Push_back using the Thrust library

Is it possible to use push_back with the Thrust library? and what about vector vectors? I would like to use in the GPU what in CPu:

 vector< vector<int> > MyVector( 100 );
 ...
 MyVector[i].push_back(j);

Is there any way to use it, for example:

thrust::device_vector<thrust::device_vector<int>> d_vec(4);

and how about creating a device_vectors array? Is it possible?

+5
source share
1 answer
  • Yes, it thrust::device_vectorhas a method push_back, like std::vector.
  • No, no device_vector, containing device_vectors. If you need such functionality in traction, I would recommend looking thrust::zip_iteratorat what an “array of structures” can provide, for example, access to a number of separate vectors or iterators.
+4
source

All Articles