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.

GPU: picks the canonical writer (lane 0 / thread 0 / last-block thread 0, depending on tier). CPU: every worker emits its own outputs (one worker per row).

emit is a value closure (its copy-captured state rides the value); once is an in-kernel thread predicate β€” not a launch boundary β€” so it is invoked directly under the canonical-writer guard.

Parameters:

Args:

  • ​emit (Emit): Callback to run on the canonical writer.
  • ​ctx (Context[params]): The dispatch bundle.