Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between memcpy_htod and to_gpu in Pycuda?

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.

like image 778
Pippi Avatar asked Nov 17 '13 18:11

Pippi


1 Answers

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.

like image 166
Roger Dahl Avatar answered Sep 18 '22 13:09

Roger Dahl