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

CPU row-wise reduction scaffolder.

Mirrors the body-facing surface of algorithm.gpu.rowwise so the same body[params: ContextParams](row_coords, mut ctx) works for both targets. Reuses GPU's ContextParams / Context types verbatim; the GPU-only runtime fields (split-K pointers and counters) get sentinels and are never read.

Tier mapping CPU ↔ GPU:

  • Inner-axis cooperative (emit_tile_width == 1, axis == rank - 1): one worker per row, vectorize the row at simd_width. Mirrors the GPU block tier with BLOCK_SIZE = 1.
  • Non-inner-axis tiled (emit_tile_width > 1, supports_tiled): one worker per slice; tile the innermost-non-axis dim with W = simd_width independent accumulators. Mirrors the GPU tiled tier.
  • Non-inner-axis cooperative (emit_tile_width == 1, !supports_tiled): one worker per output, scalar walk over the reduce axis. Mirrors the GPU cooperative-non-inner tier.

pjoin is a no-op on CPU and once runs unconditionally: one worker owns each output, so the monoid state is already final after reduce.

Structs​

  • ​SerialReducer: Single-participant Reducer for CPU's serial / cooperative tier. Nothing to combine across (one worker per output), so sum/max/min/generic are identity. Routing cpu_rowwise.pjoin through it rather than skipping the call still invokes the monoid's own pjoin body, which may do per-state finalization (e.g. ReduceSum horizontally reducing its SIMD-wide accumulator into the scalar acc field exposed to bodies).

Functions​

  • ​launch: Top-level CPU scaffolder. Picks the tier from axis and supports_tiled, parallelizes over outputs (or output tiles), and invokes the body once per output (or tile).
  • ​once: CPU: runs emit unconditionally on the cooperative / tiled tiers (one worker per output), or gated on ctx._is_last_block on the split-axis tier (only the last-arriving worker emits).
  • ​pjoin: CPU: drives the monoid's pjoin body via SerialReducer in the cooperative tier, or merges the cross-worker partials buffer in the split-axis tier.
  • ​reduce: Drives tile_fn over the reduce axis, CPU-side, with no monoid state β€” pure per-tile iteration for map/emit terminals (see the state-carrying overload below for reduce phases).