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
parallelize
def parallelize[FuncType: def(Int) -> None](func: FuncType, num_work_items: Int, ctx: Optional[DeviceContextBase] = None)
Executes func(0) ... func(num_work_items-1) as sub-tasks in parallel, 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[DeviceContextBase]): Optional CPU DeviceContext to execute the work on.
def parallelize[FuncType: def(Int) -> None](func: FuncType, num_work_items: Int, num_workers: Int, ctx: Optional[DeviceContextBase] = None)
Executes func(0) ... func(num_work_items-1) as sub-tasks in parallel, 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. - num_workers (
Int): The number of workers to use for execution. - ctx (
Optional[DeviceContextBase]): Optional CPU DeviceContext to execute the work on.