Replication and Consistency Setting: Concurrent threads accessing - - PowerPoint PPT Presentation

replication and consistency
SMART_READER_LITE
LIVE PREVIEW

Replication and Consistency Setting: Concurrent threads accessing - - PowerPoint PPT Presentation

Replication and Consistency in and hardware general memory consistency models in particular Roland Meyer Technische Universit at Kaiserslautern Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 1 / 32


slide-1
SLIDE 1

Replication and Consistency∗

∗ in and hardware general memory consistency models in particular

Roland Meyer

Technische Universit¨ at Kaiserslautern

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 1 / 32

slide-2
SLIDE 2

Replication and Consistency

Setting: Concurrent threads accessing shared data

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 2 / 32

slide-3
SLIDE 3

Replication and Consistency

Setting: Concurrent threads accessing shared data

Shared Data Thread 1 Thread 2

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 2 / 32

slide-4
SLIDE 4

Replication and Consistency

Setting: Concurrent threads accessing shared data

Shared Data Thread 1 Thread 2

Problem 1: Access to shared data is slow

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 2 / 32

slide-5
SLIDE 5

Replication and Consistency

Setting: Concurrent threads accessing shared data

Shared Data Thread 1 Thread 2

Problem 1: Access to shared data is slow

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 2 / 32

slide-6
SLIDE 6

Replication and Consistency

Setting: Concurrent threads accessing shared data

Shared Data Thread 1 Thread 2

Problem 1: Access to shared data is slow Solution 1: Replicate data so that every thread has a copy

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 2 / 32

slide-7
SLIDE 7

Replication and Consistency

Setting: Concurrent threads accessing shared data

Shared Data Thread 1 Thread 2

Problem 1: Access to shared data is slow Solution 1: Replicate data so that every thread has a copy

Thread 1 Thread 2 Replica 1 Replica 2

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 2 / 32

slide-8
SLIDE 8

Replication and Consistency

Problem 2: Announce updates to other replicas

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 3 / 32

slide-9
SLIDE 9

Replication and Consistency

Problem 2: Announce updates to other replicas Solution 2: Halt the system and inform everybody

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 3 / 32

slide-10
SLIDE 10

Replication and Consistency

Problem 2: Announce updates to other replicas Solution 2: Halt the system and inform everybody Ruins all performance benefits (back to Problem 1)

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 3 / 32

slide-11
SLIDE 11

Replication and Consistency

Problem 2: Announce updates to other replicas Solution 2: Halt the system and inform everybody Ruins all performance benefits (back to Problem 1) Solution 2’: Inform other threads in a delayed fashion

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 3 / 32

slide-12
SLIDE 12

Replication and Consistency

Problem 2: Announce updates to other replicas Solution 2: Halt the system and inform everybody Ruins all performance benefits (back to Problem 1) Solution 2’: Inform other threads in a delayed fashion Thread 1 Thread 2 Replica 1 Replica 2

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 3 / 32

slide-13
SLIDE 13

Replication and Consistency

Problem 3: Inconsistent replicas while updates travel

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 4 / 32

slide-14
SLIDE 14

Replication and Consistency

Problem 3: Inconsistent replicas while updates travel Thread 1 Thread 2 State x = 1 State x = 0 x = 1

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 4 / 32

slide-15
SLIDE 15

Replication and Consistency

Problem 3: Inconsistent replicas while updates travel Thread 1 Thread 2 State x = 1 State x = 0 x = 1 Solution 3: Live with it, inconsistency is here to stay!

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 4 / 32

slide-16
SLIDE 16

Replication and Consistency

Weaker Consistency Higher Performance/Availability CAP Undesirable Hardware

  • Prog. Lang.

Geo SC TSO (x86) C++11 Causal EC (Dynamo)

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 5 / 32

slide-17
SLIDE 17

Replication and Consistency

Problem 3: Inconsistent replicas while updates travel Solution 3: Live with it

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 6 / 32

slide-18
SLIDE 18

Replication and Consistency

Problem 3: Inconsistent replicas while updates travel Solution 3: Live with it Solution 3’: Architectures give guarantees about updates

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 6 / 32

