Race Analysis for SystemC using Model Checking Nicolas Blanc, - - PowerPoint PPT Presentation

race analysis for systemc using model checking
SMART_READER_LITE
LIVE PREVIEW

Race Analysis for SystemC using Model Checking Nicolas Blanc, - - PowerPoint PPT Presentation

Race Analysis for SystemC using Model Checking Nicolas Blanc, Daniel Kroening Outline Motivation Partial-Order Reduction Scoot Experimental Results D. Kroening: Race Analysis for SystemCusing Model Checking 2 Introduction Oxford is a


slide-1
SLIDE 1

Race Analysis for SystemC using Model Checking

Nicolas Blanc, Daniel Kroening

slide-2
SLIDE 2

Outline

Motivation Partial-Order Reduction Scoot Experimental Results

  • D. Kroening: Race Analysis for SystemCusing Model Checking

2

slide-3
SLIDE 3

Introduction

◮ Oxford is a major verification center:

9 full-time academics, 30+ post-docs

◮ My group

◮ 10 PhD students, 8 post-docs

(hiring 2 more)

◮ GBP 3m funding for verification

(industry, Artemis, FP7)

  • D. Kroening: Race Analysis for SystemCusing Model Checking

3

slide-4
SLIDE 4

High-Level Models

◮ Emergence of system design languages ◮ HardwareC, SpecC, Handel-C, and SystemC ◮ Based on C / C++ ◮ Allow joint modeling of both hardware and software

components of a system

◮ Support for bit vectors, concurrency, synchronization,

exception handling

  • D. Kroening: Race Analysis for SystemCusing Model Checking

4

slide-5
SLIDE 5

SystemC

◮ Based on C++

◮ No language extensions, but macros + library ◮ Simulation using regular C++ compiler

  • D. Kroening: Race Analysis for SystemCusing Model Checking

5

slide-6
SLIDE 6

SystemC

◮ Based on C++

◮ No language extensions, but macros + library ◮ Simulation using regular C++ compiler

SystemC Model SystemC Model SystemC Library SystemC Library

  • D. Kroening: Race Analysis for SystemCusing Model Checking

5

slide-7
SLIDE 7

SystemC

◮ Based on C++

◮ No language extensions, but macros + library ◮ Simulation using regular C++ compiler

SystemC Model SystemC Model SystemC Library SystemC Library Executable Executable

g++

  • D. Kroening: Race Analysis for SystemCusing Model Checking

5

slide-8
SLIDE 8

SystemC

◮ Based on C++

◮ No language extensions, but macros + library ◮ Simulation using regular C++ compiler

SystemC Model SystemC Model SystemC Library SystemC Library Executable Executable

g++

+ Stimulus = Traces

  • D. Kroening: Race Analysis for SystemCusing Model Checking

5

slide-9
SLIDE 9

SystemC

◮ Originally for fast, low-level circuit simulations

◮ Verilog-like multi-valued logic (0, 1, X, Z) ◮ Multiple drivers for a single signal

◮ Also offers

◮ Bit-vector types ◮ Fixed-point arithmetic ◮ Concurrency

◮ Parts of SystemC are synthesizable

  • D. Kroening: Race Analysis for SystemCusing Model Checking

6

slide-10
SLIDE 10

SystemC C/C++ Verilog/VHDL

  • D. Kroening: Race Analysis for SystemCusing Model Checking

7

slide-11
SLIDE 11

SystemC C/C++ Verilog/VHDL

  • D. Kroening: Race Analysis for SystemCusing Model Checking

7

slide-12
SLIDE 12

SystemC C/C++ Verilog/VHDL

Convenient modeling of both hardware and software

  • D. Kroening: Race Analysis for SystemCusing Model Checking

7

slide-13
SLIDE 13

Applications of SystemC

Possible applications:

◮ Hardware model for co-simulation of embedded software ◮ Synthesis of algorithms ◮ Can serve as high-level model for hardware,

in particular at the transaction level

  • D. Kroening: Race Analysis for SystemCusing Model Checking

8

slide-14
SLIDE 14

Concurrency in SystemC

◮ Asynchronous interleaving semantics

→ Thread schedule is non-deterministic

  • D. Kroening: Race Analysis for SystemCusing Model Checking

9

slide-15
SLIDE 15

