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

once

def once[Emit: def() -> None & RegisterPassable & ImplicitlyCopyable, params: ContextParams, //](emit: Emit, ctx: Context[params])

Runs emit exactly once per (logical) output row.

  • Warp tier: only lane 0 runs emit.
  • Block tier: only thread 0 runs emit.
  • Tiled / serial tier: each thread owns its own output(s), so every thread that runs the body also runs emit.
  • Split-K tier: only thread 0 of the last-arriving block (per ctx._is_last_block, set by rowwise.reduce) runs emit.

emit is a value closure (its copy-captured state rides the value); this is an in-kernel thread predicate, not a launch boundary.

The body never observes lane_id() / thread_idx.x.

Parameters:

Args:

  • ​emit (Emit): Callback to run on the canonical writer.
  • ​ctx (Context[params]): The dispatch bundle passed to the body. The split-K branch reads ctx._is_last_block to gate emission.