For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo function
sync_parallelize
def sync_parallelize[origins: OriginSet, //, func: def(Int) raises capturing thin -> None](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.
TODO: Currently exceptions raised by func will cause a trap rather than be propagated back to the caller.
Parameters:
- βorigins (
OriginSet): The capture origins. - βfunc (
def(Int) raises capturing thin -> None): The function to invoke.
Args:
- βnum_work_items (
Int): Number of parallel tasks. - βctx (
Optional[DeviceContext]): Optional CPU DeviceContext to execute the tasks on.
def sync_parallelize[FuncType: def(Int) -> 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.
Parameters:
- βFuncType (
def(Int) -> 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?
Thank you! We'll create more content like this.
Thank you for helping us improve!