Concurrency in SystemC

◮ Asynchronous interleaving semantics

→ Thread schedule is non-deterministic

◮ But: Interleaving only at specific locations

◮ wait() ◮ End of thread

→ No issues with atomicity → Does not really map onto usual pthread model

◮ Makes synthesis and model checking much easier!

  • D. Kroening: Race Analysis for SystemCusing Model Checking

9

slide-16
SLIDE 16

Concurrency in SystemC: Example (1) XX

Thread 1 Thread 2 Thread 3

x=10; wait (); y=20; (end) x++; (end) y++; (end)

Current state: x=0, y=0

  • D. Kroening: Race Analysis for SystemCusing Model Checking

10

slide-17
SLIDE 17

Concurrency in SystemC: Example (1) XX

Thread 1 Thread 2 Thread 3

x=10; wait (); y=20; (end) x++; (end) y++; (end)

Current state: x=10, y=0

  • D. Kroening: Race Analysis for SystemCusing Model Checking

10

slide-18
SLIDE 18

Concurrency in SystemC: Example (1) XX

Thread 1 Thread 2 Thread 3

x=10; wait (); y=20; (end) x++; (end) y++; (end)

Current state: x=10, y=0

  • D. Kroening: Race Analysis for SystemCusing Model Checking

10

slide-19
SLIDE 19

Concurrency in SystemC: Example (1) XX

Thread 1 Thread 2 Thread 3

x=10; wait (); y=20; (end) x++; (end) y++; (end)

Current state: x=10, y=20

  • D. Kroening: Race Analysis for SystemCusing Model Checking

10

slide-20
SLIDE 20

Concurrency in SystemC: Example (1) XX

Thread 1 Thread 2 Thread 3

x=10; wait (); y=20; (end) x++; (end) y++; (end)

Current state: x=11, y=20

  • D. Kroening: Race Analysis for SystemCusing Model Checking

10

slide-21
SLIDE 21

Concurrency in SystemC: Example (1) XX

Thread 1 Thread 2 Thread 3

x=10; wait (); y=20; (end) x++; (end) y++; (end)

Current state: x=11, y=21

  • D. Kroening: Race Analysis for SystemCusing Model Checking

10

slide-22
SLIDE 22

Concurrency in SystemC: Example (2) Alternative Schedule

Thread 1 Thread 2 Thread 3

x=10; wait (); y=20; (end) x++; (end) y++; (end)

Current state: x=0, y=0

  • D. Kroening: Race Analysis for SystemCusing Model Checking

11

slide-23
SLIDE 23

Concurrency in SystemC: Example (2) Alternative Schedule

Thread 1 Thread 2 Thread 3

x=10; wait (); y=20; (end) x++; (end) y++; (end)

Current state: x=10, y=0

  • D. Kroening: Race Analysis for SystemCusing Model Checking

11

slide-24
SLIDE 24

Concurrency in SystemC: Example (2) Alternative Schedule

Thread 1 Thread 2 Thread 3

x=10; wait (); y=20; (end) x++; (end) y++; (end)

Current state: x=11, y=0

  • D. Kroening: Race Analysis for SystemCusing Model Checking

11

slide-25
SLIDE 25

Concurrency in SystemC: Example (2) Alternative Schedule

Thread 1 Thread 2 Thread 3

x=10; wait (); y=20; (end) x++; (end) y++; (end)

Current state: x=11, y=1

  • D. Kroening: Race Analysis for SystemCusing Model Checking

11

slide-26
SLIDE 26

Concurrency in SystemC: Example (2) Alternative Schedule

Thread 1 Thread 2 Thread 3

x=10; wait (); y=20; (end) x++; (end) y++; (end)

Current state: x=11, y=1

  • D. Kroening: Race Analysis for SystemCusing Model Checking

11

slide-27
SLIDE 27

Concurrency in SystemC: Example (2) Alternative Schedule

Thread 1 Thread 2 Thread 3

x=10; wait (); y=20; (end) x++; (end) y++; (end)

Current state: x=11, y=20

  • D. Kroening: Race Analysis for SystemCusing Model Checking

11

slide-28
SLIDE 28

Concurrency in SystemC

◮ The example program has a race, i.e., the result depends

  • n the schedule
  • D. Kroening: Race Analysis for SystemCusing Model Checking

