tools/litmus/enumerate.py was written by an independent author from spec 04 §20 alone, with the programs blind (outcome sets removed). check.py compares its allowed sets with tests/litmus/*.lit: 20/20 equal. 21 self-tests derived from the axioms. Both run in CI. The author's spec findings are Q-024.
Litmus corpus
The normative litmus corpus of the memory model (spec 04 §20, §20.5; docs/reference/concurrency-litmus.md). Each .lit file is one test: a small program and its outcome sets.
tools/litmus/enumerate.pyis the axiomatic oracle. It computes the allowed outcomes of a program from the axioms of spec 04 §20 alone.tools/litmus/check.pycompares the oracle's result with the stated sets. They MUST be equal.- From Phase 5 on, the interpreter's exhaustive exploration of each test MUST give exactly the allowed set.
File format
Line-based. # starts a comment. Blank lines are ignored.
name: MP+rel+acq
init: x=0 y=0 # every location used, with its initial value
T0: # a task; its operations follow, one per line, indented
store x 1 rlx
store y 1 rel
T1:
r0 = load y acq
r1 = load x rlx
observe: T1.r0 T1.r1 # the outcome tuple, in this order
allowed: (a,b) (c,d) … # every allowed outcome: the complete set
forbidden: (e,f) … # outcomes the test exists to exclude (disjoint from allowed; documentation)
Tasks
Tn:declares a task that starts when the program starts.Tn (spawned):declares a task that starts only when another task executesspawn Tn.
All tasks run concurrently.
Operations
LOC and CH/M are names, V is a non-negative integer, ORD is rlx, acq, rel, ar (acq_rel) or sc (seq_cst), and rN names a register of the task.
| Operation | Meaning (spec 04) |
|---|---|
store LOC V ORD |
atomic store |
rN = load LOC ORD |
atomic load |
rN = rmw OP LOC V ORD |
atomic read-modify-write, OP ∈ xchg add sub and or xor (add/sub modular); rN gets the value read |
rN = cas LOC EXP NEW SUCC FAIL |
strong compare-exchange; rN gets the value read; it writes NEW with SUCC iff the value read equals EXP, otherwise it is a read with FAIL |
fence ORD |
fence |
send CH / recv CH |
send a message on channel CH / receive one (a recv takes exactly one message sent on CH; every message is received at most once) |
lock M / unlock M |
mutex operations (critical sections on M do not overlap) |
spawn Tn / join Tn |
start a spawned task / wait for its completion |
There is no control flow, so every task executes all of its operations. Programs in the corpus are such that every recv and join can complete.
Observations
Tn.rKis a register value.final LOCis the value of the last write toLOCin modification order.