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

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

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

JCuda.cudaFree介绍

[英]Frees memory on the device.

cudaError_t cudaFree ( 
void* devPtr )

Frees memory on the device. Frees the memory space pointed to by devPtr, which must have been returned by a previous call to cudaMalloc() or cudaMallocPitch(). Otherwise, or if cudaFree(devPtr) has already been called before, an error is returned. If devPtr is 0, no operation is performed. cudaFree() returns cudaErrorInvalidDevicePointer in case of failure.
Note:

Note that this function may also return error codes from previous, asynchronous launches.
[中]释放设备上的内存

cudaError_t cudaFree ( 
void* devPtr )

释放设备上的内存。释放devPtr指向的内存空间,该内存空间必须由上一次调用cudaMalloc()或cudamalocpatch()返回。否则,或者如果之前已经调用过cudaFree(devPtr),则返回一个错误。如果devPtr为0,则不执行任何操作。失败时,cudaFree()返回cudaErrorInvalidDevicePointer。
注:
请注意,此函数还可能返回以前异步启动的错误代码。

代码示例

代码示例来源:origin: deepdsl/deepdsl

public void free() { cudaFree(data); }

代码示例来源:origin: deepdsl/deepdsl

public static void free(Pointer data) {
  checkError(cudaFree(data));
}

代码示例来源:origin: deepdsl/deepdsl

public static Pointer pointerTo(float value) { 
    Pointer ret;
    if(value == 1) {
      ret = one;
    }
    else if (value == current){
      ret = currentPointer;
    }
    else {
      current = value;
      cudaFree(currentPointer);
      currentPointer = Pointer.to(new float[]{value}); 
      ret = currentPointer;
    }
    return ret;
  }
}

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

@Override
  public void free(DataBuffer buffer,int offset) {
    JCudaBuffer buf2 = (JCudaBuffer) buffer;
    BaseCudaDataBuffer.DevicePointerInfo devicePointerInfo = buf2.getPointersToContexts().get(Thread.currentThread().getName(),offset);
    JCuda.cudaFree(devicePointerInfo.getPointer());

  }
}

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

/**
 * Cuda freeRef int.
 *
 * @param deviceId the device id
 * @param devPtr   the dev ptr
 * @return the int
 */
public static int cudaFree(int deviceId, final CudaPointer devPtr) {
 long startTime = System.nanoTime();
 if (null == devPtr) return 0;
 Function<CudnnHandle, Integer> fn = dev -> {
  final int result = JCuda.cudaFree(devPtr);
  log("cudaFree", result, new Object[]{devPtr});
  cudaFree_execution.accept((System.nanoTime() - startTime) / 1e9);
  handle(result);
  return result;
 };
 if (deviceId < 0) {
  return fn.apply(null);
 } else {
  return CudaSystem.withDevice(deviceId, fn);
 }
}

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

/**
 * Cuda freeRef int.
 *
 * @param deviceId the device id
 * @param devPtr   the dev ptr
 * @return the int
 */
public static int cudaFree(int deviceId, final CudaPointer devPtr) {
 long startTime = System.nanoTime();
 if (null == devPtr) return 0;
 Function<CudnnHandle, Integer> fn = dev -> {
  final int result = JCuda.cudaFree(devPtr);
  log("cudaFree", result, new Object[]{devPtr});
  cudaFree_execution.accept((System.nanoTime() - startTime) / 1e9);
  handle(result);
  return result;
 };
 if (deviceId < 0) {
  return fn.apply(null);
 } else {
  return CudaSystem.withDevice(deviceId, fn);
 }
}

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

if (cudaResult != cudaError.cudaSuccess)
    JCuda.cudaFree(deviceCIdata);
    if (exceptionsEnabled)
if (cudaResult != cudaError.cudaSuccess)
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
cudaResult = JCuda.cudaFree(deviceCIdata);
if (cudaResult != cudaError.cudaSuccess)
  cudaResult = JCuda.cudaFree(deviceCOdata);
  if (cudaResult != cudaError.cudaSuccess)

代码示例来源:origin: org.nd4j/jcufft-osx

if (cudaResult != cudaError.cudaSuccess)
    JCuda.cudaFree(deviceCIdata);
    if (exceptionsEnabled)
if (cudaResult != cudaError.cudaSuccess)
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
cudaResult = JCuda.cudaFree(deviceCIdata);
if (cudaResult != cudaError.cudaSuccess)
  cudaResult = JCuda.cudaFree(deviceCOdata);
  if (cudaResult != cudaError.cudaSuccess)

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

if (cudaResult != cudaError.cudaSuccess)
    JCuda.cudaFree(deviceCOdata);
    if (exceptionsEnabled)
