jcuda.runtime.JCuda.cudaFreeHost()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中jcuda.runtime.JCuda.cudaFreeHost()方法的一些代码示例,展示了JCuda.cudaFreeHost()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JCuda.cudaFreeHost()方法的具体详情如下:
包路径:jcuda.runtime.JCuda
类名称:JCuda
方法名:cudaFreeHost

JCuda.cudaFreeHost介绍

[英]Frees page-locked memory.

cudaError_t cudaFreeHost ( 
void* ptr )

Frees page-locked memory. Frees the memory space pointed to by hostPtr, which must have been returned by a previous call to cudaMallocHost() or cudaHostAlloc().
Note:

Note that this function may also return error codes from previous, asynchronous launches.
[中]释放页面锁定的内存

cudaError_t cudaFreeHost ( 
void* ptr )

释放页面锁定的内存。释放hostPtr指向的内存空间,该内存空间必须由先前对cudaMallocHost()或cudaHostAlloc()的调用返回。
注:
请注意,此函数还可能返回以前异步启动的错误代码。

代码示例

代码示例来源:origin: com.simiacryptus/mindseye-cudnn

/**
 * Cuda freeRef host int.
 *
 * @param devPtr the dev ptr
 * @return the int
 */
public static int cudaFreeHost(final CudaPointer devPtr) {
 long startTime = System.nanoTime();
 final int result = JCuda.cudaFreeHost(devPtr);
 cudaFreeHost_execution.accept((System.nanoTime() - startTime) / 1e9);
 log("cudaFreeHost", result, new Object[]{devPtr});
 handle(result);
 return result;
}

代码示例来源:origin: com.simiacryptus/mindseye

/**
 * Cuda freeRef host int.
 *
 * @param devPtr the dev ptr
 * @return the int
 */
public static int cudaFreeHost(final CudaPointer devPtr) {
 long startTime = System.nanoTime();
 final int result = JCuda.cudaFreeHost(devPtr);
 cudaFreeHost_execution.accept((System.nanoTime() - startTime) / 1e9);
 log("cudaFreeHost", result, new Object[]{devPtr});
 handle(result);
 return result;
}

代码示例来源:origin: org.nd4j/nd4j-jcublas-common

@Override
  public void free(DataBuffer buffer,int offset) {
    JCudaBuffer buf2 = (JCudaBuffer) buffer;
    Table<String, Integer, BaseCudaDataBuffer.DevicePointerInfo> pointers = buf2.getPointersToContexts();
    BaseCudaDataBuffer.DevicePointerInfo devicePointerInfo = pointers.get(Thread.currentThread().getName(),offset);
    if(!devicePointerInfo.isFreed()) {
      JCuda.cudaFreeHost(devicePointerInfo.getPointer());
      devicePointerInfo.setFreed(true);
    }
  }
}

相关文章

JCuda类方法