Apologies for the drive-by issue, feel free to direct me to a more appropriate place to ask the question.
I'm evaluating parallel sorting algorithms that can run on GPU, and the Onesweep implementation in this repo is one of the most promising. However, on trying to understand the code I came across what I think is a serious flaw. In particular, the ranking section just uses atomicAdd() for all invocations in the workgroup with no additional synchronization. Consider for simplification the case where all keys have the same digit. The allowable results are all permutations such that the values delivered to a single invocation are ascending. Thus, what is supposed to be a stable multi-split appears not to actually be stable.
It is easy to believe that on particular hardware, failure of stability might be hard to observe, in particular I wouldn't be surprised at all if atomics from a single subgroup were resolved in order. Additionally, for this application an approximate sort may be tolerable.
Looking at the history, I wonder if commit 4aa3754 might have traded a correct but slower implementation for a faster but approximate one. Obviously, if we had subgroups (which I'm tracking closely), we could do proper WLMS, but I am interested in how well we can do with basic WGSL.
In any case, thanks for the implementation, it's an impressive and valuable resource even if we don't end up going that direction.
Apologies for the drive-by issue, feel free to direct me to a more appropriate place to ask the question.
I'm evaluating parallel sorting algorithms that can run on GPU, and the Onesweep implementation in this repo is one of the most promising. However, on trying to understand the code I came across what I think is a serious flaw. In particular, the ranking section just uses
atomicAdd()for all invocations in the workgroup with no additional synchronization. Consider for simplification the case where all keys have the same digit. The allowable results are all permutations such that the values delivered to a single invocation are ascending. Thus, what is supposed to be a stable multi-split appears not to actually be stable.It is easy to believe that on particular hardware, failure of stability might be hard to observe, in particular I wouldn't be surprised at all if atomics from a single subgroup were resolved in order. Additionally, for this application an approximate sort may be tolerable.
Looking at the history, I wonder if commit 4aa3754 might have traded a correct but slower implementation for a faster but approximate one. Obviously, if we had subgroups (which I'm tracking closely), we could do proper WLMS, but I am interested in how well we can do with basic WGSL.
In any case, thanks for the implementation, it's an impressive and valuable resource even if we don't end up going that direction.