how to parallel this simple algorithm? someone has met this before?

Hi,guys.

Now, I am confused by one ‘simple’ algorithm. It is like this:

  one array: 
index 0   1   2   3   4   5   6   7  8  9   

     a[]   0   0   1   0   0   1   0   1  0  1

I want to put the elements which has value!=0 in a into a new array, the elements in the array are the indexes indicate that which value is not 0.

   result: 
index   0   1   2   3

      result[]   2   5   7   9

Some guys has done this or met this before?

It is called “stream compaction” and it is implemented in CUDPP and Thrust.
There are plenty of papers describing it, just do a Google search

Thank you very much, mfatica.

I will google it. :thumbup: