Пример #1
0
 static FloatBuffer getUnifiedFloatBuffer(Pointer pinnedMemory, CUdeviceptr devicePtr, long size) {
   JCudaDriver.cuMemHostAlloc(pinnedMemory, size, JCudaDriver.CU_MEMHOSTALLOC_DEVICEMAP);
   final ByteBuffer byteBuffer = pinnedMemory.getByteBuffer(0, size);
   byteBuffer.order(ByteOrder.nativeOrder());
   JCudaDriver.cuMemHostGetDevicePointer(devicePtr, pinnedMemory, 0);
   return byteBuffer.asFloatBuffer();
 }
Пример #2
0
  public static int[] getUnifiedIntArray(Pointer pinnedMemory, CUdeviceptr devicePtr, int size) {
    int[] values = new int[size];
    JCudaDriver.cuMemHostAlloc(pinnedMemory, size, JCudaDriver.CU_MEMHOSTALLOC_DEVICEMAP);
    final ByteBuffer byteBuffer = pinnedMemory.getByteBuffer(0, size);
    byteBuffer.order(ByteOrder.nativeOrder());
    JCudaDriver.cuMemHostGetDevicePointer(devicePtr, pinnedMemory, 0);

    return values;
  }