12

slide-29
SLIDE 29

Concurrency in SystemC

◮ The example program has a race, i.e., the result depends

  • n the schedule

◮ Standard: thread schedule non-deterministic,

but must be consistent between simulation runs → many programmers don’t care about those races

  • D. Kroening: Race Analysis for SystemCusing Model Checking

12

slide-30
SLIDE 30

Concurrency in SystemC

◮ The example program has a race, i.e., the result depends

  • n the schedule

◮ Standard: thread schedule non-deterministic,

but must be consistent between simulation runs → many programmers don’t care about those races

◮ But: source of error, and simulation/synthesis differences

  • D. Kroening: Race Analysis for SystemCusing Model Checking

12

slide-31
SLIDE 31

Concurrency in SystemC

◮ The example program has a race, i.e., the result depends

  • n the schedule

◮ Standard: thread schedule non-deterministic,

but must be consistent between simulation runs → many programmers don’t care about those races

◮ But: source of error, and simulation/synthesis differences ◮ SystemC offers synchronization constructs to make the

schedule deterministic

◮ Explicit events ◮ FIFOs ◮ ...

  • D. Kroening: Race Analysis for SystemCusing Model Checking

12

slide-32
SLIDE 32

Concurrency in High-Level Modeling

How about concurrency in high-level models?

  • D. Kroening: Race Analysis for SystemCusing Model Checking

13

slide-33
SLIDE 33

Concurrency in High-Level Modeling

How about concurrency in high-level models?

FIFO

✲ ✲

  • D. Kroening: Race Analysis for SystemCusing Model Checking

13

slide-34
SLIDE 34

Concurrency in High-Level Modeling

How about concurrency in high-level models?

FIFO

✲ ✲

CLK 1 CLK 2

  • D. Kroening: Race Analysis for SystemCusing Model Checking

13

slide-35
SLIDE 35

Concurrency in High-Level Modeling

How about concurrency in high-level models?

FIFO

✲ ✲

CLK 1 CLK 2

◮ The ordering of events is crucial ◮ We want the schedule to be non-deterministic! ◮ Similar: bus systems, arbiters, ...

  • D. Kroening: Race Analysis for SystemCusing Model Checking

13

slide-36
SLIDE 36

Hunting Schedule-Related Bugs

Goal: explore multiple schedules to find schedule-related bugs

◮ Often done by means of “random” waits ◮ Not promising due to exponential number of schedules

  • D. Kroening: Race Analysis for SystemCusing Model Checking

14

slide-37
SLIDE 37

Hunting Schedule-Related Bugs

Goal: explore multiple schedules to find schedule-related bugs

◮ Often done by means of “random” waits ◮ Not promising due to exponential number of schedules ◮ Alternative: try to explore relevant schedules exhaustively

  • D. Kroening: Race Analysis for SystemCusing Model Checking

14

slide-38
SLIDE 38

Hunting Schedule-Related Bugs

“Relevant” schedules?

  • D. Kroening: Race Analysis for SystemCusing Model Checking

15

slide-39
SLIDE 39

Hunting Schedule-Related Bugs

“Relevant” schedules? Observation: Thread 1 Thread 2 Thread 3

x=10; wait (); y=20; (end) x++; (end) y++; (end)

The relative ordering of thread 2 and thread 3 is irrelevant for the state that is finally reached!

  • D. Kroening: Race Analysis for SystemCusing Model Checking

15

slide-40
SLIDE 40

Commutativity of Transitions

Key observation:

x++ and y++ are commutative ⑦ ♥

s1

  • D. Kroening: Race Analysis for SystemCusing Model Checking

16

slide-41
SLIDE 41

Commutativity of Transitions

Key observation:

x++ and y++ are commutative ✁ ✁ ✁ ✁ ☛ ⑦ ♥

s1

⑦ ♥

s2

x++

  • D. Kroening: Race Analysis for SystemCusing Model Checking

16

slide-42
SLIDE 42

Commutativity of Transitions

Key observation:

x++ and y++ are commutative ✁ ✁ ✁ ✁ ☛ ❆ ❆ ❆ ❆ ❯ ⑦ ♥

s1

⑦ ♥

s2

⑦ ♥

s3

