Robustness against Relaxed Memory Models Memory Models Roland - - PowerPoint PPT Presentation

robustness against relaxed memory models
SMART_READER_LITE
LIVE PREVIEW

Robustness against Relaxed Memory Models Memory Models Roland - - PowerPoint PPT Presentation

Robustness against Relaxed Memory Models Memory Models Roland Meyer Technische Universit at Kaiserslautern Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 1 / 27 Concurrent Programs with Shared Memory


slide-1
SLIDE 1

Robustness against Relaxed Memory Models

Memory Models Roland Meyer

Technische Universit¨ at Kaiserslautern

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 1 / 27

slide-2
SLIDE 2

Concurrent Programs with Shared Memory

Finite number of shared variables {x, y, x1, . . .} Finite data domain {d, d0, d1, . . .} Finite number of finite-control threads T1, . . . , Tn with operations: w(x, d), r(x, d)

x = y = 0

Thread 1

a : x = 1 b : if (y == 0){ c :

  • crit. sect. 1

d : }

Thread 2

p : y = 1 q : if (x == 0){ r :

  • crit. sect. 2

s : }

Dekker’s mutual exclusion protocol.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 2 / 27

slide-3
SLIDE 3

Sequential Consistency (SC) Semantics [Lamport 1979]

Threads directly write to and read from memory Classical interleaving semantics

◮ Computations of different threads are shuffled ◮ Program order is preserved for each thread

x = y = 0

Thread 1

a : x = 1 b : if (y == 0){ c :

  • crit. sect. 1

d : }

Thread 2

p : y = 1 q : if (x == 0){ r :

  • crit. sect. 2

s : }

Thread 1 pc = a Thread 2 pc = p Mem

x y

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 3 / 27

slide-4
SLIDE 4

Sequential Consistency (SC) Semantics [Lamport 1979]

Threads directly write to and read from memory Classical interleaving semantics

◮ Computations of different threads are shuffled ◮ Program order is preserved for each thread

x = y = 0

Thread 1

a : x = 1 b : if (y == 0){ c :

  • crit. sect. 1

d : }

Thread 2

p : y = 1 q : if (x == 0){ r :

  • crit. sect. 2

s : }

Thread 1 pc = b Thread 2 pc = p Mem

x 1 y

w(x, 1)

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 3 / 27

slide-5
SLIDE 5

Sequential Consistency (SC) Semantics [Lamport 1979]

Threads directly write to and read from memory Classical interleaving semantics

◮ Computations of different threads are shuffled ◮ Program order is preserved for each thread

x = y = 0

Thread 1

a : x = 1 b : if (y == 0){ c :

  • crit. sect. 1

d : }

Thread 2

p : y = 1 q : if (x == 0){ r :

  • crit. sect. 2

s : }

Thread 1 pc = c Thread 2 pc = p Mem

x 1 y

w(x, 1) · r(y, 0)

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 3 / 27

slide-6
SLIDE 6

Sequential Consistency (SC) Semantics [Lamport 1979]

Threads directly write to and read from memory Classical interleaving semantics

◮ Computations of different threads are shuffled ◮ Program order is preserved for each thread

x = y = 0

Thread 1

a : x = 1 b : if (y == 0){ c :

  • crit. sect. 1

d : }

Thread 2

p : y = 1 q : if (x == 0){ r :

  • crit. sect. 2

s : }

Thread 1 pc = c Thread 2 pc = q Mem

x 1 y 1

w(x, 1) · r(y, 0) · w(y, 1)

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 3 / 27

slide-7
SLIDE 7

Sequential Consistency (SC) Semantics [Lamport 1979]

Threads directly write to and read from memory Classical interleaving semantics

◮ Computations of different threads are shuffled ◮ Program order is preserved for each thread

x = y = 0

Thread 1

a : x = 1 b : if (y == 0){ c :

  • crit. sect. 1

d : }

Thread 2

p : y = 1 q : if (x == 0){ r :

  • crit. sect. 2

s : }

Thread 1 pc = c Thread 2 pc = q Mem

x 1 y 1

Mutual exclusion holds!

w(x, 1) · r(y, 0) · w(y, 1) ·

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 3 / 27

slide-8
SLIDE 8

Total Store Ordering (TSO) Semantics [SPARC 1994, x86]

Sequential Consistency forbids compiler and hardware optimizations Hence is not implemented by any processor Processors have various buffers to reduce latency of memory accesses Behavior captured by relaxed memory models Here: Total Store Ordering (TSO) memory model

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 4 / 27

slide-9
SLIDE 9

Total Store Ordering (TSO) Semantics [SPARC 1994, x86]

TSO architectures have write buffers (FIFO) Read takes value from memory if no write to that variable is buffered Otherwise read value of last write to that variable in the buffer

x = y = 0

Thread 1

a : x = 1 b : if (y == 0){ c :

  • crit. sect. 1

d : }

Thread 2

p : y = 1 q : if (x == 0){ r :

  • crit. sect. 2

s : }

Thread 1 pc = a Thread 2 pc = p Mem

x y

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 5 / 27

slide-10
SLIDE 10

Total Store Ordering (TSO) Semantics [SPARC 1994, x86]

TSO architectures have write buffers (FIFO) Read takes value from memory if no write to that variable is buffered Otherwise read value of last write to that variable in the buffer

x = y = 0

Thread 1

a : x = 1 b : if (y == 0){ c :

  • crit. sect. 1

d : }

Thread 2

p : y = 1 q : if (x == 0){ r :

  • crit. sect. 2

s : }

Thread 1 pc = b Thread 2 pc = p w(x, 1) Mem

x y

isu

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 5 / 27

slide-11
SLIDE 11

Total Store Ordering (TSO) Semantics [SPARC 1994, x86]

TSO architectures have write buffers (FIFO) Read takes value from memory if no write to that variable is buffered Otherwise read value of last write to that variable in the buffer

x = y = 0

Thread 1

a : x = 1 b : if (y == 0){ c :

  • crit. sect. 1

d : }

Thread 2

p : y = 1 q : if (x == 0){ r :

  • crit. sect. 2

s : }