slide-19
SLIDE 19

Replication and Consistency

Problem 3: Inconsistent replicas while updates travel Solution 3: Live with it Solution 3’: Architectures give guarantees about

  • rdering
  • f updates

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 6 / 32

slide-20
SLIDE 20

Replication and Consistency

Problem 3: Inconsistent replicas while updates travel Solution 3: Live with it Solution 3’: Architectures give guarantees about

  • rdering and visibility of updates

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 6 / 32

slide-21
SLIDE 21

Replication and Consistency

Problem 3: Inconsistent replicas while updates travel Solution 3: Live with it Solution 3’: Architectures give guarantees about

  • rdering and visibility of updates

Problem 4: But there are so many architectures

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 6 / 32

slide-22
SLIDE 22

Replication and Consistency

Problem 3: Inconsistent replicas while updates travel Solution 3: Live with it Solution 3’: Architectures give guarantees about

  • rdering and visibility of updates

Problem 4: But there are so many architectures Solution 4: Yes, but there are underlying principles

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 6 / 32

slide-23
SLIDE 23

Replication and Consistency

Problem 3: Inconsistent replicas while updates travel Solution 3: Live with it Solution 3’: Architectures give guarantees about

  • rdering and visibility of updates

Problem 4: But there are so many architectures Solution 4: Yes, but there are underlying principles ... at least in hardware

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 6 / 32

slide-24
SLIDE 24

Replication and Consistency

Principles in hardware memory consistency models

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 7 / 32

slide-25
SLIDE 25

Replication and Consistency

Principles in hardware memory consistency models Guarantees in the update mechanism [Alglave, TOPLAS’14]:

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 7 / 32

slide-26
SLIDE 26

Replication and Consistency

Principles in hardware memory consistency models Guarantees in the update mechanism [Alglave, TOPLAS’14]: SC per thread: For one thread running in isolation the system looks consistent

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 7 / 32

slide-27
SLIDE 27

Replication and Consistency

Principles in hardware memory consistency models Guarantees in the update mechanism [Alglave, TOPLAS’14]: SC per thread: For one thread running in isolation the system looks consistent Consequence: We can always rely on address and data dependencies

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 7 / 32

slide-28
SLIDE 28

Replication and Consistency

Principles in hardware memory consistency models Guarantees in the update mechanism [Alglave, TOPLAS’14]: SC per thread: For one thread running in isolation the system looks consistent Consequence: We can always rely on address and data dependencies Coherence: For every variable all threads will see the stores to this variable in the same order

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 7 / 32

slide-29
SLIDE 29

Replication and Consistency

Principles in hardware memory consistency models Guarantees in the update mechanism [Alglave, TOPLAS’14]: SC per thread: For one thread running in isolation the system looks consistent Consequence: We can always rely on address and data dependencies Coherence: For every variable all threads will see the stores to this variable in the same order Why? Programmability

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 7 / 32

slide-30
SLIDE 30

Replication and Consistency

Principles in hardware memory consistency models Guarantees in the update mechanism [Alglave, TOPLAS’14]: SC per thread: For one thread running in isolation the system looks consistent Consequence: We can always rely on address and data dependencies Coherence: For every variable all threads will see the stores to this variable in the same order Why? Programmability + historical reasons

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 7 / 32

slide-31
SLIDE 31

Replication and Consistency

Principles in hardware memory consistency models

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 8 / 32

slide-32
SLIDE 32

Replication and Consistency

Principles in hardware memory consistency models What can be relaxed: Program order

TSO+W/R

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 8 / 32

slide-33
SLIDE 33

Replication and Consistency

Principles in hardware memory consistency models What can be relaxed: Program order

TSO+W/R PSO +W/W

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 8 / 32

slide-34
SLIDE 34

Replication and Consistency

Principles in hardware memory consistency models What can be relaxed: Program order

TSO+W/R PSO PGAS +W/W +R/R

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 8 / 32

slide-35
SLIDE 35

Replication and Consistency

Principles in hardware memory consistency models What can be relaxed: Program order

