Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

push_back using Thrust library

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

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

Is there a way to use it like for example:

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

and what about creating an array of device_vectors? Is it possible?

like image 881
Manolete Avatar asked Sep 12 '12 10:09

Manolete


1 Answers

  1. Yes, thrust::device_vector has a push_back method just like a std::vector.
  2. No, it is not possible to have a device_vector containing device_vectors. If you need that sort of functionality in thrust I would recommend looking at thrust::zip_iterator which can provide "array of structures" like access to a series of distinct vectors or iterators.
like image 129
talonmies Avatar answered Sep 19 '22 04:09

talonmies