Sharing Read-Only Data Between Workers

Workers can use a common immutable input without coordinating write access to that input during their calculations.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace an independent lookup
  2. Define publication of new data
  3. Publish a fully prepared object before starting readers
  4. Check whether referenced objects remain mutable

Trace an independent lookup

Two workers can read the same table of numeric rates while computing separate reports. If the table changes during one report, identical inputs can produce conflicting classifications. See configuration snapshots.

Define publication of new data

A new version can be prepared separately and handed to later jobs. Readers keep one chosen snapshot when required. Immutable data updates describe that contract.[1]

Publish a fully prepared object before starting readers

Several workers can consult one immutable table. If one worker observes it before construction finishes, the read-only promise for later execution does not make initialization safe. Use a synchronization mechanism that publishes complete data. See immutable snapshots.

Build table → publish with defined synchronization
Workers read shared rows
Updates, if allowed, publish another complete version under the contract

Check whether referenced objects remain mutable

An immutable outer reference can still reach objects edited elsewhere. Decide which parts the workers may observe. Test a read during startup and one during replacement.

References

  1. OpenMP Architecture Review Board, OpenMP API Specifications ↩