本文整理了Java中jcuda.runtime.JCuda.cudaMemcpy()
方法的一些代码示例,展示了JCuda.cudaMemcpy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JCuda.cudaMemcpy()
方法的具体详情如下:
包路径:jcuda.runtime.JCuda
类名称:JCuda
方法名:cudaMemcpy
[英]Copies data between host and device.
cudaError_t cudaMemcpy (
void* dst,
const void* src,
size_t count,
cudaMemcpyKind kind )
Copies data between host and device. Copies count bytes from the memory area pointed to by src to the memory area pointed to by dst, where kind is one of cudaMemcpyHostToHost, cudaMemcpyHostToDevice, cudaMemcpyDeviceToHost, or cudaMemcpyDeviceToDevice, and specifies the direction of the copy. The memory areas may not overlap. Calling cudaMemcpy() with dst and src pointers that do not match the direction of the copy results in an undefined behavior.
Note:
cudaError_t cudaMemcpy (
void* dst,
const void* src,
size_t count,
cudaMemcpyKind kind )
在主机和设备之间复制数据。将计数字节从src指向的内存区域复制到dst指向的内存区域,其中种类是cudaMemcpyHostToHost主机、cudaMemcpyHostToDevice、cudaMemcpyDeviceToHost或cudaMemcpyDeviceToDevice中的一种,并指定复制方向。内存区域不能重叠。使用与复制方向不匹配的dst和src指针调用cudaMemcpy()会导致未定义的行为。
注:
*请注意,此函数还可能返回以前异步启动的错误代码。
*对于大多数用例,此函数显示同步行为。
代码示例来源: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: deepdsl/deepdsl
public static void copyDeviceToHost(Pointer source, byte[] target) {
long size = target.length;
int ret = cudaMemcpy(Pointer.to(target), source, size, cudaMemcpyDeviceToHost);
checkError(ret);
}
代码示例来源:origin: deepdsl/deepdsl
public static void copyHostToDevice(float[] source, Pointer target) {
long size = source.length * Sizeof.FLOAT;
int ret = cudaMemcpy(target, Pointer.to(source), size, cudaMemcpyHostToDevice);
checkError(ret);
}
代码示例来源:origin: deepdsl/deepdsl
public static void copyDeviceToHost(Pointer source, float[] target) {
long size = target.length * Sizeof.FLOAT;
int ret = cudaMemcpy(Pointer.to(target), source, size, cudaMemcpyDeviceToHost);
checkError(ret);
}
代码示例来源:origin: deepdsl/deepdsl
public static void copyHostToDevice(byte[] source, Pointer target) {
long size = source.length;
int ret = cudaMemcpy(target, Pointer.to(source), size, cudaMemcpyHostToDevice);
checkError(ret);
}
代码示例来源:origin: com.simiacryptus/mindseye
/**
* Cuda memcpy int.
*
* @param dst the dst
* @param src the src
* @param count the count
* @param cudaMemcpyKind_kind the cuda memcpy kind kind
*/
public static void cudaMemcpy(final CudaPointer dst, final CudaPointer src, final long count, final int cudaMemcpyKind_kind) {
long startTime = System.nanoTime();
final int result = JCuda.cudaMemcpy(dst, src, count, cudaMemcpyKind_kind);
cudaMemcpy_execution.accept((System.nanoTime() - startTime) / 1e9);
log("cudaMemcpy", result, new Object[]{dst, src, count, cudaMemcpyKind_kind});
handle(result);
}
代码示例来源:origin: com.simiacryptus/mindseye-cudnn
/**
* Cuda memcpy int.
*
* @param dst the dst
* @param src the src
* @param count the count
* @param cudaMemcpyKind_kind the cuda memcpy kind kind
*/
public static void cudaMemcpy(final CudaPointer dst, final CudaPointer src, final long count, final int cudaMemcpyKind_kind) {
long startTime = System.nanoTime();
final int result = JCuda.cudaMemcpy(dst, src, count, cudaMemcpyKind_kind);
cudaMemcpy_execution.accept((System.nanoTime() - startTime) / 1e9);
log("cudaMemcpy", result, new Object[]{dst, src, count, cudaMemcpyKind_kind});
handle(result);
}
代码示例来源:origin: org.nd4j/nd4j-jcublas-common
cudaResult = JCuda.cudaMemcpy(deviceCIdata, hostCIdata, cIdata.length * Sizeof.FLOAT, cudaMemcpyKind.cudaMemcpyHostToDevice);
if (cudaResult != cudaError.cudaSuccess)
cudaResult = JCuda.cudaMemcpy(hostCOdata, deviceCOdata, cOdata.length * Sizeof.FLOAT, cudaMemcpyKind.cudaMemcpyDeviceToHost);
if (cudaResult != cudaError.cudaSuccess)
代码示例来源:origin: org.nd4j/jcufft-osx
cudaResult = JCuda.cudaMemcpy(deviceCIdata, hostCIdata, cIdata.length * Sizeof.FLOAT, cudaMemcpyKind.cudaMemcpyHostToDevice);
if (cudaResult != cudaError.cudaSuccess)
cudaResult = JCuda.cudaMemcpy(hostCOdata, deviceCOdata, cOdata.length * Sizeof.FLOAT, cudaMemcpyKind.cudaMemcpyDeviceToHost);
if (cudaResult != cudaError.cudaSuccess)
代码示例来源:origin: org.nd4j/nd4j-jcublas-common
cudaResult = JCuda.cudaMemcpy(deviceRIdata, hostRIdata, rIdata.length * Sizeof.FLOAT, cudaMemcpyKind.cudaMemcpyHostToDevice);
if (cudaResult != cudaError.cudaSuccess)
cudaResult = JCuda.cudaMemcpy(hostCOdata, deviceCOdata, cOdata.length * Sizeof.FLOAT, cudaMemcpyKind.cudaMemcpyDeviceToHost);
if (cudaResult != cudaError.cudaSuccess)
代码示例来源:origin: org.nd4j/jcufft-osx
cudaResult = JCuda.cudaMemcpy(deviceRIdata, hostRIdata, rIdata.length * Sizeof.FLOAT, cudaMemcpyKind.cudaMemcpyHostToDevice);
if (cudaResult != cudaError.cudaSuccess)
cudaResult = JCuda.cudaMemcpy(hostCOdata, deviceCOdata, cOdata.length * Sizeof.FLOAT, cudaMemcpyKind.cudaMemcpyDeviceToHost);
if (cudaResult != cudaError.cudaSuccess)
代码示例来源:origin: org.nd4j/jcufft-osx
cudaResult = JCuda.cudaMemcpy(deviceCIdata, hostCIdata, cIdata.length * Sizeof.FLOAT, cudaMemcpyKind.cudaMemcpyHostToDevice);
if (cudaResult != cudaError.cudaSuccess)
cudaResult = JCuda.cudaMemcpy(hostROdata, deviceROdata, rOdata.length * Sizeof.FLOAT, cudaMemcpyKind.cudaMemcpyDeviceToHost);
if (cudaResult != cudaError.cudaSuccess)
代码示例来源:origin: org.jcuda/jcufft
cudaResult = JCuda.cudaMemcpy(deviceRIdata, hostRIdata, rIdata.length * Sizeof.DOUBLE, cudaMemcpyKind.cudaMemcpyHostToDevice);
if (cudaResult != cudaError.cudaSuccess)
cudaResult = JCuda.cudaMemcpy(hostCOdata, deviceCOdata, cOdata.length * Sizeof.DOUBLE, cudaMemcpyKind.cudaMemcpyDeviceToHost);
if (cudaResult != cudaError.cudaSuccess)
代码示例来源:origin: org.nd4j/nd4j-jcublas-common
cudaResult = JCuda.cudaMemcpy(deviceRIdata, hostRIdata, rIdata.length * Sizeof.DOUBLE, cudaMemcpyKind.cudaMemcpyHostToDevice);
if (cudaResult != cudaError.cudaSuccess)
cudaResult = JCuda.cudaMemcpy(hostCOdata, deviceCOdata, cOdata.length * Sizeof.DOUBLE, cudaMemcpyKind.cudaMemcpyDeviceToHost);
if (cudaResult != cudaError.cudaSuccess)
代码示例来源:origin: org.jcuda/jcufft
cudaResult = JCuda.cudaMemcpy(deviceCIdata, hostCIdata, cIdata.length * Sizeof.FLOAT, cudaMemcpyKind.cudaMemcpyHostToDevice);
if (cudaResult != cudaError.cudaSuccess)
cudaResult = JCuda.cudaMemcpy(hostCOdata, deviceCOdata, cOdata.length * Sizeof.FLOAT, cudaMemcpyKind.cudaMemcpyDeviceToHost);
if (cudaResult != cudaError.cudaSuccess)
代码示例来源:origin: org.nd4j/jcufft-osx
cudaResult = JCuda.cudaMemcpy(deviceRIdata, hostRIdata, rIdata.length * Sizeof.DOUBLE, cudaMemcpyKind.cudaMemcpyHostToDevice);
if (cudaResult != cudaError.cudaSuccess)
cudaResult = JCuda.cudaMemcpy(hostCOdata, deviceCOdata, cOdata.length * Sizeof.DOUBLE, cudaMemcpyKind.cudaMemcpyDeviceToHost);
if (cudaResult != cudaError.cudaSuccess)
代码示例来源:origin: org.nd4j/nd4j-jcublas-common
cudaResult = JCuda.cudaMemcpy(deviceCIdata, hostCIdata, cIdata.length * Sizeof.DOUBLE, cudaMemcpyKind.cudaMemcpyHostToDevice);
if (cudaResult != cudaError.cudaSuccess)
cudaResult = JCuda.cudaMemcpy(hostROdata, deviceROdata, rOdata.length * Sizeof.DOUBLE, cudaMemcpyKind.cudaMemcpyDeviceToHost);
if (cudaResult != cudaError.cudaSuccess)
代码示例来源:origin: org.jcuda/jcufft
cudaResult = JCuda.cudaMemcpy(deviceCIdata, hostCIdata, cIdata.length * Sizeof.FLOAT, cudaMemcpyKind.cudaMemcpyHostToDevice);
if (cudaResult != cudaError.cudaSuccess)
cudaResult = JCuda.cudaMemcpy(hostROdata, deviceROdata, rOdata.length * Sizeof.FLOAT, cudaMemcpyKind.cudaMemcpyDeviceToHost);
if (cudaResult != cudaError.cudaSuccess)
代码示例来源:origin: org.nd4j/nd4j-jcublas-common
cudaResult = JCuda.cudaMemcpy(deviceCIdata, hostCIdata, cIdata.length * Sizeof.DOUBLE, cudaMemcpyKind.cudaMemcpyHostToDevice);
if (cudaResult != cudaError.cudaSuccess)
cudaResult = JCuda.cudaMemcpy(hostCOdata, deviceCOdata, cOdata.length * Sizeof.DOUBLE, cudaMemcpyKind.cudaMemcpyDeviceToHost);
if (cudaResult != cudaError.cudaSuccess)
代码示例来源:origin: org.nd4j/nd4j-jcublas-common
cudaResult = JCuda.cudaMemcpy(deviceCIdata, hostCIdata, cIdata.length * Sizeof.FLOAT, cudaMemcpyKind.cudaMemcpyHostToDevice);
if (cudaResult != cudaError.cudaSuccess)
cudaResult = JCuda.cudaMemcpy(hostROdata, deviceROdata, rOdata.length * Sizeof.FLOAT, cudaMemcpyKind.cudaMemcpyDeviceToHost);
if (cudaResult != cudaError.cudaSuccess)
内容来源于网络,如有侵权,请联系作者删除!