/// <summary> /// Destroy all allocations and reset all state on the primary context /// <para/> /// Explicitly destroys and cleans up all resources associated with the current /// device in the current process. /// <para/> /// Note that it is responsibility of the calling function to ensure that no /// other module in the process is using the device any more. For that reason /// it is recommended to use ::cuDevicePrimaryCtxRelease() in most cases. /// However it is safe for other modules to call ::cuDevicePrimaryCtxRelease() /// even after resetting the device. /// </summary> /// <param name="device">Device for which primary context is destroyed</param> public static void Reset(CUdevice device) { CUResult res; res = DriverAPINativeMethods.ContextManagement.cuDevicePrimaryCtxReset(device); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuDevicePrimaryCtxReset", res)); if (res != CUResult.Success) throw new CudaException(res); }
public static extern CUResult cuDeviceTotalMem_v2(ref SizeT bytes, CUdevice dev);
public static extern CUResult cuDevicePrimaryCtxGetState(CUdevice dev, ref CUCtxFlags flags, ref int active);
public static extern CUResult cuDeviceCanAccessPeer(ref int canAccessPeer, CUdevice dev, CUdevice peerDev);
public static extern CUResult cuCtxCreate_v2(ref CUcontext pctx, CUCtxFlags flags, CUdevice dev);
public static extern CUResult cuDevicePrimaryCtxRetain(ref CUcontext pctx, CUdevice dev);
public static extern CUResult cuD3D9GetDevice(ref CUdevice pCudaDevice, string pszAdapterName);
public static extern CUResult cuDeviceGetByPCIBusId(ref CUdevice dev, byte[] pciBusId);
public static extern CUResult cuD3D11GetDevice(ref CUdevice device, IntPtr pAdapter);
public static extern CUResult cuD3D11CtxCreateOnDevice(ref CUcontext pCtx, CUCtxFlags flags, IntPtr pD3DDevice, CUdevice cudaDevice);
public static extern CUResult cuWGLGetDevice(ref CUdevice pDevice, IntPtr hGpu);
public static extern CUResult cuGLCtxCreate(ref CUcontext pCtx, CUCtxFlags Flags, CUdevice device);
public static extern CUResult cuGLGetDevices(ref uint pCudaDeviceCount, CUdevice[] pCudaDevices, uint cudaDeviceCount, CUGLDeviceList deviceList);
public static extern CUResult cuDeviceGetProperties(ref CUDeviceProperties prop, CUdevice dev);
public static extern CUResult cuD3D9CtxCreate(ref CUcontext pCtx, ref CUdevice pCudaDevice, CUCtxFlags Flags, IntPtr pD3DDevice);
public static extern CUResult cuDeviceGetAttribute(ref int pi, CUDeviceAttribute attrib, CUdevice dev);
public static extern CUResult cuMemAdvise(CUdeviceptr devPtr, SizeT count, CUmemAdvise advice, CUdevice device);
public static extern CUResult cuDeviceGetPCIBusId(byte[] pciBusId, int len, CUdevice dev);
public static extern CUResult cuMemPrefetchAsync(CUdeviceptr devPtr, SizeT count, CUdevice dstDevice, CUstream hStream);
public static extern CUResult cuCtxGetDevice(ref CUdevice device);
public static extern CUResult cuDeviceGetP2PAttribute(ref int value, CUdevice_P2PAttribute attrib, CUdevice srcDevice, CUdevice dstDevice);
public static extern CUResult cuDevicePrimaryCtxSetFlags(CUdevice dev, CUCtxFlags flags);
public static extern CUResult cuDeviceGetName([Out] byte[] name, int len, CUdevice dev);
public static extern CUResult cuDevicePrimaryCtxReset(CUdevice dev);
public static extern CUResult cuDeviceComputeCapability(ref int major, ref int minor, CUdevice dev);
public static extern CUResult cuDeviceGet(ref CUdevice device, int ordinal);
/// <summary> /// Get the state of the primary context<para/> /// Returns in flags the flags for the primary context of device, and in /// active whether it is active. See ::cuDevicePrimaryCtxSetFlags for flag /// values. /// </summary> /// <param name="device">Device to get primary context flags for</param> /// <param name="flags">Pointer to store flags</param> /// <param name="active">Pointer to store context state</param> public static void GetState(CUdevice device, out CUCtxFlags flags, out bool active) { CUResult res; flags = new CUCtxFlags(); int temp = 0; res = DriverAPINativeMethods.ContextManagement.cuDevicePrimaryCtxGetState(device, ref flags, ref temp); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuDevicePrimaryCtxGetState", res)); if (res != CUResult.Success) throw new CudaException(res); active = temp == 1; }