5

I am learning PyCUDA, and while going through the documentation on pycuda.gpuarray, I am puzzled by the difference between pycuda.driver.memcpy_htod (also _dtoh) and pycuda.gpuarray.to_gpu (also get) functions. According to gpuarray documentation, .get().

For example,transfer the contents of self into array or a newly allocated numpy.ndarray. If array is given, it must have the right size (not necessarily shape) and dtype. If it is not given, a pagelocked specifies whether the new array is allocated page-locked.

Is this saying that .get() is implemented exactly the same way as pycuda.driver.memcpy_dtoh? Somehow, I think I am mis-interpreting it.

Sagar Masuti
  • 1,271
  • 2
  • 11
  • 30
Pippi
  • 2,451
  • 8
  • 39
  • 59

1 Answers1

6

pycuda.gpuarray.GPUArray.get() stores the GPUArray as a numpy.ndarray.

pycuda.driver.memcpy_dtoh() and friends copy plain buffers between CPU and GPU memory without any processing of the data in the buffers.

Roger Dahl
  • 15,132
  • 8
  • 62
  • 82