Sorting 2 or 3 arrays by key with CUDA Thrust

We have compared two approaches to sort arrays by key, with the same key. One of those approaches uses thrust::zip_iterator and the other thrust::gather.
We have tested them in the case of sorting two arrays or three arrays. In all the two cases, the approach using thrust::gather has shown to be faster.

The full codes are available on our GitHub website:
2 Arrays solution
3 Arrays solution

In the following, some timing results (NVIDIA GTX 960 card):

Timing in the case of 2 arrays for N = 1048576
zip_iterator  = 7.34ms
gather        = 4.27ms
Timing in the case of 3 arrays for N = 1048576
zip_iterator  = 9.64ms
gather        = 4.22ms

Leave a Reply

Your email address will not be published. Required fields are marked *