Thread 1 pc = c Thread 2 pc = p w(x, 1) Mem

x y

isu · r(y, 0)

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 5 / 27

slide-12
SLIDE 12

Total Store Ordering (TSO) Semantics [SPARC 1994, x86]

TSO architectures have write buffers (FIFO) Read takes value from memory if no write to that variable is buffered Otherwise read value of last write to that variable in the buffer

x = y = 0

Thread 1

a : x = 1 b : if (y == 0){ c :

  • crit. sect. 1

d : }

Thread 2

p : y = 1 q : if (x == 0){ r :

  • crit. sect. 2

s : }

Thread 1 pc = c Thread 2 pc = q w(x, 1) w(y, 1) Mem

x y

isu · r(y, 0) · isu

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 5 / 27

slide-13
SLIDE 13

Total Store Ordering (TSO) Semantics [SPARC 1994, x86]

TSO architectures have write buffers (FIFO) Read takes value from memory if no write to that variable is buffered Otherwise read value of last write to that variable in the buffer

x = y = 0

Thread 1

a : x = 1 b : if (y == 0){ c :

  • crit. sect. 1

d : }

Thread 2

p : y = 1 q : if (x == 0){ r :

  • crit. sect. 2

s : }

Thread 1 pc = c Thread 2 pc = q w(x, 1) Mem

x y 1

isu · r(y, 0) · isu · w(y, 1)

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 5 / 27

slide-14
SLIDE 14

Total Store Ordering (TSO) Semantics [SPARC 1994, x86]

TSO architectures have write buffers (FIFO) Read takes value from memory if no write to that variable is buffered Otherwise read value of last write to that variable in the buffer

x = y = 0

Thread 1

a : x = 1 b : if (y == 0){ c :

  • crit. sect. 1

d : }

Thread 2

p : y = 1 q : if (x == 0){ r :

  • crit. sect. 2

s : }

Thread 1 pc = c Thread 2 pc = r w(x, 1) Mem

x y 1

isu · r(y, 0) · isu · w(y, 1) · r(x, 0)

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 5 / 27

slide-15
SLIDE 15

Total Store Ordering (TSO) Semantics [SPARC 1994, x86]

TSO architectures have write buffers (FIFO) Read takes value from memory if no write to that variable is buffered Otherwise read value of last write to that variable in the buffer

x = y = 0

Thread 1

a : x = 1 b : if (y == 0){ c :

  • crit. sect. 1

d : }

Thread 2

p : y = 1 q : if (x == 0){ r :

  • crit. sect. 2

s : }

Thread 1 pc = c Thread 2 pc = r Mem

x 1 y 1

isu · r(y, 0) · isu · w(y, 1) · r(x, 0) · w(x, 1)

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 5 / 27

slide-16
SLIDE 16

Total Store Ordering (TSO) Semantics [SPARC 1994, x86]

TSO architectures have write buffers (FIFO) Read takes value from memory if no write to that variable is buffered Otherwise read value of last write to that variable in the buffer

x = y = 0

Thread 1

a : x = 1 b : if (y == 0){ c :

  • crit. sect. 1

d : }

Thread 2

p : y = 1 q : if (x == 0){ r :

  • crit. sect. 2

s : }

Thread 1 pc = c Thread 2 pc = r Mem

x y 1

Mutual exclusion fails!!!

isu · r(y, 0) · isu · w(y, 1) · r(x, 0) · w(x, 1)

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 5 / 27

slide-17
SLIDE 17

Total Store Ordering (TSO) Semantics [SPARC 1994, x86]

TSO architectures have write buffers (FIFO) Read takes value from memory if no write to that variable is buffered Otherwise read value of last write to that variable in the buffer

x = y = 0

Thread 1

a : x = 1 b : if (y == 0){ c :

  • crit. sect. 1

d : }

Thread 2

p : y = 1 q : if (x == 0){ r :

  • crit. sect. 2

s : }

Thread 1 pc = c Thread 2 pc = r Mem

x y 1

isu · r(y, 0) · isu · w(y, 1) · r(x, 0) · w(x, 1)

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 5 / 27

slide-18
SLIDE 18

Verification Required?!

Relaxed executions may lead to bad behavior

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 6 / 27

slide-19
SLIDE 19

Verification Required?!

Relaxed executions may lead to bad behavior

If this is the real world, why does anything work?

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 6 / 27

slide-20
SLIDE 20

Verification Required?!

Relaxed executions may lead to bad behavior

If this is the real world, why does anything work?

Theorem [Adve, Hill 1993]: If a program is data-race-free, then SC and TSO semantics coincide.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 6 / 27

slide-21
SLIDE 21

Verification Required?!

Relaxed executions may lead to bad behavior

If this is the real world, why does anything work?

Theorem [Adve, Hill 1993]: If a program is data-race-free, then SC and TSO semantics coincide.

So, go and write data-race-free programs!

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 6 / 27

slide-22
SLIDE 22

Verification Required?!

Relaxed executions may lead to bad behavior

If this is the real world, why does anything work?

Theorem [Adve, Hill 1993]: If a program is data-race-free, then SC and TSO semantics coincide.

So, go and write data-race-free programs!

Works in 90% of the cases

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 6 / 27

slide-23
SLIDE 23

Verification Required?!

Relaxed executions may lead to bad behavior

If this is the real world, why does anything work?

Theorem [Adve, Hill 1993]: If a program is data-race-free, then SC and TSO semantics coincide.

So, go and write data-race-free programs!

Works in 90% of the cases

Performance-critical code does have data races

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 6 / 27

slide-24
SLIDE 24

Verification Required?!

Relaxed executions may lead to bad behavior

If this is the real world, why does anything work?

Theorem [Adve, Hill 1993]: If a program is data-race-free, then SC and TSO semantics coincide.

So, go and write data-race-free programs!

Works in 90% of the cases

Performance-critical code does have data races

Concurrency libraries Operating systems HPC@Fraunhofer ITWM

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 6 / 27

slide-25
SLIDE 25

Verification Required?!

Relaxed executions may lead to bad behavior

If this is the real world, why does anything work?

