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

sync_parallelize

def sync_parallelize[FuncType: def(Int) raises -> None](func: FuncType, num_work_items: Int, ctx: Optional[DeviceContext] = None)

Executes func(0) ... func(num_work_items-1) as parallel sub-tasks, and returns when all are complete.

Non-raising closures still bind this signature. Exceptions raised by func abort rather than propagating to the caller.

Parameters:

  • ​FuncType (def(Int) raises -> None): The body function type.

Args:

  • ​func (FuncType): The closure carrying the captured state of the body function.
  • ​num_work_items (Int): Number of parallel tasks.
  • ​ctx (Optional[DeviceContext]): The CPU DeviceContext to enqueue the work on.

Was this page helpful?