2021年4月5日星期一

Is cuda device pointer identical between host-side and device-side?

This is very simple question, but I'm not quite sure if this is correct.

If I call cudaMalloc() on the host, and copy the given pointer value to the device, can cuda device still access the allocated memory using copied pointer?

I wonder if this can be done, and vise-versa

For example,

int* a = cudaMalloc(sizeof(int)*10);  *host_ptr = a;  //! Assume device_ptr and host_ptr is already allocated  cudaMemcpy(device_ptr, host_ptr, sizeof(int*), cudaMemcpyHostToDevice);    //! Now, can cuda device access the   //! allocated memory space with exactly same  //! pointer value as host?  //! For example,  //! int device_a = (*device_ptr)[0]; (from device code)    
https://stackoverflow.com/questions/66955490/is-cuda-device-pointer-identical-between-host-side-and-device-side April 05, 2021 at 11:30PM

没有评论:

发表评论