IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo module

rowwise

GPU row-wise reduction scaffolder.

The author writes one body[ctx: Context](row_coords) callable, taking a comptime Context (the dispatch tier) and the row's coords. The body composes a few helpers from this module:

  • reduce β€” tier-aware iteration over the reduce axis, then a cross-thread join of the body's accumulators. Takes a per-tile callback tile_fn[ws, _r] (which closes over input closures + local monoid states) and a variadic of ReduceOp states to pjoin after the loop. Zero states runs iteration only β€” used by 2-pass algorithms' second pass.
  • once β€” run a closure exactly once per (logical) output row. Picks the canonical writer thread; the body never sees lane_id() / thread_idx.x.
  • simd β€” width-polymorphic SIMD constructor from a per-lane callback; degenerates cleanly at w = 1.

launch is the top-level entry point. It picks the tier from shape and axis, then instantiates the matching kernel template.

No GPU primitives leak into the body: it sees ctx, lambdas, and the helpers above.

Structs​

  • ​BlockReducer: Reduces a scalar across BLOCK_SIZE threads in a block. Broadcasts the result to every thread.
  • ​WarpReducer: Reduces a scalar across all lanes in a warp. Broadcasts the result to every lane.

Functions​

  • ​launch: Top-level scaffolder. Picks the tier from shape + axis, instantiates the matching kernel, and launches.
  • ​once: Runs emit exactly once per (logical) output row.
  • ​pjoin: Cross-thread join for a single monoid state, tier-appropriately.
  • ​reduce: Drives the tier-aware iteration over the reduce axis, with no monoid state β€” pure per-tile iteration for map/emit terminals (see the state-carrying overload below for reduce phases).