Library/ManagedCuda/CudaContext.cs
/// <summary>
/// Get the number of CUDA capable devices
/// </summary>
/// <returns></returns>
Get the number of CUDA capable devices
Get the number of CUDA capable devices
public static int GetDeviceCount()
		{
			CUResult res;
			int deviceCount = 0;
			res = DriverAPINativeMethods.DeviceManagement.cuDeviceGetCount(ref deviceCount);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuDeviceGetCount", res));
			if (res == CUResult.ErrorNotInitialized)
			{
				res = DriverAPINativeMethods.cuInit(CUInitializationFlags.None);
				Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuInit", res));
				if (res != CUResult.Success)
					throw new CudaException(res);
				res = DriverAPINativeMethods.DeviceManagement.cuDeviceGetCount(ref deviceCount);
				Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuDeviceGetCount", res));
				if (res != CUResult.Success)
					throw new CudaException(res);
			}
			else if (res != CUResult.Success)
				throw new CudaException(res);
			return deviceCount;
		}
public static int GetDeviceCount ( ) { CUResult res ; int deviceCount = 0 ; res = DriverAPINativeMethods . DeviceManagement . cuDeviceGetCount ( ref deviceCount ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res == CUResult . ErrorNotInitialized ) { res = DriverAPINativeMethods . cuInit ( CUInitializationFlags . None ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != CUResult . Success ) throw new CudaException ( res ) ; res = DriverAPINativeMethods . DeviceManagement . cuDeviceGetCount ( ref deviceCount ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != CUResult . Success ) throw new CudaException ( res ) ; } else if ( res != CUResult . Success ) throw new CudaException ( res ) ; return deviceCount ; }
Get the number of CUDA capable devices
Get the number of CUDA capable devices
None