Repository navigation
Conversation
…e if it cannot fit Each subgroup's histogram is staged in the tile, so KEYS_PER_THREAD must be at least RADIX / subgroup width. The floor assumed 32 lanes whatever the adapter reported, so with 8-lane subgroups (llvmpipe; Intel reports 8 to 32) the default 15 keys per thread sorted wrongly (it needs 32). Now the floor uses subgroupMinSize, the default is raised to it (16-lane: 16), and where the narrowest subgroups' tile cannot fit workgroup memory OneSweep emulates 32-lane subgroups instead. SUBGROUP_MIN_SIZE (which sizes the scan memory) is now the width that will run: 32 when emulated. Test: the choice for 4- to 64-lane adapters, which fails without the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015kfNC6id65zEHzuAAH4jtJ
This branch has not been deployed
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.
OneSweep sorted wrongly on adapters whose subgroups can be 8 lanes wide (llvmpipe reports 8; Intel GPUs report 8 to 32), and so did everything built on it (SuffixArray).
Why.
onesweep_passstages each subgroup's digit histogram (RADIX = 256 counts) in the tile, so the tile (KEYS_PER_THREAD × 256 keys) must hold (256 / subgroup width) × 256 entries: KEYS_PER_THREAD ≥ 256 / width. The floor took the width asmax(32, subgroupMinSize), so it assumed 32 lanes (8 keys per thread) whatever the adapter reported. With 8-lane subgroups the pass needs 32 keys per thread and got the default 15.Fix.
subgroupMinSize), and the default keys per thread is raised to it (16-lane: 16).SUBGROUP_MIN_SIZE, which sizes the scan's workgroup memory, is now the width that will run: 32 when emulated (it took the adapter's value even when emulating, or RADIX when unknown).Devices whose subgroups are 32 lanes or wider (NVIDIA, Apple, AMD) are unchanged: same keys per thread, hardware subgroups.
Test. A regression test checks the choice for adapters reporting 4- to 64-lane subgroups (keys per thread, hardware or emulated, the scan width), without running a sort, so it runs on any device. It fails without the fix.
Note: on llvmpipe, emulated subgroups are very slow (they spin-wait between invocations, which a CPU runs one at a time), so OneSweep there is now correct but impractically slow, rather than wrong.
Generated by Claude Code