2012-07-27 26 views

回答

5

我很確定它仍然不可能使用thrust :: host_vector作爲映射主機分配。有一個固定的內存分配器,但我不相信映射內存可用。你需要做的是這樣的:

  1. 分配映射,固定主機與cudaHostAlloc
  2. 內存獲得使用cudaHostGetDevicePointer
  3. 零拷貝存儲設備指針上設備指針使用thrust::device_pointer_cast創建thrust::device_ptr (見here瞭解更多信息)

您可以使用thrust::device_ptr的要麼做一個thrust::device_vector或消法通過thrust::device_ptr到任何接受迭代器的算法。

+0

謝謝!但是我怎樣才能使用thrust :: device_ptr使thrust :: device_vector? – Alex 2012-07-30 13:26:25

+1

你可以從一個迭代器範圍創建一個'thrust :: device_vector',所以像'thrust :: device_vector v(p,p + n)'從'device_ptr''創建矢量'v'''指向分配'n'元素。 – talonmies 2012-07-30 18:19:27

+1

但它會創建新的device_vector並將device_ptr p的內存複製到vector中,不是嗎? – Alex 2012-08-01 21:34:54

相關問題