if (cudaResult != cudaError.cudaSuccess)
  JCuda.cudaFree(deviceRIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceRIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceRIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
cudaResult = JCuda.cudaFree(deviceRIdata);
if (cudaResult != cudaError.cudaSuccess)
  cudaResult = JCuda.cudaFree(deviceCOdata);
  if (cudaResult != cudaError.cudaSuccess)

代码示例来源:origin: org.nd4j/jcufft-osx

if (cudaResult != cudaError.cudaSuccess)
    JCuda.cudaFree(deviceCOdata);
    if (exceptionsEnabled)
if (cudaResult != cudaError.cudaSuccess)
  JCuda.cudaFree(deviceRIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceRIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceRIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
cudaResult = JCuda.cudaFree(deviceRIdata);
if (cudaResult != cudaError.cudaSuccess)
  cudaResult = JCuda.cudaFree(deviceCOdata);
  if (cudaResult != cudaError.cudaSuccess)

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

if (cudaResult != cudaError.cudaSuccess)
    JCuda.cudaFree(deviceCIdata);
    if (exceptionsEnabled)
if (cudaResult != cudaError.cudaSuccess)
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceROdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceROdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceROdata);
cudaResult = JCuda.cudaFree(deviceCIdata);
if (cudaResult != cudaError.cudaSuccess)
  cudaResult = JCuda.cudaFree(deviceROdata);
  if (cudaResult != cudaError.cudaSuccess)

代码示例来源:origin: org.jcuda/jcufft

if (cudaResult != cudaError.cudaSuccess)
    JCuda.cudaFree(deviceCIdata);
    if (exceptionsEnabled)
if (cudaResult != cudaError.cudaSuccess)
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceROdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceROdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceROdata);
cudaResult = JCuda.cudaFree(deviceCIdata);
if (cudaResult != cudaError.cudaSuccess)
  cudaResult = JCuda.cudaFree(deviceROdata);
  if (cudaResult != cudaError.cudaSuccess)

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

if (cudaResult != cudaError.cudaSuccess)
    JCuda.cudaFree(deviceCOdata);
    if (exceptionsEnabled)
if (cudaResult != cudaError.cudaSuccess)
  JCuda.cudaFree(deviceRIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceRIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceRIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
cudaResult = JCuda.cudaFree(deviceRIdata);
if (cudaResult != cudaError.cudaSuccess)
  cudaResult = JCuda.cudaFree(deviceCOdata);
  if (cudaResult != cudaError.cudaSuccess)

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

if (cudaResult != cudaError.cudaSuccess)
    JCuda.cudaFree(deviceCIdata);
    if (exceptionsEnabled)
if (cudaResult != cudaError.cudaSuccess)
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
cudaResult = JCuda.cudaFree(deviceCIdata);
if (cudaResult != cudaError.cudaSuccess)
  cudaResult = JCuda.cudaFree(deviceCOdata);
  if (cudaResult != cudaError.cudaSuccess)

代码示例来源:origin: org.nd4j/jcufft-osx

if (cudaResult != cudaError.cudaSuccess)
    JCuda.cudaFree(deviceCOdata);
    if (exceptionsEnabled)
if (cudaResult != cudaError.cudaSuccess)
  JCuda.cudaFree(deviceRIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceRIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceRIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
cudaResult = JCuda.cudaFree(deviceRIdata);
if (cudaResult != cudaError.cudaSuccess)
  cudaResult = JCuda.cudaFree(deviceCOdata);
  if (cudaResult != cudaError.cudaSuccess)

代码示例来源:origin: org.nd4j/jcufft-osx

if (cudaResult != cudaError.cudaSuccess)
    JCuda.cudaFree(deviceCIdata);
    if (exceptionsEnabled)
if (cudaResult != cudaError.cudaSuccess)
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceROdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceROdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceROdata);
cudaResult = JCuda.cudaFree(deviceCIdata);
if (cudaResult != cudaError.cudaSuccess)
  cudaResult = JCuda.cudaFree(deviceROdata);
  if (cudaResult != cudaError.cudaSuccess)

代码示例来源:origin: org.jcuda/jcufft

if (cudaResult != cudaError.cudaSuccess)
    JCuda.cudaFree(deviceCOdata);
    if (exceptionsEnabled)
if (cudaResult != cudaError.cudaSuccess)
  JCuda.cudaFree(deviceRIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceRIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceRIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
cudaResult = JCuda.cudaFree(deviceRIdata);
if (cudaResult != cudaError.cudaSuccess)
  cudaResult = JCuda.cudaFree(deviceCOdata);
  if (cudaResult != cudaError.cudaSuccess)

代码示例来源:origin: org.jcuda/jcufft

if (cudaResult != cudaError.cudaSuccess)
    JCuda.cudaFree(deviceCIdata);
    if (exceptionsEnabled)
if (cudaResult != cudaError.cudaSuccess)
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceCOdata);
cudaResult = JCuda.cudaFree(deviceCIdata);
if (cudaResult != cudaError.cudaSuccess)
  cudaResult = JCuda.cudaFree(deviceCOdata);
  if (cudaResult != cudaError.cudaSuccess)

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

if (cudaResult != cudaError.cudaSuccess)
    JCuda.cudaFree(deviceCIdata);
    if (exceptionsEnabled)
if (cudaResult != cudaError.cudaSuccess)
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceROdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceROdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceROdata);
cudaResult = JCuda.cudaFree(deviceCIdata);
if (cudaResult != cudaError.cudaSuccess)
  cudaResult = JCuda.cudaFree(deviceROdata);
  if (cudaResult != cudaError.cudaSuccess)

代码示例来源:origin: org.nd4j/jcufft-osx

if (cudaResult != cudaError.cudaSuccess)
    JCuda.cudaFree(deviceCIdata);
    if (exceptionsEnabled)
if (cudaResult != cudaError.cudaSuccess)
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceROdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceROdata);
  JCuda.cudaFree(deviceCIdata);
  if (!inPlace)
    JCuda.cudaFree(deviceROdata);
cudaResult = JCuda.cudaFree(deviceCIdata);
if (cudaResult != cudaError.cudaSuccess)
  cudaResult = JCuda.cudaFree(deviceROdata);
  if (cudaResult != cudaError.cudaSuccess)

相关文章

JCuda类方法