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 function

pjoin

def pjoin[State: ReduceOp, params: ContextParams, //](mut state: State, mut ctx: Context[params])

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.

Three tiers, picked from params:

  • Cooperative (emit_tile_width == 1, !is_splitk_tier): call state.pjoin(SerialReducer()). No cross-worker combine (one worker per output), but monoids may carry per-state finalization in pjoin (e.g. ReduceSum horizontally reducing its SIMD accumulator into the scalar acc field).
  • Tiled (emit_tile_width > 1): per-output accumulators already final; each lane is a separate output; skip the cross-participant join.
  • Split-axis (is_splitk_tier): write this worker's partial to its slot in ctx._partials_base, atomically increment counters_base[row_idx], and β€” only the worker whose increment brings the counter to blocks_per_row β€” gather all partials, join them into self.state, and set ctx._is_last_block so rowwise.once gates emission.

Parameters:

  • ​State (ReduceOp): The monoid type being joined.
  • ​params (ContextParams): Comptime dispatch parameters.

Args:

  • ​state (State): The body's monoid accumulator. On return, holds the finalized value.
  • ​ctx (Context[params]): The dispatch bundle. Mutated in the split-axis tier so rowwise.once knows which worker emits.