Skip to content

Q about CUDA API:cudaHostAlloc #373

Answered by leofang
kaixiangjin asked this question in Q&A
Discussion options

You must be logged in to vote

cudaHostAllocMapped is automatically set if you only use CUDA runtime APIs (or CUDA driver APIs with explicit use of the primary context), since the primary context has this flag set by default on devices supporting address mapping.

Now, with address mapping CUDA kernels can directly access host pinned memory without extra copy to the device memory, which explains what you saw. This is possible because, since the memory is pinned/page-locked, the OS guarantees that during the lifetime of the memory there's no page swapping happening while the kernel is doing its work, and so reading/writing this memory from device is safe.

There are a few potential issues (or benefits, depending on your p…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by leofang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants