public HuForceDirectedLayout(int steps) { #if !DEBUG try { #endif CUDADriver.cuInit(0); dev = new CUdevice(); CUDADriver.cuDeviceGet(ref dev, 0); ctx = new CUcontext(); CUDADriver.cuCtxCreate(ref ctx, 0, dev); mod = new CUmodule(); CUDADriver.cuModuleLoad(ref mod, "BarnesHut.cubin"); prop = new CUDeviceProperties(); CUDADriver.cuDeviceGetProperties(ref prop, dev); int version = 0; CUDADriver.cuDriverGetVersion(ref version); string caps = ""; GASS.CUDA.CUDARuntime.cudaRuntimeGetVersion(ref version); caps += "\tClock rate = " + prop.clockRate/1000000 + " MHz\n"; caps += "\tMemory size = " + prop.totalConstantMemory/1024 + " KB\n"; caps += "\tThreads per block = " + prop.maxThreadsPerBlock + "\n"; caps += "\tWarp size = " + prop.SIMDWidth + "\n"; caps += "\tCUDA version = " + version + "\n"; Logger.AddMessage(LogEntryType.Info, "Successfully initialized CUDA GPU computation\n"+caps); #if !DEBUG } catch(Exception ex) { Logger.AddMessage(LogEntryType.Warning, "CUDA not available, falling back to CPU. Exception was: " + ex.Message); CUDAEnabled = false; } #endif }
public static extern CUResult cuWGLGetDevice(ref CUdevice pDevice, IntPtr hGpu);
public static extern CUResult cuGLCtxCreate(ref CUcontext pCtx, uint Flags, CUdevice device);
public static extern CUResult cuD3D10CtxCreate(ref CUcontext pCtx, ref CUdevice pCuDevice, uint Flags, IntPtr pDxDevice);
public static extern CUResult cuD3D10GetDevice(ref CUdevice pDevice, IntPtr pAdapter);
public static extern CUResult cuD3D9CtxCreate(ref CUcontext pCtx, ref CUdevice pCuDevice, CUCtxFlags Flags, IntPtr pDxDevice);
public static extern CUResult cuD3D9GetDevice(ref CUdevice pDevice, string pszAdapterName);
public static extern CUResult cuDeviceGet(ref CUdevice device, int ordinal);
public static extern CUResult cuDeviceGetAttribute(ref int pi, CUDeviceAttribute attrib, CUdevice dev);
public static extern CUResult cuCtxGetDevice(ref CUdevice device);
public static extern CUResult cuDeviceComputeCapability(ref int major, ref int minor, CUdevice dev);
public static extern CUResult cuCtxCreate(ref CUcontext pctx, uint flags, CUdevice dev);
public static extern CUResult cuDeviceCanAccessPeer(ref int canAccessPeer, CUdevice dev, CUdevice peerDev);
public static extern CUResult cuDeviceTotalMem(ref SizeT bytes, CUdevice dev);
public static extern CUResult cuDeviceGetProperties(ref CUDeviceProperties prop, CUdevice dev);
public static extern CUResult cuDeviceGetName([Out] byte[] name, int len, CUdevice dev);