You can do this using thrust::raw_pointer_cast
. The device vector class has a member function data
which will return a thrust::device_ptr
to the memory held by the vector, which can be cast, something like this:
thrust::device_vector<int> dv(10);
int * dv_ptr = thrust::raw_pointer_cast(dv.data());
kernel<<<bl,tpb>>>(dv_ptr)
(disclaimer: written in browser, never compiled, never tested). There is a full working example of this included with thrust: unwrap_pointer.cu
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…