Theorem [Adve, Hill 1993]: If a program is data-race-free, then SC and TSO semantics coincide.

So, go and write data-race-free programs!

Works in 90% of the cases

Performance-critical code does have data races

Concurrency libraries Operating systems HPC@Fraunhofer ITWM

This is where our verification techniques apply

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 6 / 27

slide-26
SLIDE 26

Robustness

Idea: SC semantics is specification

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 7 / 27

slide-27
SLIDE 27

Robustness

Idea: SC semantics is specification Relaxed behavior may contain bugs because programmers only had SC in mind

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 7 / 27

slide-28
SLIDE 28

Robustness

Idea: SC semantics is specification Relaxed behavior may contain bugs because programmers only had SC in mind Every relaxed behavior has an SC equivalent (up to traces)

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 7 / 27

slide-29
SLIDE 29

Robustness

Idea: SC semantics is specification Relaxed behavior may contain bugs because programmers only had SC in mind Every relaxed behavior has an SC equivalent (up to traces) Every relaxed behavior that deviates from SC is a programming error

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 7 / 27

slide-30
SLIDE 30

Robustness

Idea: SC semantics is specification Relaxed behavior may contain bugs because programmers only had SC in mind Every relaxed behavior has an SC equivalent (up to traces) Every relaxed behavior that deviates from SC is a programming error Robustness Problem against relaxed memory model RMM

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 7 / 27

slide-31
SLIDE 31

Robustness

Idea: SC semantics is specification Relaxed behavior may contain bugs because programmers only had SC in mind Every relaxed behavior has an SC equivalent (up to traces) Every relaxed behavior that deviates from SC is a programming error Robustness Problem against relaxed memory model RMM Input: Program P.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 7 / 27

slide-32
SLIDE 32

Robustness

Idea: SC semantics is specification Relaxed behavior may contain bugs because programmers only had SC in mind Every relaxed behavior has an SC equivalent (up to traces) Every relaxed behavior that deviates from SC is a programming error Robustness Problem against relaxed memory model RMM Input: Program P. Problem: Does TracesRMM(P) ⊆ TracesSC(P) hold?

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 7 / 27

slide-33
SLIDE 33

Robustness

Idea: SC semantics is specification Relaxed behavior may contain bugs because programmers only had SC in mind Every relaxed behavior has an SC equivalent (up to traces) Every relaxed behavior that deviates from SC is a programming error Robustness Problem against relaxed memory model RMM Input: Program P. Problem: Does TracesRMM(P) ⊆ TracesSC(P) hold? Decidability / Complexity ?

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 7 / 27

slide-34
SLIDE 34

Outline

1

Shared Memory Concurrency Sequential Consistency Semantics Total Store Ordering Semantics

2

Robustness: General Solution Combinatorics Algorithmics

3

Robustness: Efficient Solution Combinatorics

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 8 / 27

slide-35
SLIDE 35

Robustness: General Solution

[Calin, Derevenetc, Majumdar, M., FSTTCS’13] [Derevenetc, M., ICALP’14]

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 9 / 27

slide-36
SLIDE 36

Robustness: General Solution

[Calin, Derevenetc, Majumdar, M., FSTTCS’13] [Derevenetc, M., ICALP’14]

Decision procedure for robustness that

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 9 / 27

slide-37
SLIDE 37

Robustness: General Solution

[Calin, Derevenetc, Majumdar, M., FSTTCS’13] [Derevenetc, M., ICALP’14]

Decision procedure for robustness that applies to most memory models (checked TSO, PSO, PGAS, Power)

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 9 / 27

slide-38
SLIDE 38

Robustness: General Solution

[Calin, Derevenetc, Majumdar, M., FSTTCS’13] [Derevenetc, M., ICALP’14]

Decision procedure for robustness that applies to most memory models (checked TSO, PSO, PGAS, Power) gives precise complexity

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 9 / 27

slide-39
SLIDE 39

Robustness: General Solution

[Calin, Derevenetc, Majumdar, M., FSTTCS’13] [Derevenetc, M., ICALP’14]

Decision procedure for robustness that applies to most memory models (checked TSO, PSO, PGAS, Power) gives precise complexity ... but relies on a new automaton model and lots of guessing

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 9 / 27

slide-40
SLIDE 40

Robustness: General Solution

RMM-computations Robust Computations Minimal Violations = ∅ ?

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 10 / 27

slide-41
SLIDE 41

Robustness: General Solution

RMM-computations Robust Computations Minimal Violations = ∅ ? Combinatorics: Violations can be assumed to be in normal form

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 10 / 27

slide-42
SLIDE 42

Robustness: General Solution

RMM-computations Robust Computations Minimal Violations = ∅ ? Combinatorics: Violations can be assumed to be in normal form Algorithmics: Check whether normal form violations exist

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 10 / 27

slide-43
SLIDE 43

Robustness: General Solution

RMM-computations Robust Computations Minimal Violations = ∅ ? Combinatorics: Violations can be assumed to be in normal form Algorithmics: Check whether normal form violations exist Together: Reduce robustness to an emptiness check Lnf ∩ Rcyc

?

= ∅.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 10 / 27

slide-44
SLIDE 44

Robustness: General Solution

Reduce robustness to an emptiness check Lnf ∩ Rcyc

?

= ∅.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 11 / 27

slide-45
SLIDE 45

Robustness: General Solution

Reduce robustness to an emptiness check Lnf ∩ Rcyc

?

= ∅. Combinatorics:

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 11 / 27

slide-46
SLIDE 46

Robustness: General Solution

Reduce robustness to an emptiness check Lnf ∩ Rcyc

?

= ∅. Combinatorics: Violations to SC (if any) have a representative in normal form.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 11 / 27

slide-47
SLIDE 47

Robustness: General Solution

Reduce robustness to an emptiness check Lnf ∩ Rcyc

?

= ∅. Combinatorics: Violations to SC (if any) have a representative in normal form. Algorithmics:

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 11 / 27

slide-48
SLIDE 48

Robustness: General Solution

Reduce robustness to an emptiness check Lnf ∩ Rcyc

?