TSO+W/R PSO PGAS RMO +W/W +R/R +R/W

Very strange (and not in this talk):

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 8 / 32

slide-36
SLIDE 36

Replication and Consistency

Principles in hardware memory consistency models What can be relaxed: Program order

TSO+W/R PSO PGAS RMO +W/W +R/R +R/W

Very strange (and not in this talk): Out-of-thin-air values — arise when threads consistently lie to each other

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 8 / 32

slide-37
SLIDE 37

Replication and Consistency

Principles in hardware memory consistency models What can be relaxed: Program order + store order

TSO+W/R PSO PGAS RMO +W/W +R/R +R/W +NSA

Very strange (and not in this talk): Out-of-thin-air values — arise when threads consistently lie to each other

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 8 / 32

slide-38
SLIDE 38

Replication and Consistency

Principles in hardware memory consistency models What can be relaxed: Program order + store order

TSO+W/R PSO PGAS RMO Power +W/W +R/R +R/W +NSA

Very strange (and not in this talk): Out-of-thin-air values — arise when threads consistently lie to each other

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 8 / 32

slide-39
SLIDE 39

Lines of Research

Consistency models Axiomatic, programming language (herd) for consistency models (Alglave)

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 9 / 32

slide-40
SLIDE 40

Lines of Research

Consistency models Axiomatic, programming language (herd) for consistency models (Alglave) Geo-replicated consistency Conflict-free replicated data types (Shapiro)

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 9 / 32

slide-41
SLIDE 41

Lines of Research

Consistency models Axiomatic, programming language (herd) for consistency models (Alglave) Geo-replicated consistency Conflict-free replicated data types (Shapiro) C++11 Compilation (COMPCERT, ADVENT)

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 9 / 32

slide-42
SLIDE 42

Lines of Research

Consistency models Axiomatic, programming language (herd) for consistency models (Alglave) Geo-replicated consistency Conflict-free replicated data types (Shapiro) C++11 Compilation (COMPCERT, ADVENT) Linearizability Semantics and algorithmics (Paderborn, Paris, Uppsala)

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 9 / 32

slide-43
SLIDE 43

Lines of Research

Consistency models Axiomatic, programming language (herd) for consistency models (Alglave) Geo-replicated consistency Conflict-free replicated data types (Shapiro) C++11 Compilation (COMPCERT, ADVENT) Linearizability Semantics and algorithmics (Paderborn, Paris, Uppsala) Verification under relaxed consistency models Reachability and robustness (Paris, Uppsala, MSR, KL)

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 9 / 32

slide-44
SLIDE 44

Memory Consistency Models: TSO and SC

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 10 / 32

slide-45
SLIDE 45

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) Replication and Consistency IFIP WG 2.2 09/2016 11 / 32

slide-46
SLIDE 46

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) Replication and Consistency IFIP WG 2.2 09/2016 12 / 32

slide-47
SLIDE 47

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

isu · w(x, 1)

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 12 / 32

slide-48
SLIDE 48

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

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

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 12 / 32

slide-49
SLIDE 49

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

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

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 12 / 32

slide-50
SLIDE 50

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!

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

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 12 / 32

slide-51
SLIDE 51

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) Replication and Consistency IFIP WG 2.2 09/2016 13 / 32

slide-52
SLIDE 52

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) Replication and Consistency IFIP WG 2.2 09/2016 14 / 32

slide-53
SLIDE 53

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) Replication and Consistency IFIP WG 2.2 09/2016 14 / 32

slide-54
SLIDE 54

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) Replication and Consistency IFIP WG 2.2 09/2016 14 / 32

slide-55
SLIDE 55

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) Replication and Consistency IFIP WG 2.2 09/2016 14 / 32

slide-56
SLIDE 56

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) Replication and Consistency IFIP WG 2.2 09/2016 14 / 32

slide-57
SLIDE 57

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) Replication and Consistency IFIP WG 2.2 09/2016 14 / 32

slide-58
SLIDE 58

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) Replication and Consistency IFIP WG 2.2 09/2016 14 / 32

