Experimental · v0.5.0-preview.5

Parallel execution

Run pure i64 tasks on bounded workers with ordered results.

parallel_map accepts a concrete pure i64-to-i64 task, up to 64 inputs and one to four workers. Results preserve input order and the lowest failing input determines the reported failure.

Workers use isolated runtime state. Host I/O, nested parallel work and contract execution are restricted. The supplied numeric example ran in all three engines.

parallel-foundation

examples/parallel-foundation/src/main.zbl · v0.5.0-preview.5 · interpreter, bytecode, native

ZBL source
task square(value: i64) gives i64:
    give value * value

inputs = [3, 1, 4, 2]
results = parallel_map("square", move_value(inputs), 2)
repeat result in results:
    show result

task test_parallel_values():
    values = parallel_map("square", [3, 1, 4, 2], 2)
    assert(values[0] == 9)
    assert(values[1] == 1)
    assert(values[2] == 16)
    assert(values[3] == 4)
Recorded output
9
1
16
4