sorting data already in GPU? thrust maybe?


I want to sort some data structures that are already in GPU, produced by some kernels, in probably a new kernel. Is there any fast and easy way of doing it?

I know thrust can do parallel sorting simple when you have host data but can I use that when without copy data back to CPU and again to GPU?

Thanks for your help in advance.

I think thrust can take in device pointers as well – request you to investigate a bit more!

Yeah… Take help from some detective and spy agencies… They should help you in the investigation… What say, Crankie?

please check 2219 of GTC2010, High-Productivity CUDA Development with the Thrust Template Library.

Thanks, that was helpful. But now I have some other problem.

I want to sort a data structure with around 5 values, of course by just one value. Assume I have ID, name, start, end, and value in my struct and I want to sort by value.

I can transfer them all to arrays but then how can I use sort_by_key to sort my arrays.

I dont really know how to use templates to sort AoS.

Thanks for any help!

use a thrust::tuple inside a thrust::zip_iterator

all this is also explained in the posters or the documentation, check out

you won’t declare the types explicit, just use

make_zip_iterator(make_tuple(a, b, c))