Sorting algorithms with CUDA
21–30 of 44 posts
Re: Sorting algorithms with CUDA
#22This is not a fast way to sort on GPU. The fastest known sorting algorithm on CUDA is Onesweep, which uses a lot of sophisticated techniques to take advantage of GPU-style parallelism and work around its limitations. Linebender is working (slowly) on adapting these ideas to GPUs more portably. There's a wiki page here with some resources: https://linebender.org/wiki/gpu/sorting/
To be fair, I took this far more as an exploration on writing CUDA than I did an attempt at the best sorting method.
Re: Sorting algorithms with CUDA
#23The TL;DR is the implementer was able to get use GPUs to get merge sort speedups that exceeded CPUs once the number of elements being sorted was >10,000,000. thrust::sort is an Nvidia C++ library; I am not clear whether it is related to CUDA or not actually; the article author started out with CUDA implementing a merge sort, but once it was slower than CPU the author tried thrust::sort library and was able to get a f…
Every database co-processor, not just GPUs, have had the same issue.
Re: Sorting algorithms with CUDA
#24For a more convenient way to use GPUs for algorithms like this, the Futhark language [1] can be very valuable. It is a very high-level language that compiles to GPU instructions, which can be accessed as Python libraries. In their website there is an example of a merge sort implementation [2]. [1] https://futhark-lang.org/ [2] https://futhark-lang.org/examples/merge-sort.html
Do you use futhark in prod? Do you use it at all actually?
Re: Sorting algorithms with CUDA
#25I think you need to have huge arrays to worth sorting them on GPU. Copying data between RAM and GPU and taking it back will take some time.
Re: Sorting algorithms with CUDA
#26Re: Sorting algorithms with CUDA
#27As the other posts have said, this isn't the right algorithm. Onesweep and its kin are cool but intimidating. The magic is easier to understand if one looks into the core algorithm: radix sort. A very readable explanation is here: https://gpuopen.com/download/publications/Introduction_to_GP... It turns out that radix sort can be implemented in a way that is very straightforward to parallelize. It's a beautiful and el…
Re: Sorting algorithms with CUDA
#28As the other posts have said, this isn't the right algorithm. Onesweep and its kin are cool but intimidating. The magic is easier to understand if one looks into the core algorithm: radix sort. A very readable explanation is here: https://gpuopen.com/download/publications/Introduction_to_GP... It turns out that radix sort can be implemented in a way that is very straightforward to parallelize. It's a beautiful and el…
Yeah, but radix sort requires you to have an ordered integer key, not just two objects being comparable, like with most general sorting techniques.
structs containing strings and doubles for example are well suited to radix sort.
Re: Sorting algorithms with CUDA
#29Earlier quoted context omitted.
Yeah, but radix sort requires you to have an ordered integer key, not just two objects being comparable, like with most general sorting techniques.
I always ask in these threads, what sort of data do you have that cannot be divided into several integers, such that sorting by those integers according to some priority implements your comparator correctly, and also your comparator is not so expensive as to be impractical? on one occasion someone replied "sorting unicode strings in collation order" but it doesn't seem like recomputing the collation inside of each co…
Re: Sorting algorithms with CUDA
#30Earlier quoted context omitted.
I don't use it at all currently because the problems it solves do not come up at my job. But if they did, I would gladly use it. If your job involves a lot of heavy number crunching it might be useful.
Lololol then why are you recommending it like you know anything about it? I will never understand this kind of comment on hn - like you don't get why hyping something up that you don't actually understand is bad?
Although on second thought something like JAX is probably the better choice these days anyway.