x++ y++

  • D. Kroening: Race Analysis for SystemCusing Model Checking

16

slide-43
SLIDE 43

Commutativity of Transitions

Key observation:

x++ and y++ are commutative ✁ ✁ ✁ ✁ ☛ ❆ ❆ ❆ ❆ ❯ ❆ ❆ ❆ ❆ ❯ ⑦ ♥

s1

⑦ ♥

s2

⑦ ♥

s4

⑦ ♥

s3

x++ y++ y++

  • D. Kroening: Race Analysis for SystemCusing Model Checking

16

slide-44
SLIDE 44

Commutativity of Transitions

Key observation:

x++ and y++ are commutative ✁ ✁ ✁ ✁ ☛ ❆ ❆ ❆ ❆ ❯ ❆ ❆ ❆ ❆ ❯ ✁ ✁ ✁ ✁ ☛ ⑦ ♥

s1

⑦ ♥

s2

⑦ ♥

s4

⑦ ♥

s3

x++ y++ x++ y++

  • D. Kroening: Race Analysis for SystemCusing Model Checking

16

slide-45
SLIDE 45

Commutativity of Transitions

Key observation:

x++ and y++ are commutative ✁ ✁ ✁ ✁ ☛ ✁ ✁ ✁ ✁ ☛ ❆ ❆ ❆ ❆ ❯ ❆ ❆ ❆ ❆ ❯ ❆ ❆ ❆ ❆ ❯ ✁ ✁ ✁ ✁ ☛ ⑦ ♥

s1

⑦ ♥

s2

⑦ ♥

s4

⑦ ♥

s3

x++ y++ x++ y++

Idea: explore only one of the paths This often results in an exponential reduction!

  • D. Kroening: Race Analysis for SystemCusing Model Checking

16

slide-46
SLIDE 46

Partial-Order Reduction: Notation

Partial-Order Reduction is a formalization of this idea. We first define what it means for two threads to be independent.

Definition (Transition System)

Triple (S, S0, →) where

◮ S: Set of states, ◮ S0 ⊂ S: set of initial states, ◮ →: set of transitions

A transition α ∈→ is a relation on S. We write s α → t if (s, t) ∈ α.

  • D. Kroening: Race Analysis for SystemCusing Model Checking

17

slide-47
SLIDE 47

Partial-Order Reduction: Notation

Thread 1 Thread 2 Thread 3

x=10; wait (); y=20; (end) x++; (end) y++; (end)

◮ Set of states: values of x and y ◮ Set of initial states: {(0, 0)} ◮ Transitions?

  • D. Kroening: Race Analysis for SystemCusing Model Checking

18

slide-48
SLIDE 48

Partial-Order Reduction: Notation

Thread 1 Thread 2 Thread 3

α1

x=10; wait (); y=20; (end) x++; (end) y++; (end)

◮ Set of states: values of x and y ◮ Set of initial states: {(0, 0)} ◮ Transitions?

  • D. Kroening: Race Analysis for SystemCusing Model Checking

18

slide-49
SLIDE 49

Partial-Order Reduction: Notation

Thread 1 Thread 2 Thread 3

α1 α2

x=10; wait (); y=20; (end) x++; (end) y++; (end)

◮ Set of states: values of x and y ◮ Set of initial states: {(0, 0)} ◮ Transitions?

  • D. Kroening: Race Analysis for SystemCusing Model Checking

18

slide-50
SLIDE 50

Partial-Order Reduction: Notation

Thread 1 Thread 2 Thread 3

α1 α2 α3

x=10; wait (); y=20; (end) x++; (end) y++; (end)

◮ Set of states: values of x and y ◮ Set of initial states: {(0, 0)} ◮ Transitions?

  • D. Kroening: Race Analysis for SystemCusing Model Checking

18

slide-51
SLIDE 51

Partial-Order Reduction: Notation

Thread 1 Thread 2 Thread 3

α1 α2 α3 α4

x=10; wait (); y=20; (end) x++; (end) y++; (end)

◮ Set of states: values of x and y ◮ Set of initial states: {(0, 0)} ◮ Transitions?

  • D. Kroening: Race Analysis for SystemCusing Model Checking

18

slide-52
SLIDE 52

Partial-Order Reduction: Independence

