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 }
private void InitCudaModule() { cuda = gpuKernel.cuda; //cuda = new CUDA(0, true); //cuCtx = cuda.CreateContext(0, CUCtxFlags.MapHost); //cuda.SetCurrentContext(cuCtx); string modluePath = Path.Combine(Environment.CurrentDirectory, cudaModuleName); if (!File.Exists(modluePath)) { throw new ArgumentException("Failed access to cuda module" + modluePath); } cuModule = cuda.LoadModule(modluePath); cuFuncFindMaxIMinJ = cuda.GetModuleFunction(funcFindMaxIMinJ); cuFuncUpdateG = cuda.GetModuleFunction(funcUpdateGFunc); }
private void InitCudaModule() { cuda = new CUDA(0, true); cuModule = cuda.LoadModule(Path.Combine(Environment.CurrentDirectory, cudaModuleName)); cuFuncDotProd = cuda.GetModuleFunction(cudaProductKernelName); cuFuncGradFinalize = cuda.GetModuleFunction(cudaGradFinalizeName); cuFuncComputeBBstep = cuda.GetModuleFunction(cudaComputeBBStepName); cuFuncObjSquareW = cuda.GetModuleFunction(cudaObjWName); cuFuncObjSquareAlpha = cuda.GetModuleFunction(cudaObjAlphaName); cuFuncUpdateW = cuda.GetModuleFunction(cudaUpdateW); cuFuncUpdateAlpha = cuda.GetModuleFunction(cudaUpdateAlphaName); cuFuncMaxNorm = cuda.GetModuleFunction(cudaMaxNormName); }
internal static void SetTextureMemory(CUDA cuda, CUmodule cuModule, ref CUtexref texture, string texName, float[] data, ref CUdeviceptr memPtr) { texture = cuda.GetModuleTexture(cuModule, texName); memPtr = cuda.CopyHostToDevice(data); cuda.SetTextureAddress(texture, memPtr, (uint)(sizeof(float) * data.Length)); }
private void InitCudaModule() { string modluePath = Path.Combine(Environment.CurrentDirectory, cudaModuleName); if (!File.Exists(modluePath)) throw new ArgumentException("Failed access to cuda module" + modluePath); cuModule = cuda.LoadModule(modluePath); cuFuncDense = cuda.GetModuleFunction(funcName); }
public static extern CUResult cuModuleUnload(CUmodule hmod);
//private double ComputeObj(float[] w, float[] alpha, Problem<SparseVec> sub_prob, float[] diag) //{ // double v = 0, v1=0; // int nSV = 0; // for (int i = 0; i < w.Length; i++) // { // v += w[i] * w[i]; // v1 += 0.5*w[i] * w[i]; // } // for (int i = 0; i < alpha.Length; i++) // { // sbyte y_i = (sbyte)sub_prob.Y[i]; // //original line // //v += alpha[i] * (alpha[i] * diag[GETI(y_i, i)] - 2); // v += alpha[i] * (alpha[i] * diag[y_i + 1] - 2); // v1 += 0.5* alpha[i] * (alpha[i] * diag[y_i + 1] - 2); // if (alpha[i] > 0) ++nSV; // } // v = v / 2; // // Debug.WriteLine("Objective value = {0}", v); // // Debug.WriteLine("nSV = {0}", nSV); // return v; //} protected void InitCudaModule() { cuda = new CUDA(0, true); cuModule = cuda.LoadModule(Path.Combine(Environment.CurrentDirectory, cudaModuleName)); cuFuncDotProd = cuda.GetModuleFunction(cudaProductKernelName); cuFuncSolver = cuda.GetModuleFunction(cudaSolveL2SVM); cuFuncUpdateW = cuda.GetModuleFunction(cudaUpdateW); }
public static extern CUResult cuModuleLoadDataEx(ref CUmodule module, [In] byte[] image, uint numOptions, [In] CUJITOption[] options, [In] IntPtr[] optionValues);
public static extern CUResult cuModuleLoadFatBinary(ref CUmodule module, [In] byte[] fatCubin);
public static extern CUResult cuModuleLoadData(ref CUmodule module, [In] byte[] image);
public static extern CUResult cuModuleLoad(ref CUmodule module, string fname);
public static extern CUResult cuModuleGetTexRef(ref CUtexref pTexRef, CUmodule hmod, string name);
public static extern CUResult cuModuleGetGlobal(ref CUdeviceptr dptr, ref SizeT bytes, CUmodule hmod, string name);
public static extern CUResult cuModuleGetFunction(ref CUfunction hfunc, CUmodule hmod, string name);