本文整理汇总了Java中jcuda.driver.JCudaDriver.cuDeviceTotalMem方法的典型用法代码示例。如果您正苦于以下问题:Java JCudaDriver.cuDeviceTotalMem方法的具体用法?Java JCudaDriver.cuDeviceTotalMem怎么用?Java JCudaDriver.cuDeviceTotalMem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jcuda.driver.JCudaDriver
的用法示例。
在下文中一共展示了JCudaDriver.cuDeviceTotalMem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBestDevice
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
public static CUdevice getBestDevice() {
CUdevice best = null;
long lastmem = Long.MIN_VALUE;
int [] count = new int[1];
JCudaDriver.cuDeviceGetCount(count);
for (int i = 0; i < count[0]; i++) {
CUdevice dev = new CUdevice();
JCudaDriver.cuDeviceGet(dev, i);
CUdevprop prop = new CUdevprop();
JCudaDriver.cuDeviceGetProperties(prop, dev);
//System.out.println(prop);
int [] memory = new int [1];
JCudaDriver.cuDeviceTotalMem(memory, dev);
long mem = correctMemoryValue(memory[0]);
//System.out.println("Memory " + mem);
if (mem > lastmem){
best = dev;
lastmem = mem;
}
}
return best;
}
示例2: getSmallestDevice
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
public static CUdevice getSmallestDevice() {
CUdevice best = null;
long lastmem = Long.MAX_VALUE;
int [] count = new int[1];
JCudaDriver.cuDeviceGetCount(count);
for (int i = 0; i < count[0]; i++) {
CUdevice dev = new CUdevice();
JCudaDriver.cuDeviceGet(dev, i);
CUdevprop prop = new CUdevprop();
JCudaDriver.cuDeviceGetProperties(prop, dev);
//System.out.println(prop);
int [] memory = new int [1];
JCudaDriver.cuDeviceTotalMem(memory, dev);
long mem = correctMemoryValue(memory[0]);
//System.out.println("Memory " + mem);
if (mem < lastmem){
best = dev;
lastmem = mem;
}
}
return best;
}
示例3: initCUDA
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
public void initCUDA(){
if (!inited) {
// Initialize the JCudaDriver. Note that this has to be done from
// the same thread that will later use the JCudaDriver API.
JCudaDriver.setExceptionsEnabled(true);
JCudaDriver.cuInit(0);
CUdevice dev = CUDAUtil.getBestDevice();
cuCtx = new CUcontext();
JCudaDriver.cuCtxCreate(cuCtx, 0, dev);
// check space on device:
int [] memory = new int [1];
JCudaDriver.cuDeviceTotalMem(memory, dev);
int availableMemory = (int) (CUDAUtil.correctMemoryValue(memory[0]) / ((long)1024 * 1024));
if (debug) {
System.out.println("Total available Memory on CUDA card:" + availableMemory);
}
if (debug) {
CUdevprop prop = new CUdevprop();
JCudaDriver.cuDeviceGetProperties(prop, dev);
System.out.println(prop.toFormattedString());
}
// Load the CUBIN file containing the kernel
module = new CUmodule();
JCudaDriver.cuModuleLoad(module, "CUDAVolumeFunctions.sm_10.cubin");
// Obtain a function pointer to the kernel function. This function
// will later be called.
//
if (debug) System.out.println("Initialized.");
inited = true;
}
}