Library/ManagedCuda/CudaContext.cs
/// <summary>
/// Gets the CUdevice for a given device ordinal number
/// </summary>
/// <param name="deviceId"></param>
/// <returns></returns>
Gets the CUdevice for a given device ordinal number
Gets the CUdevice for a given device ordinal number
public static CUdevice GetCUdevice(int deviceId)
		{
			CUResult res;
			int deviceCount = GetDeviceCount();
			if (deviceCount == 0)
			{
				throw new CudaException(CUResult.ErrorNoDevice, "Cuda initialization error: There is no device supporting CUDA", null);
			}
			if (deviceId < 0 || deviceId > deviceCount - 1)
				throw new ArgumentOutOfRangeException("deviceID", deviceId, "The device ID is not in the range [0.." + (deviceCount - 1).ToString() + "]");
			CUdevice device = new CUdevice();
			res = DriverAPINativeMethods.DeviceManagement.cuDeviceGet(ref device, deviceId);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuDeviceGet", res));
			if (res != CUResult.Success)
				throw new CudaException(res);
			return device;
		}
public static CUdevice GetCUdevice ( int deviceId ) { CUResult res ; int deviceCount = GetDeviceCount ( ) ; if ( deviceCount == 0 ) { throw new CudaException ( CUResult . ErrorNoDevice , " " , null ) ; } if ( deviceId < 0 || deviceId > deviceCount - 1 ) throw new ArgumentOutOfRangeException ( " " , deviceId , " " + ( deviceCount - 1 ) . ToString ( ) + " " ) ; CUdevice device = new CUdevice ( ) ; res = DriverAPINativeMethods . DeviceManagement . cuDeviceGet ( ref device , deviceId ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != CUResult . Success ) throw new CudaException ( res ) ; return device ; }
Gets the CUdevice for a given device ordinal number
Gets the CUdevice for a given device ordinal number
None
deviceId
int
None