#include #include #include #include // this example fuses a gather operation with a reduction for // greater efficiency than separate gather() and reduce() calls int main() { // gather locations thrust::device_vector map = {3, 1, 0, 5}; // array to gather from thrust::device_vector source = {10, 20, 30, 40, 50, 60}; // fuse gather with reduction: // sum = source[map[0]] + source[map[1]] + ... int sum = thrust::reduce(thrust::make_permutation_iterator(source.begin(), map.begin()), thrust::make_permutation_iterator(source.begin(), map.end())); // print sum std::cout << "sum is " << sum << '\n'; return 0; }