1

I have C++ code with several CUDA kernels. Some operations would be easier to do with the Thrust library. Can one mix thrust calls with CUDA kernels?

More specifically, assume I have a thrust device vector declared like this:

thrust::device_vector<int> d_myVector;

Then assume I use thrust to perform some operation on that device vector. Can I later access that device vector directly from a CUDA kernel? Or, do I have to copy the thrust device vector back to the host, and then convert it to something the CUDA kernel can use, and then copy it back to the device?

JB_User
  • 3,117
  • 7
  • 31
  • 51
  • 2
    See the linked duplicate. You can cast a pointer to the data held by the vector into a pointer which can be passed to a kernel – talonmies Dec 16 '20 at 00:56

0 Answers0