cudathrustcub

CUB sort with iterator


I would like to transform values and sort them in one go, like this:

thrust::vector<int> dataIn  = ...
thrust::vector<int> dataOut = ...
auto iterIn = cub::TransformInputIterator<int, Ftor, int*>(dataIn.begin(), Ftor());
cub::DeviceRadixSort::SortKeys(dTemp, tempBytes, iterIn, dataOut.begin(), numElems);

However, SortKeys requires raw pointers instead of the iterators. Is it possible to make this work using iterators nonetheless? I know this is possible with thrust, but I want to use CUB.

Thanks for the suggestions.


Solution

  • Sorry to disappoint, but AFAIK CUB doesn't support this. It could, theoretically, with deeper templatization, but it doesn't.

    You could lift the code from within cub, or modify the code with an extra template parameter. That would be a headache, but it is doable if all you want to do is pass the input values through some transformation with a device-side function.