6
我想通過cudaHostGetDevicePointer
在映射內存上使用零拷貝。我可以使用thrust::host_vector
還是我必須使用cudaHostAlloc(...,cudaHostAllocMapped)?
或者是否與Thrust相比更容易?我可以使用thrust :: host_vector,或者我必須使用cudaHostAlloc以使用Thrust進行零拷貝?
我想通過cudaHostGetDevicePointer
在映射內存上使用零拷貝。我可以使用thrust::host_vector
還是我必須使用cudaHostAlloc(...,cudaHostAllocMapped)?
或者是否與Thrust相比更容易?我可以使用thrust :: host_vector,或者我必須使用cudaHostAlloc以使用Thrust進行零拷貝?
我很確定它仍然不可能使用thrust :: host_vector作爲映射主機分配。有一個固定的內存分配器,但我不相信映射內存可用。你需要做的是這樣的:
cudaHostAlloc
cudaHostGetDevicePointer
thrust::device_pointer_cast
創建thrust::device_ptr
(見here瞭解更多信息)您可以使用thrust::device_ptr
的要麼做一個thrust::device_vector
或消法通過thrust::device_ptr
到任何接受迭代器的算法。
謝謝!但是我怎樣才能使用thrust :: device_ptr使thrust :: device_vector? – Alex 2012-07-30 13:26:25
你可以從一個迭代器範圍創建一個'thrust :: device_vector',所以像'thrust :: device_vector v(p,p + n)'從'device_ptr''創建矢量'v'''指向分配'n'元素。 –
talonmies
2012-07-30 18:19:27
但它會創建新的device_vector並將device_ptr p的內存複製到vector中,不是嗎? – Alex 2012-08-01 21:34:54