Reduce register pressure in one-workgroup radix sort#2662
Merged
danhoeflinger merged 3 commits intomainfrom Apr 23, 2026
Merged
Reduce register pressure in one-workgroup radix sort#2662danhoeflinger merged 3 commits intomainfrom
danhoeflinger merged 3 commits intomainfrom
Conversation
Signed-off-by: Dan Hoeflinger <[email protected]>
Signed-off-by: Dan Hoeflinger <[email protected]>
Signed-off-by: Dan Hoeflinger <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces register pressure in the one-workgroup radix sort SYCL kernel by replacing a per-element cached counter-pointer array with a per-element cached bin-index array, reconstructing the counter address only when needed after the scan.
Changes:
- Replace
uint32_t* __counters[__block_size]caching withstd::uint16_t __bins[__block_size]caching and recompute the counter address in the post-scan step. - Apply
std::qualification touint*_ttypes within this kernel function for consistency.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace cached uint32_t* pointer array (__counters[__block_size]) with a uint16_t bin index array (__bins[__block_size]) in the one-workgroup radix sort kernel. This halves the register footprint of the cached data (32 vs 64 registers on 64-bit pointer platforms) by storing only the bin index and reconstructing the counter address in the post-scan loop.
The pointer array existed to avoid recomputing each element's bucket after the scan phase, but caching full 64-bit pointers is expensive in register-constrained kernels. Storing the bin index preserves the benefit (no recomputation from values) at half the register cost.
I've also taken the opportunity to add
std::touint*_twithin this function.Note: This is within margin of error from a performance perspective, but for some driver versions, this avoids generating kernels with register spill warnings in real use cases.