Filtering module#
Stream compaction shrinks a per-sample array down to just the samples
that are still active, so later kernels can launch over a smaller N
(see Foundations for the full walkthrough). The
filtering module is the machinery that implements it: a parallel
prefix-scan turns each active sample’s flag into a scatter offset — its
new, packed position in the output array — and a scatter step writes each
active sample there.
Worked example, 8 samples: flags [1,0,1,1,0,0,1,0] (1 = keep, at indices
0, 2, 3, 6). The exclusive prefix scan over those flags — each position’s
running count of 1s before it — is [0,1,1,2,3,3,3,4]. Reading
that scan only at the kept positions gives each kept sample’s new, packed
index: index 0 → new index 0, index 2 → new index 1, index 3 → new index 2,
index 6 → new index 3. The scatter step then writes each kept sample to its
new index, producing a packed 4-element output: the original samples 0, 2,
3, and 6, in order, with everything else dropped.
Headers#
Header |
Contents |
|---|---|
|
|
|
The |
|
|
|
Active-set compaction over raw buffers: |
|
The occasional physical reorder behind the map: |
|
Low-level prefix-scan and scatter kernels (internal). |
The rest of the module, one page each:
Scan and compaction – the prefix scan,
FilteringSlice, and the active-set index map.Reorder and grouping – the occasional physical reorder, and grouping samples by branch.
Run until done – running every sample to completion in one call.
See also
Filtering API — full Scanner / FilteringSlice API reference.