Effective Abstractions for Verification under Relaxed Memory Models - - PowerPoint PPT Presentation

effective abstractions for verification under relaxed
SMART_READER_LITE
LIVE PREVIEW

Effective Abstractions for Verification under Relaxed Memory Models - - PowerPoint PPT Presentation

Effective Abstractions for Verification under Relaxed Memory Models Andrei Dan Yuri Meshman Martin Vechev Eran Yahav ETH Zurich Technion ETH Zurich Technion 1 Dekkers Algorithm initial: flag[0] = false, flag[1] = false, turn = 0


slide-1
SLIDE 1

Effective Abstractions for Verification under Relaxed Memory Models

Andrei Dan ETH Zurich Yuri Meshman Technion Martin Vechev ETH Zurich Eran Yahav Technion

1

slide-2
SLIDE 2

Dekker’s Algorithm

initial: flag[0] = false, flag[1] = false, turn = 0 Thread 0: flag[0] := true Thread 1: flag[1] := true Spec: mutual exclusion over Critical Section while (flag[1] = true) if (turn ≠ 0) flag[0] := false while (turn ≠ 0) { } flag[0] := true while (flag[0] = true) if (turn ≠ 1) flag[1] := false while (turn ≠ 1) { } flag[1] := true /* Critical Section */ /* Critical Section */

2

slide-3
SLIDE 3

Dekker’s Algorithm

initial: flag[0] = false, flag[1] = false, turn = 0 Thread 0: flag[0] := true Thread 1: flag[1] := true Spec: mutual exclusion over Critical Section

Sequential Consistency

while (flag[1] = true) if (turn ≠ 0) flag[0] := false while (turn ≠ 0) { } flag[0] := true while (flag[0] = true) if (turn ≠ 1) flag[1] := false while (turn ≠ 1) { } flag[1] := true /* Critical Section */ /* Critical Section */

2

slide-4
SLIDE 4

Dekker’s Algorithm

initial: flag[0] = false, flag[1] = false, turn = 0 Thread 0: flag[0] := true Thread 1: flag[1] := true Spec: mutual exclusion over Critical Section

Sequential Consistency

while (flag[1] = true) if (turn ≠ 0) flag[0] := false while (turn ≠ 0) { } flag[0] := true while (flag[0] = true) if (turn ≠ 1) flag[1] := false while (turn ≠ 1) { } flag[1] := true /* Critical Section */ /* Critical Section */

2

slide-5
SLIDE 5

Dekker’s Algorithm

initial: flag[0] = false, flag[1] = false, turn = 0 Thread 0: flag[0] := true Thread 1: flag[1] := true Spec: mutual exclusion over Critical Section

Sequential Consistency Relaxed Model x86 TSO

while (flag[1] = true) if (turn ≠ 0) flag[0] := false while (turn ≠ 0) { } flag[0] := true while (flag[0] = true) if (turn ≠ 1) flag[1] := false while (turn ≠ 1) { } flag[1] := true /* Critical Section */ /* Critical Section */

2

slide-6
SLIDE 6

Dekker’s Algorithm

initial: flag[0] = false, flag[1] = false, turn = 0 Thread 0: flag[0] := true Thread 1: flag[1] := true Spec: mutual exclusion over Critical Section

Sequential Consistency Relaxed Model x86 TSO

while (flag[1] = true) if (turn ≠ 0) flag[0] := false while (turn ≠ 0) { } flag[0] := true while (flag[0] = true) if (turn ≠ 1) flag[1] := false while (turn ≠ 1) { } flag[1] := true /* Critical Section */ /* Critical Section */

2

slide-7
SLIDE 7

Dekker’s Algorithm

initial: flag[0] = false, flag[1] = false, turn = 0 Thread 0: flag[0] := true Thread 1: flag[1] := true Spec: mutual exclusion over Critical Section

Sequential Consistency Relaxed Model x86 TSO

while (flag[1] = true) if (turn ≠ 0) flag[0] := false while (turn ≠ 0) { } flag[0] := true while (flag[0] = true) if (turn ≠ 1) flag[1] := false while (turn ≠ 1) { } flag[1] := true /* Critical Section */ /* Critical Section */

2

slide-8
SLIDE 8

Correct Dekker’s Algorithm

initial: flag[0] = false, flag[1] = false, turn = 0 Thread 0: flag[0] := true fence Thread 1: flag[1] := true fence Spec: mutual exclusion over Critical Section

