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.