= ∅. Combinatorics: Violations to SC (if any) have a representative in normal form. Algorithmics: Language Lnf consists of all normal-form computations.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 11 / 27

slide-49
SLIDE 49

Robustness: General Solution

Reduce robustness to an emptiness check Lnf ∩ Rcyc

?

= ∅. Combinatorics: Violations to SC (if any) have a representative in normal form. Algorithmics: Language Lnf consists of all normal-form computations. ∩ Rcyc filters only violating computations.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 11 / 27

slide-50
SLIDE 50

Robustness: General Solution

Reduce robustness to an emptiness check Lnf ∩ Rcyc

?

= ∅. Combinatorics: Violations to SC (if any) have a representative in normal form. Algorithmics: Language Lnf consists of all normal-form computations. ∩ Rcyc filters only violating computations. Decide Lnf ∩ Rcyc

?

= ∅.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 11 / 27

slide-51
SLIDE 51

Robustness: General Solution

Reduce robustness to an emptiness check Lnf ∩ Rcyc

?

= ∅. Combinatorics: Violations to SC (if any) have a representative in normal form. Algorithmics: Language Lnf consists of all normal-form computations. ∩ Rcyc filters only violating computations. Decide Lnf ∩ Rcyc

?

= ∅.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 12 / 27

slide-52
SLIDE 52

Combinatorics: Normal Form Violations

Lemma (Shasha and Snir, 1988) A computation violates SC iff it has a cyclic happens-before relation. Thread 1 Thread 2 initx a: w(x, 1) d : r(x, 0) inity b: r(y, 0) c : w(y, 1)

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 13 / 27

slide-53
SLIDE 53

Combinatorics: Normal Form Violations

Lemma (Shasha and Snir, 1988) A computation violates SC iff it has a cyclic happens-before relation. Happens-before relation of computation τ = isu · r(y, 0) · isu · w(y, 1) · r(x, 0) · w(x, 1) : Thread 1 Thread 2 initx a: w(x, 1) d : r(x, 0) inity b: r(y, 0) c : w(y, 1)

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 13 / 27

slide-54
SLIDE 54

Combinatorics: Normal Form Violations

Lemma (Shasha and Snir, 1988) A computation violates SC iff it has a cyclic happens-before relation. Happens-before relation of computation τ = isu · r(y, 0) · isu · w(y, 1) · r(x, 0) · w(x, 1) : Thread 1 Thread 2 initx a: w(x, 1) d : r(x, 0) inity b: r(y, 0) c : w(y, 1) po po Program order

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 13 / 27

slide-55
SLIDE 55

Combinatorics: Normal Form Violations

Lemma (Shasha and Snir, 1988) A computation violates SC iff it has a cyclic happens-before relation. Happens-before relation of computation τ = isu · r(y, 0) · isu · w(y, 1) · r(x, 0) · w(x, 1) : Thread 1 Thread 2 initx a: w(x, 1) d : r(x, 0) inity b: r(y, 0) c : w(y, 1) po po st st Program order, store order

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 13 / 27

slide-56
SLIDE 56

Combinatorics: Normal Form Violations

Lemma (Shasha and Snir, 1988) A computation violates SC iff it has a cyclic happens-before relation. Happens-before relation of computation τ = isu · r(y, 0) · isu · w(y, 1) · r(x, 0) · w(x, 1) : Thread 1 Thread 2 initx a: w(x, 1) d : r(x, 0) inity b: r(y, 0) c : w(y, 1) po po st st src src Program order, store order, source relation

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 13 / 27

slide-57
SLIDE 57

Combinatorics: Normal Form Violations

Lemma (Shasha and Snir, 1988) A computation violates SC iff it has a cyclic happens-before relation. Happens-before relation of computation τ = isu · r(y, 0) · isu · w(y, 1) · r(x, 0) · w(x, 1) : Thread 1 Thread 2 initx a: w(x, 1) d : r(x, 0) inity b: r(y, 0) c : w(y, 1) po po st st src src cf cf Program order, store order, source relation, conflict relation

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 13 / 27

slide-58
SLIDE 58

Combinatorics: Normal Form Violations

Normal Form:

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 14 / 27

slide-59
SLIDE 59

Combinatorics: Normal Form Violations

Normal Form: Computation has two parts τ = τ1 · τ2

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 14 / 27

slide-60
SLIDE 60

Combinatorics: Normal Form Violations

Normal Form: Computation has two parts τ = τ1 · τ2 Delays in τ2 respect ordering in τ1

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 14 / 27

slide-61
SLIDE 61

Combinatorics: Normal Form Violations

Normal Form: Computation has two parts τ = τ1 · τ2 Delays in τ2 respect ordering in τ1 In normal form . . . isu . . . isu . . . ⏟ ⏞

τ1

. . . w(x, 1) . . . w(y, 1) . . . ⏟ ⏞

τ2

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 14 / 27

slide-62
SLIDE 62

Combinatorics: Normal Form Violations

Normal Form: Computation has two parts τ = τ1 · τ2 Delays in τ2 respect ordering in τ1 In normal form . . . isu . . . isu . . . ⏟ ⏞

τ1

. . . w(x, 1) . . . w(y, 1) . . . ⏟ ⏞

τ2

Not in normal form . . . isu . . . isu . . . ⏟ ⏞

τ1

. . . w(y, 1) . . . w(x, 1) . . . ⏟ ⏞

τ2

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 14 / 27

slide-63
SLIDE 63

Combinatorics: Normal Form Violations

Theorem (Normal form): If a program is not robust, it has a violation in normal form.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 15 / 27

slide-64
SLIDE 64

Combinatorics: Normal Form Violations

Theorem (Normal form): If a program is not robust, it has a violation in normal form. Proof: Take a shortest computation τ with cyclic happens-before relation.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 15 / 27

slide-65
SLIDE 65

Combinatorics: Normal Form Violations

Theorem (Normal form): If a program is not robust, it has a violation in normal form. Proof: Take a shortest computation τ with cyclic happens-before relation. There is (may be non-trivial, depending on RMM) an event that can be cancelled: τ = τ1 · a · τ2 .

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 15 / 27

slide-66
SLIDE 66

Combinatorics: Normal Form Violations

