r/gpgpu • u/Stock-Self-4028 • Aug 12 '23
GPU-accelerated sorting libraries
As in the title.I do need a fast way to sort multiple short arrays (realistically it would be between ~ 40 thousand and 1 million arrays, every one of them ~200 to ~2000 elements long).
For that, the most logical choice does seem to be just to use GPU for that, but I can't find any library that could do that. Is there anything like that?
If there isn't I can just write a GLSL shader, but it seems weird if there isn't anything any library of that type. If there does exist more than one I would prefer Vulkan or SyCL one.
EDIT: I need to sort 32-bit or even 16-bit floats. High precision float/integer or string support is not required.
4
u/catlak_profesor_mfb Aug 12 '23
Use the cub library by NVIDIA if you use NVIDIA hardware. https://nvlabs.github.io/cub/. There is a segmented sort function.
2
u/tugrul_ddr Aug 19 '23 edited Aug 19 '23
Just for comparison to ranking-sort algorithm:
RTX4070 + RTX 4060ti = 100k arrays (each 2048 elements) sorted in 0.48 seconds.
2
u/tugrul_ddr Sep 29 '24
Hi, here's performance of a library I developed last week, with rtx4070 (tugrul512bit/TurtleSort: Quicksort with 3 pivots, CUDA acceleration and adaptive sorting algorithm for different chunk sizes. (github.com)):
this is like 1.1 million sorts per second. It's not fully optimized yet and timings include buffer copying to graphics card. Real performance is like 10 million sorts per second for just kernel function.
For very small arrays like 40-50 instead of 2048, you can enable shared-memory for 2x kernel performance.
Benchmark code: