PRIMITIVES signature
The PRIMITIVES signature provides a few “primitive”
operations for parallel evaluation.
val par : (unit → 'a) * (unit → 'b) → ('a * 'b)
val parallelFor : int * int → (int → unit) → unit
val par :
(unit → 'a) * (unit → 'b) → ('a * 'b)
par (f, g) evaluates $f$ and $g$ in parallel. It
is logically equivalent to $(f(), g())$.
val parallelFor :
int * int → (int → unit) → unit
parallelFor (lo, hi) f applies $f$ to every index in the
half-open range $[lo, hi)$, in parallel, and returns once all of them have
finished. It is run for its effects; $f$ returns nothing. The iterations must
be independent: they may run in any order and at the same time, so $f$ must
not rely on one iteration having happened before another, and no two of them
may write to the same place. Prefer
tabulate wherever it
fits, which builds a sequence from a function of the index without any
mutation. No lab in this course needs parallelFor.