SLIDE 1 Bridging the Gap between Programming Languages and Hardware Weak Memory Models
Anton Podkopaev Ori Lahav Viktor Vafeiadis
SLIDE 2 1
Bridging the Gap between PL and Hardware Weak MMs Programming Language Hardware Compiler Correct Compiler P Syntax PL P PL compile P
HW PL HW is Memory Model
SLIDE 3 1
Bridging the Gap between PL and Hardware Weak MMs Programming Language Hardware Compiler Correct Compiler P Syntax PL P PL compile P
HW PL HW is Memory Model
SLIDE 4 1
Bridging the Gap between PL and Hardware Weak MMs Programming Language Hardware Compiler Correct Compiler P Syntax PL P PL compile P
HW PL HW is Memory Model
SLIDE 5 1
Bridging the Gap between PL and Hardware Weak MMs Programming Language Hardware Compiler Correct Compiler P Syntax PL P PL compile P
HW PL HW is Memory Model
SLIDE 6 1
Bridging the Gap between PL and Hardware Weak MMs Programming Language Hardware Compiler Correct Compiler ∀P ∈ Syntax(PL). PPL compile(P)HW
PL HW is Memory Model
SLIDE 7
1
Bridging the Gap between PL and Hardware Weak MMs Programming Language Hardware Compiler Correct Compiler ∀P ∈ Syntax(PL). PPL compile(P)HW −{PL,HW} is Memory Model
SLIDE 8
1
Bridging the Gap between PL and Hardware Weak MMs Programming Language Hardware Compiler Correct Compiler ∀P ∈ Syntax(PL). PPL compile(P)HW −{PL,HW} is Memory Model
SLIDE 9
2 Strong (SC) MM disallows a b 1
Memory ; [x] ← 0 [y] ← 0 Values ; a = ⊥ b = ⊥ a := [x]; [y] := 1; b := [y]; [x] := b; ARM and POWER weak MMs allow a b 1!
SLIDE 10
2 Strong (SC) MM disallows a b 1
Memory ; [x] ← 0 [y] ← 0 Values ; a = ⊥ b = ⊥ a := [x]; [y] := 1; b := [y]; [x] := b; ARM and POWER weak MMs allow a b 1!
SLIDE 11
2 Strong (SC) MM disallows a b 1
Memory ; [x] ← 0 [y] ← 0 Values ; a = 0 b = ⊥ a := [x]; [y] := 1; b := [y]; [x] := b; ARM and POWER weak MMs allow a b 1!
SLIDE 12
2 Strong (SC) MM disallows a b 1
Memory ; [x] ← 0 [y] ← 1 Values ; a = 0 b = ⊥ a := [x]; [y] := 1; b := [y]; [x] := b; ARM and POWER weak MMs allow a b 1!
SLIDE 13
2 Strong (SC) MM disallows a b 1
Memory ; [x] ← 0 [y] ← 1 Values ; a = 0 b = 1 a := [x]; [y] := 1; b := [y]; [x] := b; ARM and POWER weak MMs allow a b 1!
SLIDE 14
2 Strong (SC) MM disallows a b 1
Memory ; [x] ← 1 [y] ← 1 Values ; a = 0 b = 1 a := [x]; [y] := 1; b := [y]; [x] := b; ARM and POWER weak MMs allow a b 1!
SLIDE 15
2 Strong (SC) MM disallows a b 1
Memory ; [x] ← 1 [y] ← 1 Values ; a = 0 b = 1 a := [x]; [y] := 1; b := [y]; [x] := b; ARM and POWER weak MMs allow a b 1!
SLIDE 16
2 Strong (SC) MM disallows a = b = 1
Memory ; [x] ← 1 [y] ← 1 Values ; a = 0 b = 1 a := [x]; [y] := 1; b := [y]; [x] := b; ARM and POWER weak MMs allow a b 1!
SLIDE 17
2 Strong (SC) MM disallows a = b = 1
Memory ; [x] ← 1 [y] ← 1 Values ; a = 0 b = 1 a := [x]; [y] := 1; b := [y]; [x] := b; ARM and POWER weak MMs allow a = b = 1!
SLIDE 18 3
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 19 3
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 20 3
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 21 3
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 22 3
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 23 3
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 24 3
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 25 3
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 26 3
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 27 4 (Declarative) Executions in IMM
a := [x]; [y] := 1; b := [y]; [x] := b;
Rx0 Wy1 Ry0 Wx0
fr
,
Rx0 Wy1 Ry1 Wx1
data fr rf
,
Rx1 Wy1 Ry1 Wx1
data rf
Rx1 Wy1 Ry1 Wx1
po data rf
Axioms:
rf is acyclic …
SLIDE 28 4 (Declarative) Executions in IMM
a := [x]; [y] := 1; b := [y]; [x] := b;
Rx0 Wy1 Ry0 Wx0
fr
,
Rx0 Wy1 Ry1 Wx1
data fr rf
,
Rx1 Wy1 Ry1 Wx1
data rf
Rx1 Wy1 Ry1 Wx1
po data rf
Axioms:
rf is acyclic …
SLIDE 29 4 (Declarative) Executions in IMM
a := [x]; [y] := 1; b := [y]; [x] := b;
Rx0 Wy1 Ry0 Wx0
fr
,
Rx0 Wy1 Ry1 Wx1
data fr rf
,
Rx1 Wy1 Ry1 Wx1
data rf
Rx1 Wy1 Ry1 Wx1
po data rf
Axioms:
rf is acyclic …
SLIDE 30 4 (Declarative) Executions in IMM
a := [x]; [y] := 1; b := [y]; [x] := b;
Rx0 Wy1 Ry0 Wx0
fr
,
Rx0 Wy1 Ry1 Wx1
data fr rf
,
Rx1 Wy1 Ry1 Wx1
data rf
Rx1 Wy1 Ry1 Wx1
po data rf
Axioms:
…
SLIDE 31 5
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 32 5
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
(deps ∪ rf is acyclic)
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 33 5
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
(deps ∪ rf is acyclic)
- 3. Uses C11-style coherence
(hb; eco? is irreflexive)
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 34 5
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
(deps ∪ rf is acyclic)
- 3. Uses C11-style coherence
(hb; eco? is irreflexive)
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 35 5
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 36 5
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 37 5
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 38
6 (Operational) Execution in Promise
Promised a := [x]; [y] := 1; b := [y]; [x] := b; Requires certification Values ; a = ⊥ b = ⊥
SLIDE 39
6 (Operational) Execution in Promise
Promised a := [x]; [y] := 1; b := [y]; [x] := b; Requires certification Values ; a = ⊥ b = ⊥
SLIDE 40
6 (Operational) Execution in Promise
Promised a := [x]; [y] := 1; b := [y]; [x] := b; Requires certification Values ; a = ⊥ b = ⊥
SLIDE 41
6 (Operational) Execution in Promise
Promised a := [x]; [y] := 1; b := [y]; [x] := b; Requires certification Values ; a = ⊥ b = ⊥
SLIDE 42
6 (Operational) Execution in Promise
Promised a := [x]; [y] := 1; b := [y]; [x] := b; Requires certification Values ; a = ⊥ b = 1
SLIDE 43
6 (Operational) Execution in Promise
Promised a := [x]; [y] := 1; b := [y]; [x] := b; Requires certification Values ; a = ⊥ b = 1
SLIDE 44
6 (Operational) Execution in Promise
Promised a := [x]; [y] := 1; b := [y]; [x] := b; Requires certification Values ; a = 1 b = 1
SLIDE 45
6 (Operational) Execution in Promise
Promised a := [x]; [y] := 1; b := [y]; [x] := b; Requires certification Values ; a = 1 b = 1
SLIDE 46 7
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 47
8
How to prove correctness of compilation? Simulation How to simulate graphs? Traverse in proper order!
SLIDE 48
8
How to prove correctness of compilation? Simulation How to simulate graphs? Traverse in proper order!
SLIDE 49
8
How to prove correctness of compilation? Simulation How to simulate graphs? Traverse in proper order!
SLIDE 50
8
How to prove correctness of compilation? Simulation How to simulate graphs? Traverse in proper order!
SLIDE 51
9 Traversal of IMM execution
a := [x]; [y] := 1; b := [y]; [x] := b; Promised Promised
Rx1 Wy1 Ry1 Wx1
Covered Issued
SLIDE 52 10
Promise → IMM compilation correctness proof
- 1. Operational semantics of IMM’s traversal:
G ⊢ ⟨C, I⟩ → ⟨C ′, I ′⟩
- 2. Completeness of traversal:
G P IMM G initTraverse G Events G Writes
initTraverse initPromise
simulated by
traverse traverse promise promise
simulated by simulated by
Promise’s certification Promise’s certification via traversal of certification graph
SLIDE 53 10
Promise → IMM compilation correctness proof
- 1. Operational semantics of IMM’s traversal:
G ⊢ ⟨C, I⟩ → ⟨C ′, I ′⟩
- 2. Completeness of traversal:
∀G ∈ PIMM. G ⊢ initTraverse →∗ ⟨G.Events, G.Writes⟩
initTraverse initPromise
simulated by
traverse traverse promise promise
simulated by simulated by
Promise’s certification Promise’s certification via traversal of certification graph
SLIDE 54 10
Promise → IMM compilation correctness proof
- 1. Operational semantics of IMM’s traversal:
G ⊢ ⟨C, I⟩ → ⟨C ′, I ′⟩
- 2. Completeness of traversal:
∀G ∈ PIMM. G ⊢ initTraverse →∗ ⟨G.Events, G.Writes⟩
initTraverse initPromise
simulated by
traverse traverse′ promise ∃ promise′
simulated by simulated by
Promise’s certification Promise’s certification via traversal of certification graph
SLIDE 55 10
Promise → IMM compilation correctness proof
- 1. Operational semantics of IMM’s traversal:
G ⊢ ⟨C, I⟩ → ⟨C ′, I ′⟩
- 2. Completeness of traversal:
∀G ∈ PIMM. G ⊢ initTraverse →∗ ⟨G.Events, G.Writes⟩
initTraverse initPromise
simulated by
traverse traverse′ promise ∃ promise′
simulated by simulated by
Promise’s certification Promise’s certification via traversal of certification graph
SLIDE 56 10
Promise → IMM compilation correctness proof
- 1. Operational semantics of IMM’s traversal:
G ⊢ ⟨C, I⟩ → ⟨C ′, I ′⟩
- 2. Completeness of traversal:
∀G ∈ PIMM. G ⊢ initTraverse →∗ ⟨G.Events, G.Writes⟩
initTraverse initPromise
simulated by
traverse traverse′ promise ∃ promise′
simulated by simulated by
Promise’s certification Promise’s certification via traversal of certification graph
SLIDE 57 10
Promise → IMM compilation correctness proof
- 1. Operational semantics of IMM’s traversal:
G ⊢ ⟨C, I⟩ → ⟨C ′, I ′⟩
- 2. Completeness of traversal:
∀G ∈ PIMM. G ⊢ initTraverse →∗ ⟨G.Events, G.Writes⟩
initTraverse initPromise
simulated by
traverse traverse′ promise ∃ promise′
simulated by simulated by
Promise’s certification Promise’s certification via traversal of certification graph
SLIDE 58
11 Traversal of IMM execution
a := [x]; [y] := 1; b := [y]; [x] := b; Promised Promised
Rx1 Wy1 Ry1 Wx1
Covered Issued
SLIDE 59
11 Traversal of IMM execution
a := [x]; [y] := 1; b := [y]; [x] := b; Promised Promised
Rx1 Wy1 Ry1 Wx1
Covered Issued
SLIDE 60
11 Traversal of IMM execution
a := [x]; [y] := 1; b := [y]; [x] := b; Promised Promised
Rx1 Wy1 Ry1 Wx1
Covered Issued
SLIDE 61
11 Traversal of IMM execution
a := [x]; [y] := 1; b := [y]; [x] := b; Promised Promised
Rx1 Wy1 Ry1 Wx1
Covered Issued
SLIDE 62
11 Traversal of IMM execution
a := [x]; [y] := 1; b := [y]; [x] := b; Promised Promised
Rx1 Wy1 Ry1 Wx1
Covered Issued
SLIDE 63
11 Traversal of IMM execution
a := [x]; [y] := 1; b := [y]; [x] := b; Promised Promised
Rx1 Wy1 Ry1 Wx1
Covered Issued
SLIDE 64
11 Traversal of IMM execution
a := [x]; [y] := 1; b := [y]; [x] := b; Promised Promised
Rx1 Wy1 Ry1 Wx1
Covered Issued
SLIDE 65 12
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 66 12
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 67 12
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 68 12
Bridging the Gap between PL and Hardware Weak MMs Promise (R)C11 WeakestMO
[Chakraborty and Vafeiadis, 2019]
IMM x86-TSO ARMv7 ARMv8.3 RISC-V POWER
CompCert Weak MMs
- 1. Declarative
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
- 1. Declarative
- 2. Preserves syntactic dependencies
deps rf is acyclic
- 3. Uses C11-style coherence
hb eco is irreflexive
w/o mutually recursive relations
plv.mpi-sws.org/imm/ Thank you!
SLIDE 69 13
Links I
Chakraborty, S. and Vafeiadis, V. (2019). Grounding thin-air reads with event structures. In POPL 2019. ACM. Kang, J., Hur, C.-K., Lahav, O., Vafeiadis, V., and Dreyer, D. (2017). A promising semantics for relaxed-memory concurrency. In POPL 2017. ACM.
SLIDE 70
14
Backup slides
SLIDE 71 15
IMM definition
- Def. G is called IMM-consistent if the following hold:
- codom(G.rf) = G.R.
- For every location ℓ ∈ Loc, G.co totally orders G.Wℓ.
- G.rmw ∩ (G.fre ; G.coe) = ∅.
- G.hb ; G.eco? is irreflexive.
- G.ar is acyclic.
ar ≜ rfe ∪ bob ∪ ppo ∪ detour ∪ psc ∪ [Wstrong] ; po ; [W] bob ≜ po ; [Wrel] ∪ [Racq] ; po ∪ po ; [F] ∪ [F] ; po ∪ [Wrel] ; po|loc ; [W] ppo ≜ [R] ; (deps ∪ rfi)+ ; [W] deps ≜ data ∪ ctrl ∪ addr ; po? ∪ casdep ∪ [Rex] ; po
SLIDE 72 16
Traversal definition
a ∈ Next(G, C) ∩ Coverable(G, C, I) G ⊢ ⟨C, I⟩ → ⟨C ∪ {a}, I⟩ w ∈ Issuable(G, C, I) \ I G ⊢ ⟨C, I⟩ → ⟨C, I ∪ {w}⟩
- Def. w ∈ Issuable(G, C, I) iff w ∈ G.W and the following hold:
- dom(([G.Wrel] ; G.po|G.loc ∪ [G.F] ; G.po) ; [w]) ⊆ C
- dom((G.detour ∪ G.rfe) ; G.ppo ; [w]) ⊆ I
- dom((G.detour ∪ G.rfe) ; [G.Racq] ; G.po ; [w]) ⊆ I
- dom([G.Wstrong] ; G.po ; [w]) ⊆ I
- Def. e ∈ Coverable(G, C, I) iff e ∈ G.E, dom(G.po ; [e]) ⊆ C and either
(i) e ∈ G.W ∩ I; (ii) e ∈ G.R and dom(G.rf ; [e]) ⊆ I; (iii) e ∈ G.Fsc;
- r (iv) e ∈ G.Fsc and dom(G.sc ; [e]) ⊆ C.
SLIDE 73
17
Mistake in Kang et al.17’s compilation to POWER correctness proof
Rrlxz1 Fsc Wrlxx1 Wrlxx2 Fsc Wrlxy1 Rrlxy1 Wrlxz1
rf co rf Consistent in Strong-POWER. Not consistent in the promise-free declarative model of [Kang et al., 2017].
SLIDE 74 18
Promise → IMM compilation of RMWs
a := [y]rlx / / 1 [z]rlx := a b := [z]rlx / / 1 c := FADDrlx,rel
strong (x, 1) /
/ 0 [y]rlx := c + 1
Rrlxy1 Wrlxz1 Rrlxz1 Rrlxx0 Wrel
strongx1
Wrlxy1
data rmw data bob rfe