Relaxed Model x86 TSO

while (flag[1] = true) if (turn ≠ 0) flag[0] := false while (turn ≠ 0) { } flag[0] := true fence while (flag[0] = true) if (turn ≠ 1) flag[1] := false while (turn ≠ 1) { } flag[1] := true fence /* Critical Section */ /* Critical Section */

3

slide-9
SLIDE 9

Correct Dekker’s Algorithm

initial: flag[0] = false, flag[1] = false, turn = 0 Thread 0: flag[0] := true fence Thread 1: flag[1] := true fence Spec: mutual exclusion over Critical Section

Relaxed Model x86 TSO

while (flag[1] = true) if (turn ≠ 0) flag[0] := false while (turn ≠ 0) { } flag[0] := true fence while (flag[0] = true) if (turn ≠ 1) flag[1] := false while (turn ≠ 1) { } flag[1] := true fence /* Critical Section */ /* Critical Section */

3

slide-10
SLIDE 10

This work

Concurrent Program P Memory Model M Specification S

slide-11
SLIDE 11

This work

Concurrent Program P Memory Model M Specification S Concurrent Program PM Source-to-source translation

slide-12
SLIDE 12

This work

Concurrent Program P Memory Model M Specification S Concurrent Program PM Program invariants Source-to-source translation Abstract interpreter for sequential consistency

slide-13
SLIDE 13

This work

Concurrent Program P Memory Model M Specification S Concurrent Program PM Program invariants Source-to-source translation Abstract interpreter for sequential consistency SMT Solver

slide-14
SLIDE 14

This work

Abstraction-aware translation Concurrent Program P Memory Model M Specification S Concurrent Program PM Program invariants Source-to-source translation Abstract interpreter for sequential consistency SMT Solver

slide-15
SLIDE 15

Talk outline

Direct translation [SAS ‘14] Abstraction-aware translation:

  • 1. Leverage more refined abstract domain
  • 2. Buffer semantics without shifting [Abstraction]

Evaluation

5

slide-16
SLIDE 16

Direct translation for x86 TSO [SAS ‘14]

6

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence Write Buffer 0: Shared Memory:

X = 0 Y = 0

slide-17
SLIDE 17

Direct translation for x86 TSO [SAS ‘14]

7

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

slide-18
SLIDE 18

Direct translation for x86 TSO [SAS ‘14]

7

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence lhs1 := ‘X’; rhs1 := 1; cnt := cnt + 1 X := 1 translated to Introduce 2 local variables in Thread 0 to encode each location of the finite buffer. Introduce a variable cnt. It represents the number of elements in the buffer: {0 .. k}.

slide-19
SLIDE 19

Direct translation for x86 TSO [SAS ‘14]

8

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

slide-20
SLIDE 20

Direct translation for x86 TSO [SAS ‘14]

8

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence Write Buffer 0: Shared Memory:

X = 0 Y = 0

Establish a limit k for the size of the buffers for each thread. For example k = 3. Sound abstraction.

X := 1

slide-21
SLIDE 21

Direct translation for x86 TSO [SAS ‘14]

9

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

slide-22
SLIDE 22

Direct translation for x86 TSO [SAS ‘14]

9

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

Flush Flush Flush Flush

slide-23
SLIDE 23

Direct translation for x86 TSO [SAS ‘14]

10

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

slide-24
SLIDE 24

Direct translation for x86 TSO [SAS ‘14]

10

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence while (cnt > 0 ∧ random) do if (lhs1 = ‘X’) then X := rhs1; if (lhs1 = ‘Y’) then Y := rhs1; cnt := cnt – 1 Flush translated to

slide-25
SLIDE 25

Direct translation for x86 TSO [SAS ‘14]

11

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

slide-26
SLIDE 26

Direct translation for x86 TSO [SAS ‘14]

11

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence if (cnt ≥ 1 ∧ lhs1 = ‘X’) then a := rhs1; else a := X; a := X translated to

slide-27
SLIDE 27

Analysis with the direct translation

12

lhs1 := ‘X’; rhs1 := 1; cnt := cnt + 1 X := 1 translated to while (cnt > 0 ∧ random) do if (lhs1 = ‘X’) then X := rhs1; if (lhs1 = ‘Y’) then Y := rhs1; cnt := cnt – 1 Flush translated to if (cnt ≥ 1 ∧ lhs1 = ‘X’) then a := rhs1; else a := X; a := X translated to Direct Translation: Numerical abstract interpretation: Original program:

