Strategy
Level 1: threadgroup reduction kernel
Level 2: final reduction
Once all threadgroup sums are inPartialOut, run a second pass. For small PartialOut arrays (< 256 elements), a single threadgroup is sufficient:
Full dispatch
Notes
- SIMD group size is hardware-fixed at 32. The threadgroup size should be a multiple of 32.
- This two-pass approach works for any
Nthat is a multiple ofthreads_per_tg. - For padded inputs (N not a power of 2), use
load_ifwith a bounds mask in the first pass.
See also
- SIMD Group Operations
- Memory Model
- Tiled GEMM — combines layout algebra with shared memory
