Sizes and dispatch counts for the GPU depth sort. Pure, so it is tested
without a device.
The sort works in BLOCKS of BLOCK_ELEMENTS elements: one workgroup
of WORKGROUP_SIZE invocations handles one block, each invocation
ELEMENTS_PER_INVOCATION elements. The 16-bit key is sorted in
RADIX_PASSES passes of RADIX_BITS bits. A pass keeps one
RADIX-bin histogram per block, laid out digit-major
(hist[digit * blocks + block]), so one exclusive scan of that array gives
every block its stable write offset per digit. The scan runs in levels of SCAN_BLOCK_ELEMENTS
entries per workgroup; each level's workgroup totals form the next level,
until one workgroup holds the whole level.
Scratch buffers are sized for a CAPACITY (the largest node seen so far) and
reused; each sort then dispatches only the blocks and scan levels its own
element count needs.
Sizes and dispatch counts for the GPU depth sort. Pure, so it is tested without a device.
The sort works in BLOCKS of BLOCK_ELEMENTS elements: one workgroup of WORKGROUP_SIZE invocations handles one block, each invocation ELEMENTS_PER_INVOCATION elements. The 16-bit key is sorted in RADIX_PASSES passes of RADIX_BITS bits. A pass keeps one RADIX-bin histogram per block, laid out digit-major (
hist[digit * blocks + block]), so one exclusive scan of that array gives every block its stable write offset per digit. The scan runs in levels of SCAN_BLOCK_ELEMENTS entries per workgroup; each level's workgroup totals form the next level, until one workgroup holds the whole level.Scratch buffers are sized for a CAPACITY (the largest node seen so far) and reused; each sort then dispatches only the blocks and scan levels its own element count needs.