Theorem (Normal form): If a program is not robust, it has a violation in normal form. Proof: Take a shortest computation τ with cyclic happens-before relation. There is (may be non-trivial, depending on RMM) an event that can be cancelled: τ = τ1 · a · τ2 . Computation τ1 · τ2 is shorter

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 15 / 27

slide-67
SLIDE 67

Combinatorics: Normal Form Violations

Theorem (Normal form): If a program is not robust, it has a violation in normal form. Proof: Take a shortest computation τ with cyclic happens-before relation. There is (may be non-trivial, depending on RMM) an event that can be cancelled: τ = τ1 · a · τ2 . Computation τ1 · τ2 is shorter, hence not violating.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 15 / 27

slide-68
SLIDE 68

Combinatorics: Normal Form Violations

Theorem (Normal form): If a program is not robust, it has a violation in normal form. Proof: Take a shortest computation τ with cyclic happens-before relation. There is (may be non-trivial, depending on RMM) an event that can be cancelled: τ = τ1 · a · τ2 . Computation τ1 · τ2 is shorter, hence not violating. There is an SC computation σ with same happens-before relation.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 15 / 27

slide-69
SLIDE 69

Combinatorics: Normal Form Violations

Theorem (Normal form): If a program is not robust, it has a violation in normal form. Proof: Take a shortest computation τ with cyclic happens-before relation. There is (may be non-trivial, depending on RMM) an event that can be cancelled: τ = τ1 · a · τ2 . Computation τ1 · τ2 is shorter, hence not violating. There is an SC computation σ with same happens-before relation. Now (σ ↓ τ1) · a · (σ ↓ τ2)

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 15 / 27

slide-70
SLIDE 70

Combinatorics: Normal Form Violations

Theorem (Normal form): If a program is not robust, it has a violation in normal form. Proof: Take a shortest computation τ with cyclic happens-before relation. There is (may be non-trivial, depending on RMM) an event that can be cancelled: τ = τ1 · a · τ2 . Computation τ1 · τ2 is shorter, hence not violating. There is an SC computation σ with same happens-before relation. Now (σ ↓ τ1) · a · (σ ↓ τ2) is in normal form

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 15 / 27

slide-71
SLIDE 71

Combinatorics: Normal Form Violations

Theorem (Normal form): If a program is not robust, it has a violation in normal form. Proof: Take a shortest computation τ with cyclic happens-before relation. There is (may be non-trivial, depending on RMM) an event that can be cancelled: τ = τ1 · a · τ2 . Computation τ1 · τ2 is shorter, hence not violating. There is an SC computation σ with same happens-before relation. Now (σ ↓ τ1) · a · (σ ↓ τ2) is in normal form and violating.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 15 / 27

slide-72
SLIDE 72

Robustness: General Solution

Reduce robustness to an emptiness check Lnf ∩ Rcyc

?

= ∅. Combinatorics: Violations to SC (if any) have a representative in normal form. Algorithmics: Language Lnf consists of all normal-form computations. ∩ Rcyc filters only violating computations. Decide Lnf ∩ Rcyc

?

= ∅.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 16 / 27

slide-73
SLIDE 73

Algorithmics: Generating Normal-Form Computations

Challenge Describe language Lnf of all normal-form computations

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 17 / 27

slide-74
SLIDE 74

Algorithmics: Generating Normal-Form Computations

Challenge Describe language Lnf of all normal-form computations Need a language class that

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 17 / 27

slide-75
SLIDE 75

Algorithmics: Generating Normal-Form Computations

Challenge Describe language Lnf of all normal-form computations Need a language class that includes Lnf ,

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 17 / 27

slide-76
SLIDE 76

Algorithmics: Generating Normal-Form Computations

Challenge Describe language Lnf of all normal-form computations Need a language class that includes Lnf , is closed under regular intersection (Lnf ∩ Rcyc),

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 17 / 27

slide-77
SLIDE 77

Algorithmics: Generating Normal-Form Computations

Challenge Describe language Lnf of all normal-form computations Need a language class that includes Lnf , is closed under regular intersection (Lnf ∩ Rcyc), has decidable emptiness problem (Lnf ∩ Rcyc

?

= ∅).

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 17 / 27

slide-78
SLIDE 78

Algorithmics: Generating Normal-Form Computations

Challenge Describe language Lnf of all normal-form computations Need a language class that includes Lnf , is closed under regular intersection (Lnf ∩ Rcyc), has decidable emptiness problem (Lnf ∩ Rcyc

?

= ∅). Properties of Lnf

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 17 / 27

slide-79
SLIDE 79

Algorithmics: Generating Normal-Form Computations

Challenge Describe language Lnf of all normal-form computations Need a language class that includes Lnf , is closed under regular intersection (Lnf ∩ Rcyc), has decidable emptiness problem (Lnf ∩ Rcyc

?

= ∅). Properties of Lnf Number of concurrently executed instructions is unbounded

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 17 / 27

slide-80
SLIDE 80

Algorithmics: Generating Normal-Form Computations

Challenge Describe language Lnf of all normal-form computations Need a language class that includes Lnf , is closed under regular intersection (Lnf ∩ Rcyc), has decidable emptiness problem (Lnf ∩ Rcyc

?

= ∅). Properties of Lnf Number of concurrently executed instructions is unbounded May include computations like isun · w(x, 1)n

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 17 / 27

slide-81
SLIDE 81

Algorithmics: Generating Normal-Form Computations

Challenge Describe language Lnf of all normal-form computations Need a language class that includes Lnf , is closed under regular intersection (Lnf ∩ Rcyc), has decidable emptiness problem (Lnf ∩ Rcyc

?

= ∅). Properties of Lnf Number of concurrently executed instructions is unbounded May include computations like isun · w(x, 1)n ⇒ not regular

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 17 / 27

slide-82
SLIDE 82

Algorithmics: Generating Normal-Form Computations

Solution Define Lnf as language of a multiheaded automaton . . . isu . . . isu . . . ⏟ ⏞

τ1

. . . w(x, 1) . . . w(y, 1) . . . ⏟ ⏞

τ2

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 18 / 27