slide-59
SLIDE 59

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) Replication and Consistency IFIP WG 2.2 09/2016 14 / 32

slide-60
SLIDE 60

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) Replication and Consistency IFIP WG 2.2 09/2016 14 / 32

slide-61
SLIDE 61

Verification Required?!

Relaxed executions may lead to bad behavior

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 15 / 32

slide-62
SLIDE 62

Verification Required?!

Relaxed executions may lead to bad behavior

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

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 15 / 32

slide-63
SLIDE 63

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) Replication and Consistency IFIP WG 2.2 09/2016 15 / 32

slide-64
SLIDE 64

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) Replication and Consistency IFIP WG 2.2 09/2016 15 / 32

slide-65
SLIDE 65

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) Replication and Consistency IFIP WG 2.2 09/2016 15 / 32

slide-66
SLIDE 66

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) Replication and Consistency IFIP WG 2.2 09/2016 15 / 32

slide-67
SLIDE 67

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) Replication and Consistency IFIP WG 2.2 09/2016 15 / 32

slide-68
SLIDE 68

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) Replication and Consistency IFIP WG 2.2 09/2016 15 / 32

slide-69
SLIDE 69

Reachability

[MSR, Oxford, Paris, Uppsala]

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 16 / 32

slide-70
SLIDE 70

State Reachability Problem

Consider a memory model MM State Reachability Problem for MM Input: Program P and a (control + memory) state s. Problem: Is s reachable when P is run under MM?

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 17 / 32

slide-71
SLIDE 71

State Reachability Problem

Consider a memory model MM State Reachability Problem for MM Input: Program P and a (control + memory) state s. Problem: Is s reachable when P is run under MM? Decidability / Complexity ? Each thread is finite-state For the SC memory model, this problem is PSPACE-complete

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 17 / 32

slide-72
SLIDE 72

State Reachability Problem

Consider a memory model MM State Reachability Problem for MM Input: Program P and a (control + memory) state s. Problem: Is s reachable when P is run under MM? Decidability / Complexity ? Each thread is finite-state For the SC memory model, this problem is PSPACE-complete Non-trivial for relaxed memory models: PathsTSO(P) = ClosureTSO(PathsSC(P)) is non-regular

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 17 / 32

slide-73
SLIDE 73

Robustness

[IMDEA, Oxford, Paris, Uppsala] [ICALP’11, ESOP’13, ICALP’14, ACM TECS’15]

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 18 / 32

slide-74
SLIDE 74

Robustness

[IMDEA, Oxford, Paris, Uppsala] [ICALP’11, ESOP’13, ICALP’14, ACM TECS’15]

Decision procedure for robustness that

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 18 / 32

slide-75
SLIDE 75

Robustness

[IMDEA, Oxford, Paris, Uppsala] [ICALP’11, ESOP’13, ICALP’14, ACM TECS’15]

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

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 18 / 32

slide-76
SLIDE 76

Robustness

[IMDEA, Oxford, Paris, Uppsala] [ICALP’11, ESOP’13, ICALP’14, ACM TECS’15]

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

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 18 / 32

slide-77
SLIDE 77

Robustness

[IMDEA, Oxford, Paris, Uppsala] [ICALP’11, ESOP’13, ICALP’14, ACM TECS’15]

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) Replication and Consistency IFIP WG 2.2 09/2016 18 / 32

slide-78
SLIDE 78

Robustness

Idea: SC semantics is specification

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 19 / 32

slide-79
SLIDE 79

Robustness

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

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 19 / 32

slide-80
SLIDE 80

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) Replication and Consistency IFIP WG 2.2 09/2016 19 / 32

slide-81
SLIDE 81

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) Replication and Consistency IFIP WG 2.2 09/2016 19 / 32

slide-82
SLIDE 82

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) Replication and Consistency IFIP WG 2.2 09/2016 19 / 32

slide-83
SLIDE 83

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) Replication and Consistency IFIP WG 2.2 09/2016 19 / 32

slide-84
SLIDE 84

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) Replication and Consistency IFIP WG 2.2 09/2016 19 / 32

