rfc: 0015 scalar atomics and the Aji memory model accepted (revision 2) and integrated into the spec
The Aji RC11 profile (RC11 with NO-THIN-AIR; stronger than ISO C11/C++20) as normative axioms in spec 04 §20; DRF-SC; linear atomic<T> for AtomicScalar with atomic.new/atomic.take; ref<atomic<T>> operands; ordering tables incl. cmpxchg failure table and two results; effects [atomic] / [atomic, atomic.weak]; target atomic_widths and E4203; E4202; enumerator as oracle (observed ⊆ allowed, exact equality on the normative litmus corpus). Feature atomics stays reserved until P5-2a. Q-015 resolved; record/replay and Q-017 moved to Phase 8. RFC 0003 superseded. AIR bundle +1.9 %.
This commit is contained in:
1 parent
702d69b2c1
commit
2bbbd2135c
24 files changed
+927
-142
No files matched your search
@@ -1,59 +1,62 @@
|
||||
# Concurrency Litmus Tests
|
||||
|
||||
These are semantic tests for the interpreter, verifier and native backend. Syntax is illustrative.
|
||||
Litmus tests for the memory model of spec 04 §20–§30 (RFC 0015). They are semantic tests for the oracle, the interpreter and native backends.
|
||||
|
||||
## MP — message publication
|
||||
The tests do not define the model; spec 04 §20 does. They are its consequences, and the normative conformance corpus for the interpreter (spec 04 §20.5).
|
||||
|
||||
Writer:
|
||||
**Status:** draft corpus. The sets below were derived by hand from the axioms. P5-1a makes the corpus normative: every set is confirmed with the enumerator, the test files go into `tests/litmus/`, and the owner reviews the result. When the enumerator, the interpreter and a stated set disagree, the cause is diagnosed (spec 04 §20.5). A set is never edited to match a tool without a diagnosis.
|
||||
|
||||
```aji
|
||||
atomic.store(ref value, 42, relaxed);
|
||||
atomic.store(ref ready, true, release);
|
||||
```
|
||||
## Rules
|
||||
|
||||
Reader:
|
||||
- Each test states its **allowed** outcome set and its **forbidden** outcome set. A test never states a single expected result.
|
||||
- **Oracle:** the enumerator's allowed set MUST equal the stated allowed set.
|
||||
- **Interpreter:**
|
||||
- under exhaustive exploration, the observed outcomes MUST equal the allowed set, for these tests;
|
||||
- for any program, under any exploration, no outcome outside the allowed set may appear.
|
||||
- Unless stated otherwise:
|
||||
- locations start at 0;
|
||||
- tasks run in parallel under one scope;
|
||||
- `rlx`, `acq`, `rel`, `ar`, `sc` abbreviate the five orderings.
|
||||
|
||||
```aji
|
||||
if atomic.load(ref ready, acquire) {
|
||||
let v = atomic.load(ref value, relaxed);
|
||||
assert v == 42;
|
||||
}
|
||||
```
|
||||
## Notation
|
||||
|
||||
If the reader observes the release publication, observing the prior value store must be consistent with the happens-before relation.
|
||||
- `‖` separates tasks.
|
||||
- A tuple lists the reading registers in program order of the tasks, task by task.
|
||||
- `final x` is the value `atomic.take` reads after all joins.
|
||||
|
||||
## SB — store buffering
|
||||
## Corpus
|
||||
|
||||
Initially `x = 0`, `y = 0`, both atomic.
|
||||
| Test | Shape | Allowed | Forbidden |
|
||||
|---|---|---|---|
|
||||
| MP rel/acq | `x=1 rlx; y=1 rel` ‖ `r0=y acq; r1=x rlx` | (0,0) (0,1) (1,1) | (1,0) |
|
||||
| MP rlx | all `rlx` | all four | — |
|
||||
| MP fences | `x=1 rlx; fence rel; y=1 rlx` ‖ `r0=y rlx; fence acq; r1=x rlx` | (0,0) (0,1) (1,1) | (1,0) |
|
||||
| SB rlx | `x=1; r0=y` ‖ `y=1; r1=x`, all `rlx` | all four | — |
|
||||
| SB rel/acq | stores `rel`, loads `acq` | all four, including (0,0) | — |
|
||||
| SB sc | all `sc` | (0,1) (1,0) (1,1) | (0,0) |
|
||||
| SB fences | `rlx` accesses, `fence sc` between store and load on both sides | (0,1) (1,0) (1,1) | (0,0) |
|
||||
| LB rlx | `r0=x; y=1` ‖ `r1=y; x=1`, all `rlx` | (0,0) (0,1) (1,0) | (1,1), a consequence of NO-THIN-AIR |
|
||||
| IRIW acq | `x=1 rel` ‖ `y=1 rel` ‖ `r0=x acq; r1=y acq` ‖ `r2=y acq; r3=x acq` | includes (1,0,1,0) | — |
|
||||
| IRIW sc | all `sc` | every tuple except (1,0,1,0) | (1,0,1,0) |
|
||||
| CoRR | `x=1 rlx` ‖ `r0=x rlx; r1=x rlx` | (0,0) (0,1) (1,1) | (1,0) |
|
||||
| CoWW | `x=1 rlx; x=2 rlx`, final `x` | 2 | 1 |
|
||||
| relaxed counter | 2 tasks × 2 `add.wrap(x,1) rlx`, final `x` | 4 | 2, 3 |
|
||||
| CAS exclusion | `r0=cas.rlx.rlx(x,0→1)` ‖ `r1=cas.rlx.rlx(x,0→2)` (old values) | (0,1) (2,0) | (0,0) |
|
||||
| CAS failure acquire | `d=1 rlx; f=1 rel` ‖ `r0=cas.acq.acq(f,0→5); r1=d rlx` | (0,0) (0,1) (1,1) | (1,0) |
|
||||
| CAS failure relaxed | as above with `cas.acq.rlx` | (0,0) (0,1) (1,0) (1,1) | — |
|
||||
| release sequence | `d=1 rlx; f=1 rel` ‖ `add.wrap(f,2) rlx` ‖ `r0=f acq; r1=d rlx` | (0,0) (0,1) (1,1) (2,0) (2,1) (3,1) | (1,0) (3,0) |
|
||||
| channel handoff | `x=1 rlx; send(t)` ‖ `recv; r0=x rlx` | (1) | (0) |
|
||||
| mutex handoff | `lock; x=1 rlx; unlock` ‖ `lock; r0=x rlx; unlock`, in that lock order | (1) | (0) |
|
||||
| spawn/join | `x=1 rlx`; spawn ‖ child: `r0=x rlx; x=2 rlx`; after join `r1=x rlx` | (1,2) | (0,·) (·,1) |
|
||||
|
||||
Task A:
|
||||
## Rejected programs
|
||||
|
||||
```text
|
||||
store x=1 relaxed
|
||||
r1 = load y relaxed
|
||||
```
|
||||
These are verifier tests, not outcome tests.
|
||||
|
||||
Task B:
|
||||
|
||||
```text
|
||||
store y=1 relaxed
|
||||
r2 = load x relaxed
|
||||
```
|
||||
|
||||
Outcome `r1=0, r2=0` is permitted under relaxed ordering. The interpreter's weak-memory test mode must not incorrectly forbid it.
|
||||
|
||||
## Mutex handoff
|
||||
|
||||
Writes performed while holding a mutex before unlock must be visible to a later holder after successful lock acquisition.
|
||||
|
||||
## Channel handoff
|
||||
|
||||
Writes sequenced before successful `channel.send` are visible after the matching receive. Ownership of the moved message belongs only to the receiver after transfer.
|
||||
|
||||
## Spawn/join
|
||||
|
||||
Parent operations sequenced before spawn happen-before child start. Child operations happen-before successful join return.
|
||||
|
||||
## Invalid ordinary race
|
||||
|
||||
Two tasks writing the same ordinary `u64` through overlapping unsynchronized aliases must be rejected before execution.
|
||||
| Test | Program | Code |
|
||||
|---|---|---|
|
||||
| ordinary race | two tasks `store` the same ordinary `u64` through overlapping borrows | `E4101` |
|
||||
| mixing | ordinary `load` through `ref<atomic<u64>>` | `E4202` |
|
||||
| invalid ordering | `atomic.load.release` | `E4201` |
|
||||
| invalid failure ordering | `atomic.cmpxchg.relaxed.acquire` | `E4201` |
|
||||
| take while lent | `atomic.take` of a cell whose `ref` is lent to a live task | `E4101` |
|
||||
Reference in new issue
Block a user