Skip to main content

Module parallel

Module parallel 

Source
Expand description

Deterministic parallelism for the kernel’s embarrassingly parallel stages.

The rule that makes parallelism admissible here at all: the answer must be bit-identical at any thread count. map_ordered guarantees it structurally: each item is computed independently from shared read-only input, results are collected in item order, and nothing about scheduling can reach the output. A stage that cannot meet that bar stays sequential.

The thread count comes from threads: the machine’s parallelism by default, overridable process-wide with set_threads, including down to one, which is also what tiny workloads collapse to on their own. Worker threads re-install the caller’s progress watch, so cancellation reaches into the workers.

Functions§

map_ordered
Map f over items on up to threads scoped threads, returning results in item order. f receives the item index and the item.
set_threads
Set the process-wide thread count for parallel stages. 0 restores the machine default. The answer never depends on this; only the wall clock does.
threads
The thread count parallel stages will use.