0

I have a list of n intervals or domains. I would like to subdivide in parallel each interval into k parts making a new list (unordered). However, most of the subdivision won't pass certain criteria and shouldn't be added to the new list.

cilk::reducer_list_append extends the idea of parallel reduction to forming a list with push_back. This way I can collect in parallel only valid sub-intervals.

What is the thrust way of accomplishing the task? I suspect one way would be to form a large nxk list, then use parallel filter and stream compaction? But I really hope there is a reduction list append operation, because nxk can be very large indeed.

hivert
  • 10,579
  • 3
  • 31
  • 56
rych
  • 682
  • 3
  • 10
  • 22

1 Answers1

1

I am new to this forum but maybe you find some of these useful.. If you are not fixed upon Thrust, you can also have a look at Arrayfire. I learned about it quite recently and it's free for that sorts of problems.

For example, with arrayfire you can evaluate selection criterion for each interval in parallel using gfor construct, ie. consider:

// # of intervals n and # of subintervals k
const int n = 10, k = 5;

// this array represets original intervals
array A = seq(n); // A = 0,1,2,...,n-1

// for each interval A[i], subI[i] counts # of subintervals       
array subI = zeros(n);  

gfor(array i, n) {  // in parallel for all intervals
    // here evaluate your predicate for interval's subdivision
    array pred = A(i)*A(i) + 1234;
    subI(i) = pred % (k + 1);
}

//array acc = accum(subI);
int n_total = sum<float>(subI); // compute the total # of intervals
// this array keeps intervals after subdivision
array B = zeros(n_total);

std::cout << "total # of subintervals: " << n_total << "\n";
print(A);
print(subI);

gfor(array i, n_total) {
    // populate the array of new intervals
B(i) = ...
}
print(B);

of course, it depends on a way how your intervals are represented and which criterion you use for subdivision..