slide-83
SLIDE 83

Algorithmics: Generating Normal-Form Computations

Solution Define Lnf as language of a multiheaded automaton Multiheaded automata . . . isu . . . isu . . . ⏟ ⏞

τ1

. . . w(x, 1) . . . w(y, 1) . . . ⏟ ⏞

τ2

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 18 / 27

slide-84
SLIDE 84

Algorithmics: Generating Normal-Form Computations

Solution Define Lnf as language of a multiheaded automaton Multiheaded automata Extension of NFA . . . isu . . . isu . . . ⏟ ⏞

τ1

. . . w(x, 1) . . . w(y, 1) . . . ⏟ ⏞

τ2

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 18 / 27

slide-85
SLIDE 85

Algorithmics: Generating Normal-Form Computations

Solution Define Lnf as language of a multiheaded automaton Multiheaded automata Extension of NFA Generates parts τ1 and τ2 of a computation τ1 · τ2 simultaneously . . . isu . . . isu . . . ⏟ ⏞

τ1

. . . w(x, 1) . . . w(y, 1) . . . ⏟ ⏞

τ2

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 18 / 27

slide-86
SLIDE 86

Algorithmics: Generating Normal-Form Computations

Solution Define Lnf as language of a multiheaded automaton Multiheaded automata Extension of NFA Generates parts τ1 and τ2 of a computation τ1 · τ2 simultaneously Transitions q

1,a

− − → q′ and q

2,b

− − → q′ labeled by head i = 1, 2 . . . isu . . . isu . . . ⏟ ⏞

τ1

. . . w(x, 1) . . . w(y, 1) . . . ⏟ ⏞

τ2

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 18 / 27

slide-87
SLIDE 87

Algorithmics: Generating Normal-Form Computations

Solution Define Lnf as language of a multiheaded automaton Multiheaded automata Extension of NFA Generates parts τ1 and τ2 of a computation τ1 · τ2 simultaneously Transitions q

1,a

− − → q′ and q

2,b

− − → q′ labeled by head i = 1, 2 Example: . . . isu . . . isu . . . ⏟ ⏞

τ1

. . . w(x, 1) . . . w(y, 1) . . . ⏟ ⏞

τ2

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 18 / 27

slide-88
SLIDE 88

Algorithmics: Generating Normal-Form Computations

Solution Define Lnf as language of a multiheaded automaton Multiheaded automata Extension of NFA Generates parts τ1 and τ2 of a computation τ1 · τ2 simultaneously Transitions q

1,a

− − → q′ and q

2,b

− − → q′ labeled by head i = 1, 2 Example:

↑ . . . isu . . . isu . . .

⏟ ⏞

τ1 ↑ . . . w(x, 1) . . . w(y, 1) . . .

⏟ ⏞

τ2

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 18 / 27

slide-89
SLIDE 89

Algorithmics: Generating Normal-Form Computations

Solution Define Lnf as language of a multiheaded automaton Multiheaded automata Extension of NFA Generates parts τ1 and τ2 of a computation τ1 · τ2 simultaneously Transitions q

1,a

− − → q′ and q

2,b

− − → q′ labeled by head i = 1, 2 Example: . . . ↑isu . . . isu . . . ⏟ ⏞

τ1 ↑ . . . w(x, 1) . . . w(y, 1) . . .

⏟ ⏞

τ2

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 18 / 27

slide-90
SLIDE 90

Algorithmics: Generating Normal-Form Computations

Solution Define Lnf as language of a multiheaded automaton Multiheaded automata Extension of NFA Generates parts τ1 and τ2 of a computation τ1 · τ2 simultaneously Transitions q

1,a

− − → q′ and q

2,b

− − → q′ labeled by head i = 1, 2 Example: . . . ↑isu . . . isu . . . ⏟ ⏞

τ1

. . . ↑w(x, 1) . . . w(y, 1) . . . ⏟ ⏞

τ2

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 18 / 27

slide-91
SLIDE 91

Algorithmics: Generating Normal-Form Computations

Solution Define Lnf as language of a multiheaded automaton Multiheaded automata Extension of NFA Generates parts τ1 and τ2 of a computation τ1 · τ2 simultaneously Transitions q

1,a

− − → q′ and q

2,b

− − → q′ labeled by head i = 1, 2 Example: . . . ↑isu . . . isu . . . ⏟ ⏞

τ1

. . . ↑w(x, 1) . . . w(y, 1) . . . ⏟ ⏞

τ2

Transitions: q1

1,isu

− − − → q2

2,w(x,1)

− − − − − → q3

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 18 / 27

slide-92
SLIDE 92

Algorithmics: Generating Normal-Form Computations

Solution Define Lnf as language of a multiheaded automaton Multiheaded automata Extension of NFA Generates parts τ1 and τ2 of a computation τ1 · τ2 simultaneously Transitions q

1,a

− − → q′ and q

2,b

− − → q′ labeled by head i = 1, 2 Example: . . . isu↑ . . . isu . . . ⏟ ⏞

τ1

. . . ↑w(x, 1) . . . w(y, 1) . . . ⏟ ⏞

τ2

Transitions: q1

1,isu

− − − → q2

2,w(x,1)

− − − − − → q3

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 18 / 27

slide-93
SLIDE 93

Algorithmics: Generating Normal-Form Computations

Solution Define Lnf as language of a multiheaded automaton Multiheaded automata Extension of NFA Generates parts τ1 and τ2 of a computation τ1 · τ2 simultaneously Transitions q

1,a

− − → q′ and q

2,b

− − → q′ labeled by head i = 1, 2 Example: . . . isu↑ . . . isu . . . ⏟ ⏞

τ1

. . . w(x, 1)↑ . . . w(y, 1) . . . ⏟ ⏞

τ2

Transitions: q1

1,isu

− − − → q2

2,w(x,1)

− − − − − → q3

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 18 / 27

slide-94
SLIDE 94

Robustness: General Solution

Reduce robustness to an emptiness check Lnf ∩ Rcyc

?

= ∅. Combinatorics: Violations to SC (if any) have a representative in normal form. Algorithmics: Language Lnf consists of all normal-form computations. ∩ Rcyc filters only violating computations. Decide Lnf ∩ Rcyc

