本文整理了Java中jcuda.runtime.JCuda
类的一些代码示例,展示了JCuda
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JCuda
类的具体详情如下:
包路径:jcuda.runtime.JCuda
类名称:JCuda
[英]Java bindings for the NVidia CUDA runtime API.
Most comments are extracted from the CUDA online documentation
[中]英伟达CUDA运行时API的java绑定。
大多数评论摘自CUDA在线文档
代码示例来源:origin: deepdsl/deepdsl
public void free() { cudaFree(data); }
代码示例来源:origin: org.jcuda/jcuda
public static int cudaStreamCreateWithPriority(cudaStream_t pStream, int flags, int priority)
{
return checkResult(cudaStreamCreateWithPriorityNative(pStream, flags, priority));
}
private static native int cudaStreamCreateWithPriorityNative(cudaStream_t pStream, int flags, int priority);
代码示例来源:origin: org.nd4j/nd4j-jcublas-common
return checkResult(cudaArrayGetInfoNative(desc, extent, flags, array));
代码示例来源:origin: org.nd4j/jcuda
public static int cudaStreamGetPriority(cudaStream_t hStream, int priority[])
{
return checkResult(cudaStreamGetPriorityNative(hStream, priority));
}
private static native int cudaStreamGetPriorityNative(cudaStream_t hStream, int priority[]);
代码示例来源:origin: org.jcuda/jcuda
public static int cudaStreamAttachMemAsync(cudaStream_t stream, Pointer devPtr, long length, int flags)
{
return checkResult(cudaStreamAttachMemAsyncNative(stream, devPtr, length, flags));
}
private static native int cudaStreamAttachMemAsyncNative(cudaStream_t stream, Pointer devPtr, long length, int flags);
代码示例来源:origin: org.nd4j/nd4j-jcublas-common
cudaResult = JCuda.cudaMalloc(deviceRIdata, rIdata.length * Sizeof.DOUBLE);
if (cudaResult != cudaError.cudaSuccess)
cudaResult = JCuda.cudaMalloc(deviceCOdata, cOdata.length * Sizeof.DOUBLE);
if (cudaResult != cudaError.cudaSuccess)
JCuda.cudaFree(deviceCOdata);
if (exceptionsEnabled)
cudaResult = JCuda.cudaMemcpy(deviceRIdata, hostRIdata, rIdata.length * Sizeof.DOUBLE, cudaMemcpyKind.cudaMemcpyHostToDevice);
if (cudaResult != cudaError.cudaSuccess)
JCuda.cudaFree(deviceRIdata);
if (!inPlace)
JCuda.cudaFree(deviceCOdata);
JCuda.cudaFree(deviceRIdata);
if (!inPlace)
JCuda.cudaFree(deviceCOdata);
cudaResult = JCuda.cudaMemcpy(hostCOdata, deviceCOdata, cOdata.length * Sizeof.DOUBLE, cudaMemcpyKind.cudaMemcpyDeviceToHost);
if (cudaResult != cudaError.cudaSuccess)
JCuda.cudaFree(deviceRIdata);
if (!inPlace)
JCuda.cudaFree(deviceCOdata);
代码示例来源:origin: org.jcuda/jcudnn
/**
* Initializes the native library. Note that this method
* does not have to be called explicitly, since it will
* be called automatically when this class is loaded.
*/
public static void initialize()
{
if (!initialized)
{
String libraryBaseName = "JCudnn-" + JCuda.getJCudaVersion();
String libraryName =
LibUtils.createPlatformLibraryName(libraryBaseName);
LibUtils.loadLibrary(libraryName);
initialized = true;
}
}
代码示例来源:origin: com.simiacryptus/mindseye-cudnn
@Nonnull int[] runtimeVersion = {0};
@Nonnull int[] driverVersion = {0};
JCuda.cudaRuntimeGetVersion(runtimeVersion);
JCuda.cudaDriverGetVersion(driverVersion);
@Nonnull CharSequence jCudaVersion = JCuda.getJCudaVersion();
out.printf("Time: %s; Driver %s; Runtime %s; Lib %s%n", new Date(), driverVersion[0], runtimeVersion[0], jCudaVersion);
@Nonnull long[] free = {0};
@Nonnull long[] total = {0};
JCuda.cudaMemGetInfo(free, total);
out.printf("Cuda Memory: %.1f freeRef, %.1f total%n", free[0] * 1.0 / (1024 * 1024), total[0] * 1.0 / (1024 * 1024));
@Nonnull final int[] deviceCount = new int[1];
JCuda.cudaGetDeviceCount(deviceCount);
IntStream.range(0, deviceCount[0]).forEach(device -> {
@Nonnull final cudaDeviceProp deviceProp = new cudaDeviceProp();
JCuda.cudaGetDeviceProperties(deviceProp, device);
out.printf("Device %d = %s%n", device, deviceProp, free[0], total[0]);
});
代码示例来源:origin: org.nd4j/jcuda
public static int cudaStreamGetFlags(cudaStream_t hStream, int flags[])
{
return checkResult(cudaStreamGetFlagsNative(hStream, flags));
}
private static native int cudaStreamGetFlagsNative(cudaStream_t hStream, int flags[]);
代码示例来源:origin: org.nd4j/nd4j-jcublas-common
public static int cudaDeviceGetStreamPriorityRange(int leastPriority[], int greatestPriority[])
{
return checkResult(cudaDeviceGetStreamPriorityRangeNative(leastPriority, greatestPriority));
}
private static native int cudaDeviceGetStreamPriorityRangeNative(int leastPriority[], int greatestPriority[]);
代码示例来源:origin: org.nd4j/nd4j-jcublas-common
/**
* Destroys a surface object.
*
* <pre>
* cudaError_t cudaDestroySurfaceObject (
* cudaSurfaceObject_t surfObject )
* </pre>
* <div>
* <p>Destroys a surface object. Destroys the
* surface object specified by <tt>surfObject</tt>.
* </p>
* </div>
*
* @param surfObject Surface object to destroy
*
* @return cudaSuccess, cudaErrorInvalidValue
*
* @see JCuda#cudaCreateSurfaceObject
*/
public static int cudaDestroySurfaceObject(cudaSurfaceObject surfObject)
{
return checkResult(cudaDestroySurfaceObjectNative(surfObject));
}
private static native int cudaDestroySurfaceObjectNative(cudaSurfaceObject surfObject);
代码示例来源:origin: org.jcuda/jcuda
/**
* Destroys a texture object.
*
* <pre>
* cudaError_t cudaDestroyTextureObject (
* cudaTextureObject_t texObject )
* </pre>
* <div>
* <p>Destroys a texture object. Destroys the
* texture object specified by <tt>texObject</tt>.
* </p>
* </div>
*
* @param texObject Texture object to destroy
*
* @return cudaSuccess, cudaErrorInvalidValue
*
* @see JCuda#cudaCreateTextureObject
*/
public static int cudaDestroyTextureObject(cudaTextureObject texObject)
{
return checkResult(cudaDestroyTextureObjectNative(texObject));
}
private static native int cudaDestroyTextureObjectNative(cudaTextureObject texObject);
代码示例来源:origin: org.nd4j/jcuda
return checkResult(cudaBindSurfaceToArrayNative(surfref, array, desc));
代码示例来源:origin: org.nd4j/nd4j-jcublas-common
return checkResult(cudaBindTextureToArrayNative(texref, array, desc));
代码示例来源:origin: org.jcuda/jcuda
return checkResult(cudaBindTextureNative(offset, texref, devPtr, desc, size));
代码示例来源:origin: org.nd4j/nd4j-jcublas-common
return checkResult(cudaBindTexture2DNative(offset, texref, devPtr, desc, width, height, pitch));
代码示例来源:origin: deepdsl/deepdsl
public static void copyDeviceToDevice(long size, Pointer source, Pointer target) {
size = size * Sizeof.FLOAT;
int ret = cudaMemcpy(target, source, size, cudaMemcpyDeviceToDevice);
checkError(ret);
}
代码示例来源:origin: org.nd4j/jcuda
public static int cudaMallocManaged(Pointer devPtr, long size, int flags)
{
return checkResult(cudaMallocManagedNative(devPtr, size, flags));
}
private static native int cudaMallocManagedNative(Pointer devPtr, long size, int flags);
代码示例来源:origin: org.jcuda/jcuda
/**
* Returns the CUDA Runtime version.
*
* <pre>
* cudaError_t cudaRuntimeGetVersion (
* int* runtimeVersion )
* </pre>
* <div>
* <p>Returns the CUDA Runtime version.
* Returns in <tt>*runtimeVersion</tt> the version number of the installed
* CUDA Runtime. This function automatically returns cudaErrorInvalidValue
* if the <tt>runtimeVersion</tt> argument is NULL.
* </p>
* </div>
*
* @param runtimeVersion Returns the CUDA Runtime version.
*
* @return cudaSuccess, cudaErrorInvalidValue
*
* @see JCuda#cudaDriverGetVersion
*/
public static int cudaRuntimeGetVersion(int runtimeVersion[])
{
return checkResult(cudaRuntimeGetVersionNative(runtimeVersion));
}
private static native int cudaRuntimeGetVersionNative(int runtimeVersion[]);
代码示例来源:origin: deepdsl/deepdsl
public static void allocByte(Pointer data, long size) {
checkError(cudaMalloc(data, size));
}
内容来源于网络,如有侵权,请联系作者删除!