slide-85
SLIDE 85

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) Replication and Consistency IFIP WG 2.2 09/2016 19 / 32

slide-86
SLIDE 86

Robustness: General Solution

RMM-computations Robust Computations Minimal Violations = ∅ ?

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 20 / 32

slide-87
SLIDE 87

Robustness: General Solution

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

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 20 / 32

slide-88
SLIDE 88

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) Replication and Consistency IFIP WG 2.2 09/2016 20 / 32

slide-89
SLIDE 89

Robustness: General Solution

Together: Reduce robustness to an emptiness check Lnf ∩ Rcyc

?

= ∅.

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 21 / 32

slide-90
SLIDE 90

Robustness: General Solution

Together: Reduce robustness to an emptiness check Lnf ∩ Rcyc

?

= ∅. Combinatorics:

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 21 / 32

slide-91
SLIDE 91

Robustness: General Solution

Together: Reduce robustness to an emptiness check Lnf ∩ Rcyc

?

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

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 21 / 32

slide-92
SLIDE 92

Robustness: General Solution

Together: 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) Replication and Consistency IFIP WG 2.2 09/2016 21 / 32

slide-93
SLIDE 93

Robustness: General Solution

Together: 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) Replication and Consistency IFIP WG 2.2 09/2016 21 / 32

slide-94
SLIDE 94

Robustness: General Solution

Together: 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) Replication and Consistency IFIP WG 2.2 09/2016 21 / 32

slide-95
SLIDE 95

Robustness: General Solution

Together: 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) Replication and Consistency IFIP WG 2.2 09/2016 21 / 32

slide-96
SLIDE 96

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) Replication and Consistency IFIP WG 2.2 09/2016 22 / 32

slide-97
SLIDE 97

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) Replication and Consistency IFIP WG 2.2 09/2016 23 / 32

slide-98
SLIDE 98

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) Replication and Consistency IFIP WG 2.2 09/2016 23 / 32

slide-99
SLIDE 99

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) Replication and Consistency IFIP WG 2.2 09/2016 23 / 32

slide-100
SLIDE 100

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) Replication and Consistency IFIP WG 2.2 09/2016 23 / 32

slide-101
SLIDE 101

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) Replication and Consistency IFIP WG 2.2 09/2016 23 / 32

slide-102
SLIDE 102

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) Replication and Consistency IFIP WG 2.2 09/2016 23 / 32

slide-103
SLIDE 103

Combinatorics: Normal Form Violations

Normal Form:

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 24 / 32

slide-104
SLIDE 104

Combinatorics: Normal Form Violations

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

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 24 / 32

slide-105
SLIDE 105

Combinatorics: Normal Form Violations

Normal Form: Computation has two parts τ = τ1 · τ2 No delays within a part

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 24 / 32

slide-106
SLIDE 106

Combinatorics: Normal Form Violations

Normal Form: Computation has two parts τ = τ1 · τ2 No delays within a part Delays in τ2 respect ordering in τ1

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 24 / 32

slide-107
SLIDE 107

Combinatorics: Normal Form Violations

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

τ1

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

τ2

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 24 / 32

slide-108
SLIDE 108

Combinatorics: Normal Form Violations

Normal Form: Computation has two parts τ = τ1 · τ2 No delays within a part 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) Replication and Consistency IFIP WG 2.2 09/2016 24 / 32

slide-109
SLIDE 109

Combinatorics: Normal Form Violations

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

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 25 / 32

slide-110
SLIDE 110

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) Replication and Consistency IFIP WG 2.2 09/2016 25 / 32

slide-111
SLIDE 111

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) Replication and Consistency IFIP WG 2.2 09/2016 25 / 32

slide-112
SLIDE 112

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) Replication and Consistency IFIP WG 2.2 09/2016 25 / 32

slide-113
SLIDE 113

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) Replication and Consistency IFIP WG 2.2 09/2016 25 / 32

slide-114
SLIDE 114

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) Replication and Consistency IFIP WG 2.2 09/2016 25 / 32

slide-115
SLIDE 115

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) Replication and Consistency IFIP WG 2.2 09/2016 25 / 32

