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(); }
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; }