dynamic verification of multicore communication applications in mcapi subodh sharma, uofu

42
1 Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU Ganesh Gopalakrishnan, UofU Eric Mercer, BYU 1 Supported by NSF CCF 0903408/0903491 and SRC 2009-TJ-1993/1994 HLDVT 2009

Upload: clyde

Post on 14-Jan-2016

26 views

Category:

Documents


1 download

DESCRIPTION

HLDVT 2009. Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU Ganesh Gopalakrishnan, UofU Eric Mercer, BYU. Supported by NSF CCF 0903408/0903491 and SRC 2009-TJ-1993/1994. 1. Concurrency Space in Multicore Era. Concurrency Space in Multicore Era. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

1

Dynamic Verification of Multicore Communication Applications in MCAPI

Subodh Sharma, UofUGanesh Gopalakrishnan, UofU

Eric Mercer, BYU

1Supported by NSF CCF 0903408/0903491 and SRC 2009-TJ-1993/1994

HLDVT 2009

Page 2: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

2

Concurrency Space in Multicore Era

S/W solution H/W solution

Cloud/HPC Computing MPI, PVM, Mapreduce, MSCS

Clusters, Vector machines, Supercomputers

Desktop computing OOSD, Scripting, Pthreads, TBB, CT, OpenMP

Desktop machines

Embedded Computing Lightweight counterparts of the above.

FPGAs, DoC, SoC, etc.

Page 3: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

3

Concurrency Space in Multicore Era

Requires Standardization

Multicore Association (MCA) Effort

S/W solution H/W solution

Cloud/HPC Computing MPI, PVM, Mapreduce, MSCS

Clusters, Vector machines, Supercomputers

Server/Desktop computing

OOSD, Scripting, Pthreads, TBB, CT, OpenMP

Desktop machines

Embedded Computing Lightweight counterparts of the above.

FPGAs, DoC, SoC, etc.

Page 4: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

4

What is MCAPI (Multicore Communication API)?

• An API specification from MCA (Multicore Association)

• To program embedded systems like mobile phones, PDAs, routers, servers, etc.

• Not restricted to SPMD (like MPI) or multi threaded style of programming.

Page 5: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

5

Taxonomy for MCA APIs

MCAPI – Communication API• Message based• Packet/Scalar Channel based

MRAPI – Resource Management API

• Semaphores, mutexes• Shared memory segment allocation, deallocation

MTAPI – Task Management API• Specification work yet to begin• Thread Pooling, Work Stealing queues e.g. CILK, TBB, TPL etc.Inter API

interactions

Page 6: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

6

State of MCA Efforts?

• MCAPI standard is released.

• MCAPI reference implementation exists• A commercial implementation – Polycore, Inc.• In-house implementation on FPGA in progress (Utah).

• MRAPI standard work in progress.

• MTAPI efforts yet to begin.

Page 7: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

7

State of MCA Efforts?

• Standardization efforts take a long time to mature

• Need for FV in MCA API development.

• Our effort: Early Engagement of FV in the MCA APIs space

• To promote early adoption of the API• To promote better programming practices• To help avoid early pit-falls – e.g. unspecified behaviors

Page 8: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

8

Achievements so far!

• Formal Specification work (at BYU)• Permits symbolic analysis

• Murphi -> CVC• Query Oracle for scenario outcome calculation.• Platform testing

• Dynamic Verification of MCAPI user apps (at Utah)• MCC tool created.• Current capabilities of MCC

• Dynamic search of dependencies• Exerting a deterministic runtime control

• Algorithmic Advances• Symmetry reduction in MCAPI domain space.

Page 9: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

9

Focus of the talk!

• Formal Specification work (at BYU)• Permits execution based symbolic analysis

• Murphi -> CVC• Query Oracle for scenario outcome calculation.• Platform testing

• Dynamic Verification of MCAPI user apps (at Utah)• MCC tool created.• Current capabilities of MCC

• Dynamic search of dependencies• Exerting a deterministic runtime control

• Algorithmic Advances• Symmetry reduction in MCAPI domain space.

Page 10: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

10

Related Work

• CHESS tool from MSR• Uses preemption bounded search • Cannot be used for message passing programs

• ISP tool from Utah• Used for MPI verification• MCC differs in the way determinism is enforced at runtime.

• Inspect tool from Utah• Used for shared memory programs• Implements the classical DPOR algorithm.

• JPF• A model checker for Java bytecode.

Page 11: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

11

MCAPI Preliminaries

• MCAPI Node – • Processes, Threads, OS instance, Processor core,

etc.

• MCAPI Endpoint –• Socket-like communication termination points• Identified by a tuple <node_id, port_id>

• MCAPI Channels • Point to point unidirectional FIFO connections

between a pair of endpoints.

• A single communication universe

Page 12: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

12

MCAPI Messages

Node 1

Port 1 <1,1>

Port 2 <1,2>

Node 2

Port 1 <2,1>

Connectionless Message

To <2,1>

• Message received at FIFO receive queue

Page 13: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

13