?

= ∅.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 19 / 27

slide-95
SLIDE 95

Algorithmics: Checking Cyclicity

Happens-before relation from the example: Thread 1 Thread 2 initx a: w(x, 1) d : r(x, 0) inity b: r(y, 0) c : w(y, 1) po po st st src src cf cf

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 20 / 27

slide-96
SLIDE 96

Algorithmics: Checking Cyclicity

Happens-before relation from the example: Thread 1 Thread 2 initx a: w(x, 1) d : r(x, 0) inity b: r(y, 0) c : w(y, 1) po po st st src src cf cf Checking cyclicity

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 20 / 27

slide-97
SLIDE 97

Algorithmics: Checking Cyclicity

Happens-before relation from the example: Thread 1 Thread 2 initx a: w(x, 1) d : r(x, 0) inity b: r(y, 0) c : w(y, 1) po po st st src src cf cf Checking cyclicity Finitely many types of cycles

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 20 / 27

slide-98
SLIDE 98

Algorithmics: Checking Cyclicity

Happens-before relation from the example: Thread 1 Thread 2 initx a: w(x, 1) d : r(x, 0) inity b: r(y, 0) c : w(y, 1) po po st st src src cf cf Checking cyclicity Finitely many types of cycles Guess per thread two instructions in program order

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 20 / 27

slide-99
SLIDE 99

Algorithmics: Checking Cyclicity

Happens-before relation from the example: Thread 1 Thread 2 initx a: w(x, 1) d : r(x, 0) inity b: r(y, 0) c : w(y, 1) po po st st src src cf cf Checking cyclicity Finitely many types of cycles Guess per thread two instructions in program order Finite automata check edges between guessed instructions from different threads

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 20 / 27

slide-100
SLIDE 100

Robustness: General Solution

Reduce robustness to an emptiness check Lnf ∩ Rcyc

?

= ∅. Combinatorics: Violations to SC (if any) have a representative in normal form. Algorithmics: Language Lnf consists of all normal-form computations. ∩ Rcyc filters only violating computations. Decide Lnf ∩ Rcyc

?

= ∅.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 21 / 27

slide-101
SLIDE 101

Algorithmics: Emptiness

Theorem: Assuming finite memory, robustness is PSpace-complete.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 22 / 27

slide-102
SLIDE 102

Algorithmics: Emptiness

Theorem: Assuming finite memory, robustness is PSpace-complete. Proof:

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 22 / 27

slide-103
SLIDE 103

Algorithmics: Emptiness

Theorem: Assuming finite memory, robustness is PSpace-complete. Proof: Upper bound: Lnf ∩ Rcyc

?

= ∅.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 22 / 27

slide-104
SLIDE 104

Algorithmics: Emptiness

Theorem: Assuming finite memory, robustness is PSpace-complete. Proof: Upper bound: Lnf ∩ Rcyc

?

= ∅. Lower bound: SC state reachability [Kozen 1977].

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 22 / 27

slide-105
SLIDE 105

Robustness: Efficient Solution

[Bouajjani, M., M¨

  • hlmann, ICALP’11]

[Bouajjani, Derevenetc, M., ESOP’13]

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 23 / 27

slide-106
SLIDE 106

Robustness: Efficient Solution

[Bouajjani, M., M¨

  • hlmann, ICALP’11]

[Bouajjani, Derevenetc, M., ESOP’13]

Decision procedure for robustness that

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 23 / 27

slide-107
SLIDE 107

Robustness: Efficient Solution

[Bouajjani, M., M¨

  • hlmann, ICALP’11]

[Bouajjani, Derevenetc, M., ESOP’13]

Decision procedure for robustness that uses standard SC reachability in ordinary parallel programs

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 23 / 27

slide-108
SLIDE 108

Robustness: Efficient Solution

[Bouajjani, M., M¨

  • hlmann, ICALP’11]

[Bouajjani, Derevenetc, M., ESOP’13]

Decision procedure for robustness that uses standard SC reachability in ordinary parallel programs (rather than emptiness in multiheaded automata)

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 23 / 27

slide-109
SLIDE 109

Robustness: Efficient Solution

[Bouajjani, M., M¨

  • hlmann, ICALP’11]

[Bouajjani, Derevenetc, M., ESOP’13]

Decision procedure for robustness that uses standard SC reachability in ordinary parallel programs (rather than emptiness in multiheaded automata) avoids non-determinism for finding cycles (regular intersection)

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 23 / 27

slide-110
SLIDE 110

Robustness: Efficient Solution

[Bouajjani, M., M¨

  • hlmann, ICALP’11]

[Bouajjani, Derevenetc, M., ESOP’13]

Decision procedure for robustness that uses standard SC reachability in ordinary parallel programs (rather than emptiness in multiheaded automata) avoids non-determinism for finding cycles (regular intersection) ... but is hard to apply (so far only works for TSO)

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 23 / 27

slide-111
SLIDE 111

Robustness: Efficient Solution

RMM-computations Robust Computations Minimal Violations = ∅ ?

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 24 / 27

slide-112
SLIDE 112

Robustness: Efficient Solution

RMM-computations Robust Computations Minimal Violations = ∅ ? Combinatorics: Violations can be assumed to be local

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 24 / 27

slide-113
SLIDE 113

Robustness: Efficient Solution

RMM-computations Robust Computations Minimal Violations = ∅ ? Combinatorics: Violations can be assumed to be local — one thread delays

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 24 / 27

slide-114
SLIDE 114

Robustness: Efficient Solution

RMM-computations Robust Computations Minimal Violations = ∅ ? Combinatorics: Violations can be assumed to be local — one thread delays Algorithmics: Check whether local violations exist

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 24 / 27

slide-115
SLIDE 115

Robustness: Efficient Solution

RMM-computations Robust Computations Minimal Violations = ∅ ? Combinatorics: Violations can be assumed to be local — one thread delays Algorithmics: Check whether local violations exist Together: Reduce robustness to SC reachability in an instrumented program

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 24 / 27

slide-116
SLIDE 116

