Question about sorting using CUDA


I have the following situation. I have an array of floating point values (keys) and two floating point arrays each containing 3D points (the arrays are of size number_of_points*3). The x, y, z coordinates are basically kept one after the other.


float *keys; // contains key values

float *arr1; // 3D points…x, y, z, x, y, z, x, y, z…

float *arr2; // 3D points…x, y, z, x, y, z, x, y, z…[/codebox]

Now, I need to sort these arrays in ascending order based on the key values.

I looked at the SDK and there seems to be a radix sort example and I was unable to figure out how to m odify it for my needs. Can someone provide any suggestion on how I might go about this.

I have about half a million keys to sort. So, it is not too many. The algorithm does not have to be the best in business but just good enough.



Check out thrust or cupp.

Here is an example of two ways to do what you want using thrust:…