MCAPI Connection Oriented Communication

Node 1

Port 1 <1,1>

Port 2 <1,2>

Node 2

Port 1 <2,1>To <2,1>

• Sent over a connected channel• <1,1> can communicate on ONE channel only

Node 3

Port 1 <3,1>

To <3,1>ERROR!!

Page 14: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

14

MCAPI API generic + message calls

Initialize/Finalize Sets and deletes the environment. Must be called by each communicating node.

Create/Delete endpoint API calls to manage creation/deletion of endpoints on the owner node

Get_endpoint A blocking call to get the address of a remote endpoint.

Send (send_endpoint, recv_endpoint .. )

Sends a data-payload from a sending endpoint to a receiving endpoint. API provides blocking and non blocking versions.

Recv (recv_endpoint, ..) Receives a data payload from the receiving endpoint. API provides blocking non-blocking versions.

Wait (request_handle, ..), Test(req_handle, ..)

Checks the completion of the request. Wait – Blocking; Test – Non blocking

Page 15: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

15

Illustration of MCAPI C program

int main () {…for(t=0; t<NUM_THREADS; t++){ rc = pthread_create(&threads[t], NULL, run_thread, (void*)&thread_data_array[t]); } for (t = 0; t < NUM_THREADS; t++) { pthread_join(threads[t],NULL); }}void* run_thread (void *t) {… mcapi_initialize(tid,&version,&status); if (tid == 1) { recv_endpt = mcapi_create_endpoint (PORT_NUM, &status);

mcapi_msg_recv(recv_endpt,msg, BUFF_SIZE,&recv_size, &status);mcapi_msg_recv(recv_endpt,msg, BUFF_SIZE, &recv_size, &status);} else {send_endpt = mcapi_create_endpoint (PORT_NUM,&status);recv_endpt = mcapi_get_endpoint (1,PORT_NUM,&status);mcapi_msg_send(send_endpt,recv_endpt, msg,strlen(msg), 1,&status);} mcapi_finalize(&status);return NULL;}

Potential deadlock

Page 16: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

16

MCC – MCAPI Checker

Workflow of MCC.

MCAPI C ProgramMCAPI C Program

instrumentation

Instrumented ProgramInstrumented Program

compile

MCAPI Library WrapperMCAPI Library Wrapper

Scheduler

Executable

thread 1

thread n

request/permit

request/

permit

Page 17: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

17

Bug Classes in MCAPI User Applications

• Non determinism due to communication race.• The recv() call is passed with only receiving

endpoint as a parameter. • The receiving endpoint extracts message from the

FIFO receive queue.

T0 T1 T2

--- --- --- The send that matches the recv may decide the correctness !!

POTENTIAL BUG

S(e1,e2) S(e1,e2) R(e2)

R(e2)

Page 18: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

18

Bug Classes in MCAPI User Applications

• Mismatched Calls

“get_endpoint” invoked for a non-existent endpoint -- ERROR

T0 T1

--- ---

R(1) Get_endpoint(2)

S(1,2)

Does not exist

Page 19: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

19

Challenge: exponential interleavings

19

T0 T1 T2 T3 T4 T5

T0 T1 T2 T3 T4 T5

A B

Dependent MCAPI calls

Only these 2 are RELEVANT!!!

Possible Interleaving

Page 20: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

20

Relevant interleaving exploration by MCC scheduler

T0 T1 T2

S (ep1,ep3) S(ep2,ep3) R(ep3)

R(ep3)

Intra happens-Before Edge

Page 21: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

21

T0 T1 T2

S (ep1,ep3) S (ep2,ep3) R (ep3)

R (ep3)

Enabled Transitions: S(ep1, ep3), S(ep2, ep3), R (ep3)

Match Set: <S(ep1, ep3), R (ep3)> <S(ep2, ep3), R (ep3)>

Interleaving 1

Issue to the runtime

Match sets are computed at “decision points”

Set of matchingtransitions

No runnable thread

Relevant interleaving exploration by MCC scheduler

Page 22: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

22

T0 T1 T2

S (ep1,ep3) S (ep2,ep3) R (ep3)

R (ep3)

Enabled Transitions: S(ep2, ep3), R (ep3)

Match Set: <S(ep2, ep3), R (ep3)>

Interleaving 1

Issue to the runtime

Relevant interleaving exploration by MCC scheduler

Page 23: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

23

T0 T1 T2

S (ep1,ep3) S (ep2,ep3) R (ep3)

R (ep3)

Enabled Transitions: S(ep1, ep3), S(ep2, ep3), R (ep3)

Match Set: <S(ep2, ep3), R (ep3)>

Interleaving 2

Issue to the runtime

Relevant interleaving exploration by MCC scheduler

Page 24: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

24

T0 T1 T2

S (ep1,ep3) S (ep2,ep3) R (ep3)

R (ep3)

Enabled Transitions: S(ep2, ep3), R (ep3)

Match Set: <S(ep1, ep3), R (ep3)>

Interleaving 2

Issue to the runtime

