Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit8d45df8664

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

SlotAccessContents
keysreadPer-item sort key, written by whatever produced the keys.
indicesreadThis pass's input permutation.
histread_writeDigit populations, digit-major.
sortread[0] = item count, [1] = block count, [2] = digit shift.

Dispatch one workgroup of 256 per 256 items.