slide-28
SLIDE 28

Analysis with the direct translation

12

lhs1 := ‘X’; rhs1 := 1; cnt := cnt + 1 X := 1 translated to while (cnt > 0 ∧ random) do if (lhs1 = ‘X’) then X := rhs1; if (lhs1 = ‘Y’) then Y := rhs1; cnt := cnt – 1 Flush translated to if (cnt ≥ 1 ∧ lhs1 = ‘X’) then a := rhs1; else a := X; a := X translated to Direct Translation: Numerical abstract interpretation: Original program: lhs1 = ‘X’ ∧ rhs1 = 1 ∧ cnt = 1 ∧ X = 0

slide-29
SLIDE 29

Analysis with the direct translation

12

lhs1 := ‘X’; rhs1 := 1; cnt := cnt + 1 X := 1 translated to while (cnt > 0 ∧ random) do if (lhs1 = ‘X’) then X := rhs1; if (lhs1 = ‘Y’) then Y := rhs1; cnt := cnt – 1 Flush translated to if (cnt ≥ 1 ∧ lhs1 = ‘X’) then a := rhs1; else a := X; a := X translated to Direct Translation: Numerical abstract interpretation: Original program: lhs1 = ‘X’ ∧ rhs1 = 1 ∧ cnt = 1 ∧ X = 0 lhs1 = ‘X’ ∧ rhs1 = 1 ∧ cnt = [0, 1] ∧ X = [0, 1]

slide-30
SLIDE 30

Analysis with the direct translation

12

lhs1 := ‘X’; rhs1 := 1; cnt := cnt + 1 X := 1 translated to while (cnt > 0 ∧ random) do if (lhs1 = ‘X’) then X := rhs1; if (lhs1 = ‘Y’) then Y := rhs1; cnt := cnt – 1 Flush translated to if (cnt ≥ 1 ∧ lhs1 = ‘X’) then a := rhs1; else a := X; a := X translated to Direct Translation: Numerical abstract interpretation: Original program: lhs1 = ‘X’ ∧ rhs1 = 1 ∧ cnt = 1 ∧ X = 0 lhs1 = ‘X’ ∧ rhs1 = 1 ∧ cnt = [0, 1] ∧ X = [0, 1] lhs1 = ‘X’ ∧ rhs1 = 1 ∧ cnt = [0, 1] ∧ X = [0, 1] ∧ a = [0, 1]

slide-31
SLIDE 31

Analysis with the direct translation

12

lhs1 := ‘X’; rhs1 := 1; cnt := cnt + 1 X := 1 translated to while (cnt > 0 ∧ random) do if (lhs1 = ‘X’) then X := rhs1; if (lhs1 = ‘Y’) then Y := rhs1; cnt := cnt – 1 Flush translated to if (cnt ≥ 1 ∧ lhs1 = ‘X’) then a := rhs1; else a := X; a := X translated to Problem: The analysis loses precision due to joins in the non-deterministic Flush. Direct Translation: Numerical abstract interpretation: Original program: lhs1 = ‘X’ ∧ rhs1 = 1 ∧ cnt = 1 ∧ X = 0 lhs1 = ‘X’ ∧ rhs1 = 1 ∧ cnt = [0, 1] ∧ X = [0, 1] lhs1 = ‘X’ ∧ rhs1 = 1 ∧ cnt = [0, 1] ∧ X = [0, 1] ∧ a = [0, 1]

slide-32
SLIDE 32

Talk outline

Direct translation [SAS ‘14] Abstraction-aware translation:

  • 1. Leverage more refined abstract domain
  • 2. Buffer semantics without shifting [Abstraction]

Evaluation

13

Looses precision with flushes, cannot verify interesting concurrent algorithms.

slide-33
SLIDE 33

14

More refined Abstract Domain

Logico-numerical abstract domain

  • Concrete value is kept for the boolean variables
  • Abstract value is kept for the numerical variables
  • It allows disjunctions in the abstract states

Example: (b = true ∧ 2x + y ≥ 4) ∨ (b = false ∧ 3x - 2y ≥ 7)

slide-34
SLIDE 34

15

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

Abstraction-aware translation

