Nested Zip_Iterator for output in THRUST

Hello everybody,

i have a foreach call function that is getting nested zip(tuple(zip(tuple()),zip(tuple()))) iterators because the tuples. THis is becuase i have more than ten in- and output vectors. WHen i trry to modify the output vectors it has no effect tho when doping it like

thrust::tuple<double,double,double,double> outputs=get<0>(thewholeinputtoforeach);
thrust::get<0>(output)= SOMEFUNCTION OF OTHER STUFF

I believe this doesnt work because the first line creates a deep copy of the output and changes the copy, not the output.

Trying it like this

thrust::get<0>(thrust::get<0>(thewholeinputtoforeach)= SOMEFUNCTION OF OTHER STUFF

errors with “error: expression must be a modifiable lvalue”

SO somehow i guess i have to create reference to the output iterator with pointers, but i don’t manage to.

Nay tips and ideas are highly appreciated.
best regards
Franz

It’s not clear what the problem is. The following seems to work for me:

$ cat t687.cu
#include <thrust/iterator/zip_iterator.h>
#include <thrust/device_vector.h>
#include <thrust/for_each.h>
#include <iostream>

#define DSIZE 10
#define ZIP(X,Y) thrust::make_zip_iterator(thrust::make_tuple(X,Y))

struct incr
{
  template <typename T>
  __host__ __device__
  void operator()(T d1){
  thrust::get<0>(thrust::get<0>(d1))++;
  thrust::get<1>(thrust::get<0>(d1))++;
  thrust::get<0>(thrust::get<1>(d1))++;
  thrust::get<1>(thrust::get<1>(d1))++;
  }
};

int main(){
  thrust::device_vector<int> d1(DSIZE);
  thrust::device_vector<int> d2(DSIZE);
  thrust::device_vector<int> d3(DSIZE);
  thrust::device_vector<int> d4(DSIZE);
  std::cout << d1[0] << std::endl;
  thrust::for_each(ZIP(ZIP(d1.begin(),d2.begin()), ZIP(d3.begin(),d4.begin())), ZIP(ZIP(d1.end(), d2.end()), ZIP(d3.end(), d4.end())), incr());
  std::cout << d1[0] << std::endl;

}

$ nvcc -o t687 t687.cu
$ ./t687
0
1
$

ok, thanks for the reply.
apperently my problem was that i didnt use a template functor but gave the types myself instead. ANd probably i messed up references and copies somewhere around there.

Thanks again, now it works.

best regards
Franz