subgroupMin
Performs a reduction over all active invocations in the current subgroup and returns the minimum of e to every active lane.
Core Advantages
Leverages hardware subgroup primitives to compute a minimum in one step, avoiding shared memory and barriers for lower latency and higher throughput.
Common Uses
Fast per‑tile/per‑block minimum depth or error for early‑out and thresholding
Windowed minimum in image/voxel processing (e.g., morphological erosion, local contrast prepass)
A building block in multi‑stage/global min reductions together with workgroup‑level steps
How to adjust
The function itself has no tunables. Influence the result by changing e and by controlling which lanes are active (e.g., call it inside a conditional). If only one writer is desired, pick a representative with invocationSubgroupIndex.equal(0) or subgroupElect() before writing.
Code Examples
1// Per-thread scalar input: compute subgroup minimum
2const idx = globalId.x;
3const v = inputBuffer.element( idx );
4
5// Subgroup reduction: all active lanes receive the same minimum
6const sMin = subgroupMin( v );
7
8// Write back: produces a "one constant per subgroup" tile pattern
9outMinBuffer.element( idx ).assign( sMin );