slide-35
SLIDE 35

15

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence rhs1 := 1; bX1 := true; X := 1 translated to

Abstraction-aware translation

Abstraction-aware Translation: Direct Translation: lhs1 := ‘X’; rhs1 := 1; cnt := cnt + 1 Eliminate the cnt counter variable and the lhs1, lhs2 , lhs3 variables. Introduce boolean variables to replace cnt: bX1, bX2,bX3,bY1, bY2,bY3.

slide-36
SLIDE 36

16

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

Abstraction-aware translation

slide-37
SLIDE 37

16

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence while (( bX1 ∨bY1 ) ∧ random) do if (bX1) then X := rhs1; bX1 := false; if (bY1) then Y := rhs1; bY1 := false; Flush translated to

Abstraction-aware translation

Abstraction-aware Translation: while (cnt > 0 ∧ random) do if (lhs1 = ‘X’) then X := rhs1; if (lhs1 = ‘Y’) then Y := rhs1; cnt := cnt – 1 Direct Translation:

slide-38
SLIDE 38

17

Abstraction-aware translation

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

slide-39
SLIDE 39

17

Abstraction-aware translation

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence if (bX1) then a := rhs1; else a := X; a := X translated to Abstraction-aware Translation: if (cnt ≥ 1 ∧ lhs1 = ‘X’) then a := rhs1; else a := X; Direct Translation:

slide-40
SLIDE 40

18

Analysis with the abstraction-aware translation

X := 1 translated to Flush translated to a := X translated to rhs1 := 1; bX1 := true; while (( bX1 ∨ bY1 ) ∧ random ) do if (bX1) then X := rhs1; bX1 := false; if (bY1) then Y := rhs1; bY1 := false; if (bX1) then a := rhs1; else a := X; Abstraction-aware Translation: Numerical abstract interpretation: Original program:

slide-41
SLIDE 41

18

Analysis with the abstraction-aware translation

X := 1 translated to Flush translated to a := X translated to rhs1 := 1; bX1 := true; while (( bX1 ∨ bY1 ) ∧ random ) do if (bX1) then X := rhs1; bX1 := false; if (bY1) then Y := rhs1; bY1 := false; if (bX1) then a := rhs1; else a := X; Abstraction-aware Translation: Numerical abstract interpretation: Original program: bX1 = true ∧ rhs1 = 1 ∧ X = 0

slide-42
SLIDE 42

18

Analysis with the abstraction-aware translation

X := 1 translated to Flush translated to a := X translated to rhs1 := 1; bX1 := true; while (( bX1 ∨ bY1 ) ∧ random ) do if (bX1) then X := rhs1; bX1 := false; if (bY1) then Y := rhs1; bY1 := false; if (bX1) then a := rhs1; else a := X; Abstraction-aware Translation: Numerical abstract interpretation: Original program: bX1 = true ∧ rhs1 = 1 ∧ X = 0 (bX1 = true ∧ rhs1 = 1 ∧ X = 0) ∨ (bX1 = false ∧ rhs1 = 1 ∧ X = 1)

slide-43
SLIDE 43

18

Analysis with the abstraction-aware translation

X := 1 translated to Flush translated to a := X translated to rhs1 := 1; bX1 := true; while (( bX1 ∨ bY1 ) ∧ random ) do if (bX1) then X := rhs1; bX1 := false; if (bY1) then Y := rhs1; bY1 := false; if (bX1) then a := rhs1; else a := X; Abstraction-aware Translation: Numerical abstract interpretation: Original program: bX1 = true ∧ rhs1 = 1 ∧ X = 0 (bX1 = true ∧ rhs1 = 1 ∧ X = 0) ∨ (bX1 = false ∧ rhs1 = 1 ∧ X = 1) (bX1 = true ∧ rhs1 = 1 ∧ X = 0 ∧ a = 1) ∨ (bX1 = false ∧ rhs1 = 1 ∧ X = 1 ∧ a = 1)

slide-44
SLIDE 44

18

Analysis with the abstraction-aware translation

