I want to use zero-copy on mapped memory by cudaHostGetDevicePointer
. Can I use thrust::host_vector
or I must use cudaHostAlloc(...,cudaHostAllocMapped)?
Or is it somehow easier to do with Thrust?
I am pretty sure it still isn't possible to use a thrust::host_vector as a mapped host allocation. There is a pinned memory allocator, but I don't believe mapped memory is available. What you need to do is something like this:
cudaHostAlloc
cudaHostGetDevicePointer
thrust::device_ptr
using thrust::device_pointer_cast
on that device pointer (see here for more information)You can the either make a thrust::device_vector
using the thrust::device_ptr
or dirctly pass the thrust::device_ptr
to any algorithms which accept an iterator.