Combinatorics: Locality Theorem

Theorem (Locality): If a program is not robust against TSO, then there is a violating computation where only one thread delays writes.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 25 / 27

slide-117
SLIDE 117

Combinatorics: Locality Theorem

Theorem (Locality): If a program is not robust against TSO, then there is a violating computation where only one thread delays writes. Combinatorial set-up: Consider a violating computation, where

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 25 / 27

slide-118
SLIDE 118

Combinatorics: Locality Theorem

Theorem (Locality): If a program is not robust against TSO, then there is a violating computation where only one thread delays writes. Combinatorial set-up: Consider a violating computation, where number of delays is minimal.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 25 / 27

slide-119
SLIDE 119

Combinatorics: Locality Theorem

Theorem (Locality): If a program is not robust against TSO, then there is a violating computation where only one thread delays writes. Combinatorial set-up: Consider a violating computation, where number of delays is minimal. Lemma: In a minimal violation τ1 · a · τ2 · b · τ3 with thread(a) = thread(b), there is a happens-before path between a and b through τ2.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 25 / 27

slide-120
SLIDE 120

Combinatorics: Locality Theorem

Proof (Locality Theorem): Three cases: . . . isu . . . w(y, 1) . . . . . . isu . . . w(x, 1) . . . . . . isu . . . isu . . . . . . w(y, 1) . . . w(y, 1) . . . . . . isu . . . isu . . . . . . w(x, 1) . . . w(y, 1) . . . Non-trivial

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 26 / 27

slide-121
SLIDE 121

Conclusion

Robustness Compares relaxed behaviors against SC

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 27 / 27

slide-122
SLIDE 122

Conclusion

Robustness Compares relaxed behaviors against SC Problem is PSPACE-complete for many models

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 27 / 27

slide-123
SLIDE 123

Conclusion

Robustness Compares relaxed behaviors against SC Problem is PSPACE-complete for many models Upper bound uses unified approach

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 27 / 27

slide-124
SLIDE 124

Conclusion

Robustness Compares relaxed behaviors against SC Problem is PSPACE-complete for many models Upper bound uses unified approach based on normal forms and multiheaded automata

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 27 / 27

slide-125
SLIDE 125

Conclusion

Robustness Compares relaxed behaviors against SC Problem is PSPACE-complete for many models Upper bound uses unified approach based on normal forms and multiheaded automata Efficient implementations rely on locality

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 27 / 27

slide-126
SLIDE 126

Conclusion

Robustness Compares relaxed behaviors against SC Problem is PSPACE-complete for many models Upper bound uses unified approach based on normal forms and multiheaded automata Efficient implementations rely on locality Alternative: Reachability

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 27 / 27

slide-127
SLIDE 127

Conclusion

Robustness Compares relaxed behaviors against SC Problem is PSPACE-complete for many models Upper bound uses unified approach based on normal forms and multiheaded automata Efficient implementations rely on locality Alternative: Reachability Decidable for TSO (and beyond), but non-primitive recursive [Atig et

  • al. POPL’10, ESOP’12]

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 27 / 27

slide-128
SLIDE 128

Conclusion

Robustness Compares relaxed behaviors against SC Problem is PSPACE-complete for many models Upper bound uses unified approach based on normal forms and multiheaded automata Efficient implementations rely on locality Alternative: Reachability Decidable for TSO (and beyond), but non-primitive recursive [Atig et

  • al. POPL’10, ESOP’12]

Abstraction-based techniques [Kuperstein, Vechev, Yahav, PLDI’11]

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 27 / 27

slide-129
SLIDE 129

Conclusion

Robustness Compares relaxed behaviors against SC Problem is PSPACE-complete for many models Upper bound uses unified approach based on normal forms and multiheaded automata Efficient implementations rely on locality Alternative: Reachability Decidable for TSO (and beyond), but non-primitive recursive [Atig et

  • al. POPL’10, ESOP’12]

Abstraction-based techniques [Kuperstein, Vechev, Yahav, PLDI’11] Symbolic techniques [Abdulla et al., TACAS’12][Linden, Wolper, SPIN’10’11]

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 27 / 27

slide-130
SLIDE 130

Conclusion

Robustness Compares relaxed behaviors against SC Problem is PSPACE-complete for many models Upper bound uses unified approach based on normal forms and multiheaded automata Efficient implementations rely on locality Alternative: Reachability Decidable for TSO (and beyond), but non-primitive recursive [Atig et

  • al. POPL’10, ESOP’12]

Abstraction-based techniques [Kuperstein, Vechev, Yahav, PLDI’11] Symbolic techniques [Abdulla et al., TACAS’12][Linden, Wolper, SPIN’10’11] Pros: Robustness does not need a spec.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 27 / 27

slide-131
SLIDE 131

Conclusion

Robustness Compares relaxed behaviors against SC Problem is PSPACE-complete for many models Upper bound uses unified approach based on normal forms and multiheaded automata Efficient implementations rely on locality Alternative: Reachability Decidable for TSO (and beyond), but non-primitive recursive [Atig et

  • al. POPL’10, ESOP’12]

Abstraction-based techniques [Kuperstein, Vechev, Yahav, PLDI’11] Symbolic techniques [Abdulla et al., TACAS’12][Linden, Wolper, SPIN’10’11] Pros: Robustness does not need a spec. Reachability checks what is needed.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 27 / 27

slide-132
SLIDE 132

Conclusion

Robustness Compares relaxed behaviors against SC Problem is PSPACE-complete for many models Upper bound uses unified approach based on normal forms and multiheaded automata Efficient implementations rely on locality Alternative: Reachability Decidable for TSO (and beyond), but non-primitive recursive [Atig et

  • al. POPL’10, ESOP’12]

Abstraction-based techniques [Kuperstein, Vechev, Yahav, PLDI’11] Symbolic techniques [Abdulla et al., TACAS’12][Linden, Wolper, SPIN’10’11] Pros: Robustness does not need a spec. Reachability checks what is

  • needed. Robustness is cheaper.

Roland Meyer (TU KL) Robustness against Relaxed Memory Models MM February 2015 27 / 27