Extra complication: Transitions may be enabled (or not). E.g., a transition may be sensitive to a clock edge. We write α ∈ Enabled(s) if ∃t. s α → t.

  • D. Kroening: Race Analysis for SystemCusing Model Checking

19

slide-53
SLIDE 53

Partial-Order Reduction: Independence

Extra complication: Transitions may be enabled (or not). E.g., a transition may be sensitive to a clock edge. We write α ∈ Enabled(s) if ∃t. s α → t.

Definition (Independence)

Transitions α, β are independent in s iff

  • 1. α ∈ Enabled(s) ⇒

β ∈ Enabled(s) ⇐ ⇒ β ∈ Enabled(α(s)), and

  • 2. α, β ∈ Enabled(s) ⇒ α(β(s)) = β(α(s))
  • D. Kroening: Race Analysis for SystemCusing Model Checking

19

slide-54
SLIDE 54

Partial-Order Reduction

  • 1. Sleep sets: maintain set of transitions

that can be skipped during the exploration

  • 2. Persistent sets: maintain set of transitions

which are the only ones to be explored The techniques are orthogonal, and can be combined.

  • D. Kroening: Race Analysis for SystemCusing Model Checking

20

slide-55
SLIDE 55

Persistent Sets

1 Set get pers(Set runnable) 2

Set persistents= ∅;

3

for all (Process pi, pj ∈ runnable) do

4

if (commutative(pi, pj)) then

5

if (pi ∈ persistents) then

6

persistents := persistents ∪ {pj};

7

else

8

persistents := persistents ∪ {pi, pj};

9

return persistents;

  • D. Kroening: Race Analysis for SystemCusing Model Checking

21

slide-56
SLIDE 56

SystemC Running Example

1 SC MODULE(m){ 2

sc clock clk ;

3

int pressure;

4 5

void guard() {

6

if (pressure == PMAX)

7

pressure = PMAX−1;

8

}

9 10

void increment() { pressure++; }

11 12

SC CTOR(m) {

13

SC METHOD(guard); sensitive << clk;

14

SC METHOD(increment); sensitive << clk;

15

}

16 };

  • D. Kroening: Race Analysis for SystemCusing Model Checking

22

slide-57
SLIDE 57

SystemC Running Example

1 SC MODULE(m){ 2

sc clock clk ;

3

int pressure;

4 5

void guard() {

6

if (pressure == PMAX)

7

pressure = PMAX−1;

8

}

9 10

void increment() { pressure++; }

11 12

SC CTOR(m) {

13

SC METHOD(guard); sensitive << clk;

14

SC METHOD(increment); sensitive << clk;

15

}

16 };

  • variable definitions
  • D. Kroening: Race Analysis for SystemCusing Model Checking

22

slide-58
SLIDE 58

SystemC Running Example

1 SC MODULE(m){ 2

sc clock clk ;

3

int pressure;

4 5

void guard() {

6

if (pressure == PMAX)

7

pressure = PMAX−1;

8

}

9 10

void increment() { pressure++; }

11 12

SC CTOR(m) {

13

SC METHOD(guard); sensitive << clk;

14

SC METHOD(increment); sensitive << clk;

15

}

16 };

  • variable definitions

             two thread definitions

  • D. Kroening: Race Analysis for SystemCusing Model Checking

22

slide-59
SLIDE 59

SystemC Running Example

1 SC MODULE(m){ 2

sc clock clk ;

3

int pressure;

4 5

void guard() {

6

if (pressure == PMAX)

7

pressure = PMAX−1;

8

}

9 10

void increment() { pressure++; }

11 12

SC CTOR(m) {

13

SC METHOD(guard); sensitive << clk;

14

SC METHOD(increment); sensitive << clk;

15

}

16 };

  • variable definitions

             two thread definitions      constructor – sets up threads

  • D. Kroening: Race Analysis for SystemCusing Model Checking

22

slide-60
SLIDE 60

Running Example

◮ Intent: Keep pressure lower than PMAX ◮ After each clock tick, the scheduler can choose between

(guard, increment) and (increment, guard)

◮ There is an exponential number of possibilities

(in the number of clock ticks)

  • D. Kroening: Race Analysis for SystemCusing Model Checking

23

slide-61
SLIDE 61

Running Example

◮ Intent: Keep pressure lower than PMAX ◮ After each clock tick, the scheduler can choose between

