Can I use thrust :: host_vector or should I use cudaHostAlloc for a null copy with Thrust?

I want to use a null copy in the mapped memory of cudaHostGetDevicePointer . Can I use thrust::host_vector , or should I use cudaHostAlloc(...,cudaHostAllocMapped)? Or is it somehow easier to do with Thrust?

+6
source share
1 answer

I am sure it is not yet possible to use thrust :: host_vector as a distributed host allocation. There is a designated memory allocator, but I do not believe that available memory is available. What you need to do is something like this:

  • cudaHostAlloc mapped memory with cudaHostAlloc application
  • Get device pointer for null copy using cudaHostGetDevicePointer
  • Create thrust::device_ptr using thrust::device_pointer_cast on this device pointer (see here for more information)

You can either make thrust::device_vector with thrust::device_ptr , or dirctly pass thrust::device_ptr any algorithms that accept an iterator.

+5
source

Source: https://habr.com/ru/post/921509/


All Articles