X := 1 translated to Flush translated to a := X translated to rhs1 := 1; bX1 := true; while (( bX1 ∨ bY1 ) ∧ random ) do if (bX1) then X := rhs1; bX1 := false; if (bY1) then Y := rhs1; bY1 := false; if (bX1) then a := rhs1; else a := X; Abstraction-aware Translation: Numerical abstract interpretation: Original program: bX1 = true ∧ rhs1 = 1 ∧ X = 0 (bX1 = true ∧ rhs1 = 1 ∧ X = 0) ∨ (bX1 = false ∧ rhs1 = 1 ∧ X = 1) (bX1 = true ∧ rhs1 = 1 ∧ X = 0 ∧ a = 1) ∨ (bX1 = false ∧ rhs1 = 1 ∧ X = 1 ∧ a = 1) ... ∧ rhs1 = 1 ∧ X = [0, 1] ∧ a = [0, 1] Invariant from Direct Translation:

slide-45
SLIDE 45

18

Analysis with the abstraction-aware translation

X := 1 translated to Flush translated to a := X translated to rhs1 := 1; bX1 := true; while (( bX1 ∨ bY1 ) ∧ random ) do if (bX1) then X := rhs1; bX1 := false; if (bY1) then Y := rhs1; bY1 := false; if (bX1) then a := rhs1; else a := X; Abstraction-aware Translation: Numerical abstract interpretation: Original program: bX1 = true ∧ rhs1 = 1 ∧ X = 0 (bX1 = true ∧ rhs1 = 1 ∧ X = 0) ∨ (bX1 = false ∧ rhs1 = 1 ∧ X = 1) (bX1 = true ∧ rhs1 = 1 ∧ X = 0 ∧ a = 1) ∨ (bX1 = false ∧ rhs1 = 1 ∧ X = 1 ∧ a = 1) ... ∧ rhs1 = 1 ∧ X = [0, 1] ∧ a = [0, 1] Invariant from Direct Translation:

slide-46
SLIDE 46

Flush with shifting

19

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

Y := 2 X := 0

slide-47
SLIDE 47

Flush with shifting

19

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

Y := 2 X := 0 Flush

slide-48
SLIDE 48

Flush with shifting

20

Write Buffer 0: Shared Memory:

X = 1 Y = 0

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

Y := 2 X := 0 Flush

slide-49
SLIDE 49

Flush with shifting

21

Write Buffer 0: Shared Memory:

X = 1 Y = 0

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

Y := 2 X := 0

Buffer shift

slide-50
SLIDE 50

Flush with shifting

22

Write Buffer 0: Shared Memory:

X = 1 Y = 0

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

Y := 2 X := 0

Buffer shift

slide-51
SLIDE 51

Flush with shifting

22

Write Buffer 0: Shared Memory:

X = 1 Y = 0

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

Y := 2 X := 0

Buffer shift while (( bX1 ∨bY1 ) ∧ random) do if (bX1) then X := rhs1; bX1 := false; if (bY1) then Y := rhs1; bY1 := false; if (bX2) then rhs1 := rhs2; bX1 := true; bX2 := false; if (bY2) then rhs1 := rhs2; bY1 := true; bY2 := false; if (bX3) then rhs2 := rhs3; bX2 := true; bX3 := false; if (bY3) then rhs2 := rhs3; bY2 := true; bY3 := false; Flush translated to

slide-52
SLIDE 52

Flush with shifting

22

Write Buffer 0: Shared Memory:

X = 1 Y = 0

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

Y := 2 X := 0

Buffer shift while (( bX1 ∨bY1 ) ∧ random) do if (bX1) then X := rhs1; bX1 := false; if (bY1) then Y := rhs1; bY1 := false; if (bX2) then rhs1 := rhs2; bX1 := true; bX2 := false; if (bY2) then rhs1 := rhs2; bY1 := true; bY2 := false; if (bX3) then rhs2 := rhs3; bX2 := true; bX3 := false; if (bY3) then rhs2 := rhs3; bY2 := true; bY3 := false; Flush translated to Buffer Shift

slide-53
SLIDE 53

Appears after each translated statement. Its complexity is due mostly to the buffer shifting operation Problem: This can lead to more work for the analysis and loss of precision.

23

Flush procedure

slide-54
SLIDE 54

Talk outline

Direct translation [SAS ‘14] Abstraction-aware translation:

  • 1. Leverage more refined abstract domain
  • 2. Buffer semantics without shifting [Abstraction]

Evaluation

24

slide-55
SLIDE 55

Flushing without shifting

25

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

Y := 2 X := 0

slide-56
SLIDE 56

Flushing without shifting

25