(guard, increment) and (increment, guard)

◮ There is an exponential number of possibilities

(in the number of clock ticks)

the property can be violated with the right schedule

  • D. Kroening: Race Analysis for SystemCusing Model Checking

23

slide-62
SLIDE 62

Detecting Commutativity

◮ Commutativity is typically approximated

by means of static analysis

◮ E.g., compute set of read/written variables ◮ Works well for fine-grained parallelism

  • D. Kroening: Race Analysis for SystemCusing Model Checking

24

slide-63
SLIDE 63

SystemC Running Example

Are these independent?

void guard() { if (pressure == PMAX) pressure = PMAX−1; } void increment() { pressure++; }

  • D. Kroening: Race Analysis for SystemCusing Model Checking

25

slide-64
SLIDE 64

SystemC Running Example

Are these independent?

void guard() { if (pressure == PMAX) pressure = PMAX−1; } void increment() { pressure++; }

No, because they are not commutative.

  • D. Kroening: Race Analysis for SystemCusing Model Checking

25

slide-65
SLIDE 65

SystemC Running Example

Are these independent?

void guard() { if (pressure == PMAX) pressure = PMAX−1; } void increment() { pressure++; }

No, because they are not commutative. Partial order reduction with usual static commutativity analysis yields no reduction

  • D. Kroening: Race Analysis for SystemCusing Model Checking

25

slide-66
SLIDE 66

Partial-Order Reduction for Big-Step Parallelism

◮ High-level models typically have large blocks that are

executed atomically

◮ There are very few independent transitions ◮ Remedy: compute dependency relation

separately for each state

  • D. Kroening: Race Analysis for SystemCusing Model Checking

26

slide-67
SLIDE 67

SystemC Running Example

Are these independent?

void guard() { if (pressure == PMAX) pressure = PMAX−1; } void increment() { pressure++; } ⑦ ♥

Yes, in most states!

  • D. Kroening: Race Analysis for SystemCusing Model Checking

27

slide-68
SLIDE 68

SystemC Running Example

Are these independent?

void guard() { if (pressure == PMAX) pressure = PMAX−1; } void increment() { pressure++; } ✁ ✁ ✁ ✁ ☛ ⑦ ♥ ⑦ ♥

1

inc

Yes, in most states!

  • D. Kroening: Race Analysis for SystemCusing Model Checking

27

slide-69
SLIDE 69

SystemC Running Example

Are these independent?

void guard() { if (pressure == PMAX) pressure = PMAX−1; } void increment() { pressure++; } ✁ ✁ ✁ ✁ ☛ ❆ ❆ ❆ ❆ ❯ ⑦ ♥ ⑦ ♥

1

⑦ ♥

1

inc guard

Yes, in most states!

  • D. Kroening: Race Analysis for SystemCusing Model Checking

27

slide-70
SLIDE 70

SystemC Running Example

Are these independent?

void guard() { if (pressure == PMAX) pressure = PMAX−1; } void increment() { pressure++; } ✁ ✁ ✁ ✁ ☛ ❆ ❆ ❆ ❆ ❯ ❆ ❆ ❆ ❆ ❯ ⑦ ♥ ⑦ ♥

1

⑦ ♥ ⑦ ♥

1

inc guard guard

Yes, in most states!

  • D. Kroening: Race Analysis for SystemCusing Model Checking

27

slide-71
SLIDE 71

SystemC Running Example

Are these independent?

void guard() { if (pressure == PMAX) pressure = PMAX−1; } void increment() { pressure++; } ✁ ✁ ✁ ✁ ☛ ❆ ❆ ❆ ❆ ❯ ❆ ❆ ❆ ❆ ❯ ✁ ✁ ✁ ✁ ☛ ⑦ ♥ ⑦ ♥

1

⑦ ♥ ⑦ ♥

1

inc guard inc guard

Yes, in most states!

  • D. Kroening: Race Analysis for SystemCusing Model Checking

27

slide-72
SLIDE 72

SystemC Running Example

Are these independent?

void guard() { if (pressure == PMAX) pressure = PMAX−1; } void increment() { pressure++; } ✁ ✁ ✁ ✁ ☛ ❆ ❆ ❆ ❆ ❯ ❆ ❆ ❆ ❆ ❯ ✁ ✁ ✁ ✁ ☛ ⑦ ♥ ⑦ ♥