slide-116
SLIDE 116

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) Replication and Consistency IFIP WG 2.2 09/2016 25 / 32

slide-117
SLIDE 117

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) Replication and Consistency IFIP WG 2.2 09/2016 25 / 32

slide-118
SLIDE 118

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) Replication and Consistency IFIP WG 2.2 09/2016 26 / 32

slide-119
SLIDE 119

Algorithmics: Generating Normal-Form Computations

Challenge Describe language Lnf of all normal-form computations

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 27 / 32

slide-120
SLIDE 120

Algorithmics: Generating Normal-Form Computations

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

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 27 / 32

slide-121
SLIDE 121

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) Replication and Consistency IFIP WG 2.2 09/2016 27 / 32

slide-122
SLIDE 122

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) Replication and Consistency IFIP WG 2.2 09/2016 27 / 32

slide-123
SLIDE 123

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) Replication and Consistency IFIP WG 2.2 09/2016 27 / 32

slide-124
SLIDE 124

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) Replication and Consistency IFIP WG 2.2 09/2016 27 / 32

slide-125
SLIDE 125

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) Replication and Consistency IFIP WG 2.2 09/2016 27 / 32

slide-126
SLIDE 126

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(xi, 1)n

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 27 / 32

slide-127
SLIDE 127

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(xi, 1)n ⇒ not context-free (language σ · σ)

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 27 / 32

slide-128
SLIDE 128

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) Replication and Consistency IFIP WG 2.2 09/2016 28 / 32

slide-129
SLIDE 129

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) Replication and Consistency IFIP WG 2.2 09/2016 28 / 32

slide-130
SLIDE 130

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) Replication and Consistency IFIP WG 2.2 09/2016 28 / 32

slide-131
SLIDE 131

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) Replication and Consistency IFIP WG 2.2 09/2016 28 / 32

slide-132
SLIDE 132

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) Replication and Consistency IFIP WG 2.2 09/2016 28 / 32

slide-133
SLIDE 133

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) Replication and Consistency IFIP WG 2.2 09/2016 28 / 32

slide-134
SLIDE 134

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) Replication and Consistency IFIP WG 2.2 09/2016 28 / 32

slide-135
SLIDE 135

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) Replication and Consistency IFIP WG 2.2 09/2016 28 / 32

slide-136
SLIDE 136

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) Replication and Consistency IFIP WG 2.2 09/2016 28 / 32

slide-137
SLIDE 137

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) Replication and Consistency IFIP WG 2.2 09/2016 28 / 32

slide-138
SLIDE 138

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) Replication and Consistency IFIP WG 2.2 09/2016 28 / 32

slide-139
SLIDE 139

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) Replication and Consistency IFIP WG 2.2 09/2016 28 / 32

slide-140
SLIDE 140

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) Replication and Consistency IFIP WG 2.2 09/2016 29 / 32

slide-141
SLIDE 141

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) Replication and Consistency IFIP WG 2.2 09/2016 30 / 32

slide-142
SLIDE 142

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) Replication and Consistency IFIP WG 2.2 09/2016 30 / 32

slide-143
SLIDE 143

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) Replication and Consistency IFIP WG 2.2 09/2016 30 / 32

slide-144
SLIDE 144

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) Replication and Consistency IFIP WG 2.2 09/2016 30 / 32

slide-145
SLIDE 145

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) Replication and Consistency IFIP WG 2.2 09/2016 30 / 32

slide-146
SLIDE 146

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) Replication and Consistency IFIP WG 2.2 09/2016 31 / 32

slide-147
SLIDE 147

Algorithmics: Emptiness

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

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 32 / 32

slide-148
SLIDE 148

Algorithmics: Emptiness

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

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 32 / 32

slide-149
SLIDE 149

Algorithmics: Emptiness

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

?

= ∅.

Roland Meyer (TU KL) Replication and Consistency IFIP WG 2.2 09/2016 32 / 32

slide-150
SLIDE 150

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) Replication and Consistency IFIP WG 2.2 09/2016 32 / 32