我可以使用thrust :: host_vector或者我必须使用cudaHostAlloc进行零重复吗?

Ale*_*lex 6 cuda gpu zero-copy thrust

我想在映射内存上使用零拷贝cudaHostGetDevicePointer.我可以使用thrust::host_vector或者必须使用cudaHostAlloc(...,cudaHostAllocMapped)? 或者它是否更容易使用Thrust?

tal*_*ies 5

我很确定仍然无法使用thrust :: host_vector作为映射主机分配.有一个固定内存分配器,但我不相信映射内存可用.你需要做的是这样的事情:

  1. 分配映射的固定主机内存 cudaHostAlloc
  2. 使用获取零拷贝内存的设备指针 cudaHostGetDevicePointer
  3. 在该设备上创建一个thrust::device_ptr使用thrust::device_pointer_cast指针(有关详细信息,请参阅此处)

你可以thrust::device_vector使用thrust::device_ptr或者直接传递thrust::device_ptr给任何接受迭代器的算法.