1

⑦ ♥ ⑦ ♥

1

inc guard inc guard ⑦ ♥

9

(PMAX=10)

Yes, in most states!

  • D. Kroening: Race Analysis for SystemCusing Model Checking

27

slide-73
SLIDE 73

SystemC Running Example

Are these independent?

void guard() { if (pressure == PMAX) pressure = PMAX−1; } void increment() { pressure++; } ✁ ✁ ✁ ✁ ☛ ❆ ❆ ❆ ❆ ❯ ❆ ❆ ❆ ❆ ❯ ✁ ✁ ✁ ✁ ☛ ⑦ ♥ ⑦ ♥

1

⑦ ♥ ⑦ ♥

1

inc guard inc guard ✁ ✁ ✁ ✁ ☛ ⑦ ♥

9

⑦ ♥

10

inc

(PMAX=10)

Yes, in most states!

  • D. Kroening: Race Analysis for SystemCusing Model Checking

27

slide-74
SLIDE 74

SystemC Running Example

Are these independent?

void guard() { if (pressure == PMAX) pressure = PMAX−1; } void increment() { pressure++; } ✁ ✁ ✁ ✁ ☛ ❆ ❆ ❆ ❆ ❯ ❆ ❆ ❆ ❆ ❯ ✁ ✁ ✁ ✁ ☛ ⑦ ♥ ⑦ ♥

1

⑦ ♥ ⑦ ♥

1

inc guard inc guard ✁ ✁ ✁ ✁ ☛ ❄ ⑦ ♥

9

⑦ ♥

10

⑦ ♥

9

inc guard

(PMAX=10)

Yes, in most states!

  • D. Kroening: Race Analysis for SystemCusing Model Checking

27

slide-75
SLIDE 75

SystemC Running Example

Are these independent?

void guard() { if (pressure == PMAX) pressure = PMAX−1; } void increment() { pressure++; } ✁ ✁ ✁ ✁ ☛ ❆ ❆ ❆ ❆ ❯ ❆ ❆ ❆ ❆ ❯ ✁ ✁ ✁ ✁ ☛ ⑦ ♥ ⑦ ♥

1

⑦ ♥ ⑦ ♥

1

inc guard inc guard ✁ ✁ ✁ ✁ ☛ ❆ ❆ ❆ ❆ ❯ ❄ ⑦ ♥

9

⑦ ♥

10

⑦ ♥

9

inc guard guard

(PMAX=10)

Yes, in most states!

  • D. Kroening: Race Analysis for SystemCusing Model Checking

27

slide-76
SLIDE 76

SystemC Running Example

Are these independent?

void guard() { if (pressure == PMAX) pressure = PMAX−1; } void increment() { pressure++; } ✁ ✁ ✁ ✁ ☛ ❆ ❆ ❆ ❆ ❯ ❆ ❆ ❆ ❆ ❯ ✁ ✁ ✁ ✁ ☛ ⑦ ♥ ⑦ ♥

1

⑦ ♥ ⑦ ♥

1

inc guard inc guard ✁ ✁ ✁ ✁ ☛ ❆ ❆ ❆ ❆ ❯ ❄ ❄ ⑦ ♥

9

⑦ ♥

10

⑦ ♥

9

⑦ ♥

9

inc guard inc guard

(PMAX=10)

Yes, in most states!

  • D. Kroening: Race Analysis for SystemCusing Model Checking

27

slide-77
SLIDE 77

SystemC Running Example

Are these independent?

void guard() { if (pressure == PMAX) pressure = PMAX−1; } void increment() { pressure++; } ✁ ✁ ✁ ✁ ☛ ❆ ❆ ❆ ❆ ❯ ❆ ❆ ❆ ❆ ❯ ✁ ✁ ✁ ✁ ☛ ⑦ ♥ ⑦ ♥

1

⑦ ♥ ⑦ ♥

1

inc guard inc guard ✁ ✁ ✁ ✁ ☛ ❆ ❆ ❆ ❆ ❯ ❄ ❄ ⑦ ♥

9

⑦ ♥

10

⑦ ♥

9

⑦ ♥

9

⑦ ♥

10

inc guard inc guard