Write Buffer 0: Shared Memory:

X = 0 Y = 0 X := 1

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

Y := 2 X := 0 Flush

slide-57
SLIDE 57

Flushing without shifting

26

Write Buffer 0: Shared Memory:

X = 1 Y = 0

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

Y := 2 X := 0

slide-58
SLIDE 58

Flushing without shifting

26

Write Buffer 0: Shared Memory:

X = 1 Y = 0

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

Y := 2 X := 0 Flush

slide-59
SLIDE 59

Flushing without shifting

27

Write Buffer 0: Shared Memory:

X = 1 Y = 2

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

X := 0

slide-60
SLIDE 60

Flushing without shifting

27

Write Buffer 0: Shared Memory:

X = 1 Y = 2

Thread 0: X := 1 a := X Y := a + 1 X := a – 1 fence

X := 0

while (random) do if (bX1) then X := rhs1; bX1 := false; else if (bY1) then Y := rhs1; bY1 := false; else if (bX2) then X := rhs2; bX2 := false; else if (bY2) then Y := rhs2; bY2 := false; else if (bX3) then X := rhs3; bX3 := false; else if (bY3) then Y := rhs3; bY3 := false; Flush

translated to

slide-61
SLIDE 61

Flushing without shifting

Eliminating buffer shifting:

  • is sound
  • is an abstraction
  • may introduce additional cases of imprecision,

not the case for any of our benchmarks

28

slide-62
SLIDE 62

Comparing Translations

29

lhs1 := ‘X’; rhs1 := 1; cnt := cnt + 1 while (cnt > 0 ∧ random) do if (lhs1 = ‘X’) then X := rhs1; if (lhs1 = ‘Y’) then Y := rhs1; if (cnt > 1) then lhs1 := lhs2; rhs1 := rhs2; cnt := cnt – 1 if (cnt ≥ 1 ∧ lhs1 = ‘X’) then a := rhs1; else a := X; rhs1 := 1; bX1 := true; while (( bX1 ∨ bY1 ) ∧ random ) do if (bX1) then X := rhs1; bX1 := false; else if (bY1) then Y := rhs1; bY1 := false; else if (bX2) then X := rhs2; bX2 := false; else if (bY2) then Y := rhs2; bY2 := false; if (bX1) then a := rhs1; else a := X; X := 1 Flush

translated to

a := X

translated to translated to

Direct translation [SAS ‘14]: Abstraction-aware tr translation: Orig rigin inal program:

slide-63
SLIDE 63

30

Implementation

Eliminate buffer shifts Refined abstract domain Abstraction-aware translation Concurrent Program P X86 TSO, PSO Safety properties Concurrent Program PM Program invariants Source-to-source translation ConcurInterProc Z3 Solver

slide-64
SLIDE 64

Evaluation for x86 TSO

31

Abstraction-aware Translation Direct Translation [SAS ‘14] Program # Fences Time (sec) Memory (MB) # Fences Time (sec) Memory (MB) Abp 5 189 14 352 Bakery 4 1148 4749 8 3181 6575 Concloop 2 8 547 2 18 891 Dekker 4 227 2233 10 615 1004 Kessel 4 14 357 4 15 424 Queue 1 1 101 1 1 115 Szymanski 3 1066 3781 8 124 1770 WSQ THE 4 125 1646 6 t/o

  • WSQ Chase-Lev

2 17 550 4 30 789

slide-65
SLIDE 65

Evaluation for x86 TSO

31

Abstraction-aware Translation Direct Translation [SAS ‘14] Program # Fences Time (sec) Memory (MB) # Fences Time (sec) Memory (MB) Abp 5 189 14 352 Bakery 4 1148 4749 8 3181 6575 Concloop 2 8 547 2 18 891 Dekker 4 227 2233 10 615 1004 Kessel 4 14 357 4 15 424 Queue 1 1 101 1 1 115 Szymanski 3 1066 3781 8 124 1770 WSQ THE 4 125 1646 6 t/o

  • WSQ Chase-Lev

2 17 550 4 30 789

slide-66
SLIDE 66

In summary

32

Eliminate buffer shifts Refined abstract domain

Additional details: www.practicalsynthesis.org/fender

Abstraction-aware translation Concurrent Program P Memory Model M Specification S Concurrent Program PM Program invariants Source-to-source translation Abstract interpreter for sequential consistency SMT Solver