29
Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

Embed Size (px)

Citation preview

Page 1: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

Tutorial on Test Model-checking

Ganesh Gopalakrishnan

Ratan Nalumasu

Rajnish Ghughal

Mike Jones

Ritwik Bhattacharya

Ali Sezgin

Prosenjit Chatterjee

Page 2: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

2

Overview of talk

• Advantages of the approach

• An example

• Avenues of work

– Formal specification of memory models

– Characterization of violations

– Obtaining finite-state abstractions

– Obtaining finite-state models of memory systems

– Combating state explosion and reporting errors

– Conjectures

• Conclusions

Page 3: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

3

Advantages of the approach

• Test automata inspired by proven architectural testing methods (lifting

architectural testing techniques to the realm of model-checking)

• Can formally study properties of memory models as well as their sub-

ordering rules (e.g. read orderings w/o write ordering)

• Can use test model-checking without knowing the internal details of the

memory system (rapid verification regressions)

• Can use pure tests as putative queries to help understand the memory

model

• Can define a variety of memory models in a uniform framework (weak as

well as strong models) – hence not “hard wired” for particular models

Page 4: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

4

From Archtest to Test Automata

P1

A:=1A:=2

..A:=k

P2

X[1]:=A X[2]:=A

..X[k]:=A

Condition : ALL X[i] values are monotonically increasing

Archtest recommends running for “large” values of kto capture all possible interleavings

• Archtest Test for (CMP, RO, WO)

Page 5: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

5

Why this tests for (CMP,RO,WO)Consider a violation:

P1 P2 A := 1 X[ 1 ] := A

A := 2 X[ 2 ] := A … …

A := p X[ i ] := A ==> q… … A := q X[ j ] := A ==> p

… … A := k X[ k ] := A

We check for all k for all interleavingsthrough an abstraction that capitalizeson data independence

Page 6: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

6

Example test automata that drivetest model-checking for (CMP,RO,WO)

s0

s1

A := 0

A := 1

s0

s1

read(A)

s2

X2 :=read(A)

X1 := read(A)

read(A)

P2P1

Safety Property to be established:

P2 in final state => X2 >= X1

Non-deterministic switches

Page 7: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

7

Another example: A pure test for (CMP,RO)

P1

A:=1A:=2

..A:=k

P2

X[1]:=A X[2]:=A

..X[k]:=A

RO met when for all p, q, r : p < q < r : X[p] = X[r] => X[p] = X[q] = X[r]

- Obtain execution scenario capturing ordering rule- Create finite-state abstraction of violating executions

Page 8: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

8

Test Automata for (CMP, RO) for the same operand

s0

s1

A := 0

A := 1

s0

s1

read(A)

s2

X2 :=read(A)

X1 := read(A)

read(A)

P2

P1

Safety Property :

Finally, X1 = X3 => X1 = X2 = X3

Non-deterministic switches

read(A)

s2

X3 :=read(A)

read(A)

Page 9: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

9

Variant of previous test: Test Automata for (CMP, MB-RR) assuming that the # of MB-RRs don’t matter

s0

s1

A := 0

A := 1

s0

s1

read(A)

s2

X2 :=read(A) ; MB-RR

X1 := read(A) ; MB-RR

read(A)

P2

P1

Safety Property :

Finally, X1 = X3 => X1 = X2 = X3

Non-deterministic switch

read(A)

s2

X3 :=read(A) ; MB-RR

read(A)

Page 10: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

10

Specification of memory models via architectural rules

• CMP (Rule of Computation) : – A Basic rule specifying how operand values are computed

from other operand values.

• RO (Read Order) :– Reads in a single process are completed in program order

• WO (Write Order) / PO (Program Order):– Writes / reads and writes in a single process are completed in

program order

• WOS, POS - our defn (we denote Collier’s

definitions by WOS_c, POS_c, etc.)– Writes posted in program order in remote stores also

Page 11: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

11

Specifying Weaker memory models relaxations of orderings

• Partial-PO Relaxation :– Relaxes PO partially - WR is always relaxed

– May relax WA in various orders

– examples : SPARC V9 TSO, PSO, Intel Pentium Pro,

Processor consistency etc.

• Complete-PO relaxation :– Relaxes PO completely

– typically does not relax WA

– examples : SPARC V9 RMO, Alpha, PowerPC, Release

Consistency

Page 12: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

12

WA relaxationvia rule WA-S

• WA :

– a write becomes visible to all processors “instantly”

– atomic set of events - all write events

• WA-S :

– a write becomes visible to all other processors

“instantly”

– atomic set of events - all write events in stores of

other processors

Page 13: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

13

Some examples(informal proofs in Ghughal’s MS)

• TSO = A (CMP, UPO, RO, WO, RW, WA-S, MB-WR)

• PSO = A (CMP, UPO,RO, RW, WA-S, MB-WR, MB-WW)

• IBM 370 = A(CMP, UPO, RO, WO, RW, WA, MB-WR)

• Alpha subset = A(CMP, UPO, ROO, WA-S, MB, MB-WW)

Page 14: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

14

Anticipated Path towards Completeness

• Take memory model in question - e.g. (CMP,RO,WOS)

• Prove limited address theorem – e.g. two addresses suffice for

(CMP,RO,WOS) – called “max # of addresses” below

• Obtain single partial order “<c” that simulates CMP (I.e. any admissible CMP

respects the <c order) in the context of RO,WOS

• Assume address projectability (single partial order <c (as opposed to CMP)

allows violating cycles to be projected onto the max # of addresses in violating

cycles)

• Enumerate all possible violations over max # of addresses

• Capitalize on data independence to build test automata that incorporate the

violations

Page 15: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

15

Anticipated Path towards Completeness

• Currently we have that

