-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lang] Add parallel sort utility #3790
Conversation
✔️ Deploy Preview for jovial-fermat-aa59dc ready! 🔨 Explore the source changes: 39d1344 🔍 Inspect the deploy log: https://app.netlify.com/sites/jovial-fermat-aa59dc/deploys/61b8ebe9b393ed00078c1e2f 😎 Browse the preview: https://deploy-preview-3790--jovial-fermat-aa59dc.netlify.app |
Maybe add an option where we can sort based on a sort key? Which takes two arrays |
Hi, thanks a lot for the quick implementation. I wonder do we have another place to put these parallel intrinsics? Since more will be added later, IMHO looking at the |
Yeah I'm not sure if this is right place either. I chose the |
We have some linalg implementations at |
I don't really think it belongs in |
ehmm, in this case it is a utility helper correct. I thought we could offer functions such as parallel sort, reduce, scan... as the parallel intrinsics offered by the Taichi language. Nevertheless, i am also fine with keeping it here at |
That's a pretty good idea. We should group these into the same directory once we also have an API for reduce and scan. But for now I think let's just leave it in tools. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This is an implementation of parallel odd-even merge sort.
related issue = #3764
References:
https://developer.nvidia.com/gpugems/gpugems2/part-vi-simulation-and-numerical-algorithms/chapter-46-improved-gpu-sorting
https://en.wikipedia.org/wiki/Batcher_odd%E2%80%93even_mergesort
This will be very useful for #3781 as well. We likely won't be having atomics in WebGPU (sadge), but one can always use a sort to simulate atomic operations. To demonstrate this, I will open another PR to add versions of
mpm99.py
andpbf2d.py
that are atomics-free but uses sorting.