Relevant interleaving exploration by MCC scheduler

Page 25: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

25

T0 T1 T2

S (ep1,ep3) S (ep2,ep3) R (ep3)

R (ep3)

Enabled Transitions: S(ep2, ep3), R (ep3)

Match Set: <S(ep1, ep3), R (ep3)>

Interleaving 2

Issue to the runtimeError Caught

Relevant interleaving exploration by MCC scheduler

Page 26: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

26

Enforcing a deterministic runtime match• For non blocking requests, there is an additional problem

• Runtime communication race even after a scheduler decides deterministically.

T0 T1 T2

IS (ep1,ep3) IS (ep2,ep3) IR (ep3)

IR (ep3)

Match-set 1

Match-set 2

Page 27: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

27

T0 T1 T2

IS (ep1,ep3) IS (ep2,ep3) IR (ep3)

IR (ep3)

Match-set 1

Match-set 2

Not finished yet!!

RACE

Enforcing a deterministic runtime match

Page 28: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

28

Solution 1 to enforce a deterministic match.

• Addition of Probing function to the MCAPI library• Probes an endpoint’s receive queue for a message• Returns TRUE if the message is found

• Scheduler issues the next match-set only when the probe function returns TRUE.

Enforcing a deterministic runtime match

Page 29: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

29

T0 T1 T2

IS (ep1,ep3) IS (ep2,ep3) IR (ep3)

IR (ep3)

Probing Solution

Receive Queue

matched

Enforcing a deterministic runtime match

Page 30: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

30

T0 T1 T2

IS (ep1,ep3) IS (ep2,ep3) IR (ep3)

IR (ep3)

Probing Solution

Receive Queue

matched

Runtime MCC Scheduler

Probes

Enforcing a deterministic runtime match

Page 31: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

31

T0 T1 T2

IS (ep1,ep3) IS (ep2,ep3) IR (ep3)

IR (ep3)

Probing Solution

T1 Receive Queue

Probes

Runtime MCC Scheduler

Enforcing a deterministic runtime match

Page 32: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

32

T0 T1 T2

IS (ep1,ep3) IS (ep2,ep3) IR (ep3)

IR (ep3)

Probing Solution

T1T0 Receive Queue

Enforcing a deterministic runtime match

Page 33: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

33

Solution 2 to enforce a deterministic match.

• Scheduler induces a “test” call

• Scheduler spin-loops on the request handle until the

successful completion of the “test” call.

We opt Solution 2 in our work as it is non-intrusive.

Enforcing a deterministic runtime match

Page 34: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

34

T0 T1 T2

IS (ep1,ep3) IS (ep2,ep3) IR (ep3)

IR (ep3)

Enabled Transitions: Send(ep1, ep3), Send(ep2, ep3), Recv (ep3)

Match Set: <Send(ep2, ep3), Recv (ep3)> <Send(ep1, ep3), Recv (ep3)>

Dummy “wait” Solution

matched

Enforcing a deterministic runtime match

Page 35: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

35

T0 T1 T2

IS (ep1,ep3) IS (ep2,ep3) IR (ep3)

IR (ep3)

Dummy “wait” Solution

Runtime MCC Scheduler

Enforcing a deterministic runtime match

Test ()

Page 36: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

36

T0 T1 T2

IS (ep1,ep3) IS (ep2,ep3) IR (ep3)

IR (ep3)

Dummy “wait” Solution

Runtime MCC Scheduler

Enforcing a deterministic runtime match

Test()

matched

Page 37: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

37

Concluding remarks and future work

• MCC currently supports connectionless API constructs• Checks for safety assertion violations and

Deadlocks

• Steadily improve MCC over this year• Support for connection-oriented API calls, sanity

checks etc.

• Release MCC and assess experience of industrial app writers

Page 38: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

38

www.cs.utah.edu/formal_verification

Page 39: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

39

Happens-Before Relationship – Computed Dynamically

T0 T1 T2

IS (ep1,ep3, r1) IS (ep2,ep3, r3) IR (ep3, r4)

IR (ep3, r5)IS (ep1,ep4, r2)

R (ep3)W(r2)

Page 40: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

40

t1: a[x] := …

t2: … := a[y] t1: a[x] := …

t2: … := a[y]

Equal ??

t2: … := a[y]

Review of POR

Dynamic POR

Dependencies based on concrete values

x=56, y=753 (e.g.) at runtime!

Page 41: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

41

Happens-Before Relationship – Example

T0 T1 T2

IS (ep1,ep3, r1) IS (ep2,ep3, r3) IR (ep3, r4)

IR (ep4, r5)IS (ep1,ep4, r2)

R (ep3)W(r2)

Page 42: Dynamic Verification of Multicore Communication Applications in MCAPI Subodh Sharma, UofU

42

OOO completion: Why construct Happens-Before relationship?

42

T0

T0

IS (1GB to T1)IS (1GB to T1)

IS (1 byte to T2)IS (1 byte to T2)

Must calls complete in PROGRAM ORDER?

NO!!!