IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/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. /max/get-started.md).

Mojo function

partition_work

def partition_work(task_id: Int, num_tasks: Int, work: Int, work_block_size: Int) -> IndexList[Int(2)]

Partitions work into blocks distributed across num_tasks tasks.

The work is first grouped into work_block_size-sized blocks for alignment and load/store efficiency, then the blocks are split between tasks as evenly as possible.

Args:

  • ​task_id (Int): The index of the task to compute the range for.
  • ​num_tasks (Int): The total number of tasks sharing the work.
  • ​work (Int): The total amount of work to partition.
  • ​work_block_size (Int): The block size used to align the partitioning.

Returns:

IndexList[Int(2)]: A pair (offset, length) describing this task's work range.

Was this page helpful?