(PMAX=10)

Yes, in most states!

  • D. Kroening: Race Analysis for SystemCusing Model Checking

27

slide-78
SLIDE 78

Scoot: Key Idea

◮ Scoot is an analyzer for SystemC models ◮ Key idea: use formal verification (FV) to compute the set of

states in which a pair of transactions is commutative

◮ Then re-synthesize the code to obtain a statically

scheduled simulator for dynamic verification (DV)

→ Removes enormous overhead

  • D. Kroening: Race Analysis for SystemCusing Model Checking

28

slide-79
SLIDE 79

An Overview of Scoot

Pointer Analysis Typechecker Race−Condition Analysis Scheduler Synthesis Code Re−synthesis

Scoot g++

Module−Hierarchy Exhaustive Simulator

  • f the

SystemC header files systemc.h SystemC models User−provided Control−Flow Graph Analysis C++ Model Flat Simplified version

  • D. Kroening: Race Analysis for SystemCusing Model Checking

29

slide-80
SLIDE 80

Scheduling with Commutativity Information

◮ We only consider time notification and delta notification ◮ Thus, we ban immediate notification

→ processes cannot enable each other during the evaluation phase

  • D. Kroening: Race Analysis for SystemCusing Model Checking

30

slide-81
SLIDE 81

Scheduling with Commutativity Information

◮ We only consider time notification and delta notification ◮ Thus, we ban immediate notification

→ processes cannot enable each other during the evaluation phase

◮ Consequence:

Runnable(α(s)) = Runnable(s) \ {α}

  • D. Kroening: Race Analysis for SystemCusing Model Checking

30

slide-82
SLIDE 82

Scheduling with Commutativity Information

Theorem (valid without immediate notification):

Two processes α, β ∈ Runnable(s) are independent in s if they are commutative in s.

It’s enough to find out if two processes are commutative.

  • D. Kroening: Race Analysis for SystemCusing Model Checking

31

slide-83
SLIDE 83

Model Checking

◮ Model Checking is an algorithmic technique for verifying if

a given model satisfies a given property

◮ Relies on an exhaustive analysis of the state space of the

model

◮ Frequently applied in the hardware domain ◮ Key value: diagnostic counterexamples

in case the property does not hold

◮ But: susceptible to state-space explosion problem

  • D. Kroening: Race Analysis for SystemCusing Model Checking

32

slide-84
SLIDE 84

Experimental Results

Benchmarks:

◮ B1/B2 ◮ Both: three processes (one server, two clients) ◮ Typical instances for transaction-level modeling

  • D. Kroening: Race Analysis for SystemCusing Model Checking

33

slide-85
SLIDE 85

Results on Benchmark B1

1 10 100 1000 10000 100000 1e+06 1 2 3 4 5 6 7 8 9 No-POR P S P+S

# Transitions # Simulation steps

0.01 0.1 1 10 100 1000 10000 1 2 3 4 5 6 7 8 9 10 No-POR P S P+S

Time (s) # Simulation steps

  • D. Kroening: Race Analysis for SystemCusing Model Checking

34

slide-86
SLIDE 86

Results on Benchmark B2

10 100 1000 10000 100000 1e+06 1 2 3 4 5 6 7 8 No-POR P S P+S

# Transitions # Simulation steps

0.01 0.1 1 10 100 1000 10000 1 2 3 4 5 6 7 8 No-POR P S P+S

Time (s) # Simulation steps

  • D. Kroening: Race Analysis for SystemCusing Model Checking

35

slide-87
SLIDE 87

The Price to Pay

Benchmark Pair SATABS [s] # Strengthenings B1 <1 3 B1 1 23 17 B1 2 21 17 B2 1111 65 B2 1 396 24 B2 2 638 23 Model Checker only sees pairs of transitions Pairs can be distributed on a cluster!

  • D. Kroening: Race Analysis for SystemCusing Model Checking

36

slide-88
SLIDE 88

Conclusion

◮ SystemC offers new opportunities for formal analysis! ◮ If you are running lots of simulations,

it may be worthwhile to perform some heavy static analysis first

◮ Please talk to us if you are interested in

◮ co-verification (e.g. driver + Verilog RTL) ◮ SystemC

  • D. Kroening: Race Analysis for SystemCusing Model Checking

37