I have a thrust device_vector. I want to cast it to a raw pointer so that I can pass it to a kernel. How can I do so?
thrust::device_vector<int> dv(10);
//CAST TO RAW
kernel<<<bl,tpb>>>(pass raw)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do this using
thrust::raw_pointer_cast. The device vector class has a member functiondatawhich will return athrust::device_ptrto the memory held by the vector, which can be cast, something like this:(disclaimer: written in browser, never compiled, never tested). There is a full working example of this included with thrust: unwrap_pointer.cu