Builtin Library
- ..
- README.md1.2 KB
- bindings.yaml638 B
- shader.wgsl1.8 KB
README.md
radix_hist
Stage 1 of one pass of the shared GPU radix sort. One workgroup of 256 per 256 items, once per radix pass.
Each thread reads its item's sort key through the pass's input permutation,
extracts the 8-bit digit this pass sorts on, and counts it in workgroup memory.
The workgroup then writes its 256 digit populations to hist, laid out
digit-major: entry digit * block_count + block.
Digit-major is what makes the sort stable. A plain exclusive scan over the whole
array — radix_scan — then yields, for every (digit, block) pair, the first
slot that pair's items occupy.
The block size, the workgroup size and the radix are all 256, so each thread writes exactly one histogram entry and every entry is written on every pass. The histogram therefore needs no clearing between passes.
Bindings
| Slot | Access | Contents |
|---|---|---|
keys | read | Per-item sort key, written by whatever produced the keys. |
indices | read | This pass's input permutation. |
hist | read_write | Digit populations, digit-major. |
sort | read | [0] = item count, [1] = block count, [2] = digit shift. |
Dispatch one workgroup of 256 per 256 items.