– (CMP,RO,WOS) can be verified in 2 addresses

– PRAM=(CMP,POS) and SC=(CMP,POS,WA) have N-address

violations for N processors

– We have complete characterization of SC violations for 2

processors and addresses assuming PRAM

Page 16: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

16

Identifying Violation Classes:some of the POS violations (1-3 of 5)

v is not the initialvalue T of a, and a is not writtenanywhere

(1)

P_i...rd(a, v)…

P_ j...…...

(2)

P_i...rd(a,v1)…rd(a,v2)...

P_ j…wr(a,v2)…wr(a,v1)...

P_ i and P_ jcould be thesame process

(3)

P_i...rd(a,v)…rd(a,T)...

P_ j…wr(a,v)…

P_ i and P_ jcould be thesame process

Page 17: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

17

...one-address PO violations (4-5 of 5)

v is not the initialvalue T of a, and a is not writtenbefore being read

(4) P_i...rd(a,v)…wr(a,v)...

(5) P_i...wr(a,v)…rd(a,T)...

The formal status of these violations is under study(believed to be exhaustive for one address)

Page 18: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

Client0 Client1b a

Host

Broadcast Verification of Program Orderingfor all one-address programs

Error states: E1, E2

xmeans Write(A,x)

Read(A,-)

Page 19: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

19

Experimental result

• A model of the MIT HCN protocol was created in Murphi by Mike Jones (details in

the next presentation)

• He applied his parameterized verification technique to identify network classes in

which to verify

• The PRAM test on the previous page was applied

• Subtle coding error revealed pretty quickly

Message: Often cheaper to verify sub-ordering rules than the whole

(in this case SC)

Page 20: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

20

Pure Test for RO- different operands- WO not assumed

P1

B:=1

P2

X := A;Y := B;C := Y;

P3

U := C;A := U;

• Initially all vars == 0• Finally all vars == 1 => In P2, B must have been read before A

Creating a test automaton based on violation scenarios

Page 21: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

21

Pure Test for RO- different operands- WO not assumed

P1

B:=1B:=2

..B:=k

P2

Y[0] := 0;X[1] := A;Y[1] := B;C := Y[i];X[2] := A;Y[2] := B;C := Y[2];

…X[k] := A;Y[k] := B;C := Y[k];

Condition : Exists i:1<= i<= k Forall j:0<= j < i: X[i] != Y[j]

P3

U[1] := C;A := U[1];U[2] := C;A := U[2];

...U[k] := C;A := U[k];

“X is getting ahead of all the Y’s so far” -- need to examinea history of values...

Turn into OR accumulatorvia data-independence!

Page 22: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

22

Safety Property :

(P2 in S1 /\ y==0)

=> x==0

Test Automata for RO(diff opnds)

s0

B:=0s0

s1

read(A); t := read(B); C := t; y := y \/ t;

P2

P1

B:=1s0P3

u := read(C);A := u;

read(A); t := read(B); C := t;

x := read(A); t := read(B); C := t;

Page 23: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

23

Characterization of violations: a summary

• Test model-checking allows different violation classes to

be studied and reused

• Abstract interpretation can help derive sound abstractions

systematically

Page 24: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

24

Modeling memory systems

• Good modeling languages will allow succinct specifications to be

written

• They may even help meet certain assumptions automatically for

verification (e.g. address projectability and data independence)

• Explicit or implicit state? None seem to have an edge (see next

slides)

• Reductions appear to be quintessential (tried Partial Order

Reductions so far)

Page 25: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

Formal Specification of Memory Systems

Runout

Runin

Cache lines

Noncoh

Client0 Client1

b a

Host

Broadcast

Coh_chans

Page 26: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

26

Experimental Results (VIS)

WA States Bdds Time

Serial Memory 212k 10k 34 sec

Lazy Caching 1.9M 513k 59 min

PA8000 985k 1.7M 40 hrs

PO States Bdds Time

Serial Memory 7k 7k 9 sec

Lazy Caching 7.8M 306k 36 min

PA8000 953k 1.6M 27 hrs

Page 27: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

27

SC verification of the HP/Runway modelPromela, with SPIN and PV (#states)

Spin PV

PO-1 56K 2794

PO-2 > 5M/DNF 11M

SC-1 499K 7880

SC-2a > 5M/DNF 5.9M

SC-2b > 4M/DNF 574K

Page 28: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

28

Some results as well as conjectures

• (CMP,UPO,WO,RO,RW) => (CMP,POS_c)

• Assuming CON to be part of WA-S, Ghughal has shown that

(CMP,WOS_c,WA-S) = (CMP,WO,WA-S)

• It has been shown that (CMP,UPO,CON) => (CMP,UPO,CON,WA-Si) where

WA-Si is the “intra” component of WA-S

• (CMP,RO,…) =?= (CMP-SRW,RO,RW,…)

• Is (CMP,UPO,WO,RO,RW) the same as PRAM or (CMP,POS)?

– Reason to think so: PRAM tests don’t fail on TSO

– We define TSO as (CMP,UPO,RO,WO,RW,WA-S,MB-WB)

Page 29: Tutorial on Test Model-checking Ganesh Gopalakrishnan Ratan Nalumasu Rajnish Ghughal Mike Jones Ritwik Bhattacharya Ali Sezgin Prosenjit Chatterjee

October 31, 2000 School of Computing, University of Utah

29

Concluding Remarks

• RAPA provided us a solid start in this area

• Many formal proofs remain to be tightened (PVS encoding

contemplated)

• An experimental test model-checking framework will be built

• Some questions:

– Future trends in memory model selection?

– How to cut needless variety in protocol design (that may not have a

significant performance benefit)?

– Can test model-checking be used in other situations (e.g. JVM validation)?