1
votes

The documentation for cudaHostAlloc() says that with cudaHostAllocMapped flag it allocates pinned memory on the host and "Maps the allocation into the CUDA address space". Does it mean that a mirror buffer is allocated on the device too? Either during cudaHostAlloc() or cudaHostGetDevicePointer() call. Or does the device communicate with the host memory upon each access to the pointer returned by cudaHostGetDevicePointer() ?

This question is different from When to use cudaHostRegister() and cudaHostAlloc()? What is the meaning of "Pinned or page-locked" memory? Which are the equivalent in OpenCL? because I don't ask what the APIs are, when to use them or what is pinned memory. I ask specifically whether a mirror buffer is allocated on GPU or not.

1
@Leos313, there is nothing in that question or answers about the mirror buffer. I already knew the answers for that question. I am interested in the details on how GPU accesses CPU memory. - Serge Rogatch
No memory is allocated on the device, all accesses go to host memory. This documentation may be better suited for your needs. - tera

1 Answers

5
votes

No "mirror" buffer is allocated.

When device code uses a pointer that refers to mapped host memory, then a device read or write using that pointer will generated PCIE traffic to transfer the data to/from host memory, to service that read or write.