Keeping Output Positions in a Parallel Map
A parallel map can compute individual outputs independently while preserving their original positions at assembly.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace three conversions
Inputs at positions zero, one, and two finish in reverse order. Recording their indices allows assembling them in source order. Enumerated iteration provides those indices.
Decide the interface carefully
A consumer needing results as soon as ready may accept completion order with identity attached. A batch result may require the original order. See parallel scheduling and determinism.[1]
Associate each result with the input position that produced it
Inputs A, B and C may take three, one and two time units. With separate workers, B can complete before C, which completes before A. A parallel map promising input order should still return results A, B and C in their original positions. See stable ordering.
Work completes B,C,A
Store by index: slots 1,2,0
Read result slots 0,1,2 → A,B,C
Define order under failures
If one task fails, decide whether its position contains an explicit failure or the whole result fails. Test a late first task and an early failed middle task.