Title: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs
1Towards Automating the Redesign of the
Synchronization Skeletons of UPC Programs
Presenter Amin Alipour Adviser Ali Ebnenasir
2Motivations
- Help developers in
- automated behavioral debugging, and
- design of synchronization mechanisms of
multithreaded programs, i.e., synchronization
skeleton
3Example A UPC Program
4Problem
- Deadlock
- Need deadlock-freedom
5Outline
- Problem Statement
- Proposed Solution
- Case Study
6Problem Statement
- Input
- A UPC program P
- A desired mutual exclusion (e.g., lack of data
race) or progress property (e.g.,
deadlock-freedom), denoted L - P does not meet L
- Output
- A revised version of P, denoted P_r
- Constraints
- P_r meets L
- P_r does not violate other properties of P
7Proposed Solution
UPC Program
Revised UPC Program
8Synchronization Skeleton of the UPC Program
- Synch. Skeleton of thread i
- // Generate an array element index 0/1
- TS_i
- upc_lock(lki)
- upc_lock(lks)
-
- CS_i
- // Swap
- ...
-
- // Dont forget to unlock
- upc_unlock(lki)
- upc_unlock(lks)
9Transforming Synchronization Skeleton to Guarded
Commands
10Guarded Commands
- State snapshot valuation to program variables
- Guarded command
- ltgrd_1gt ? stmt_1
- ltgrd_2gt ? stmt_2
-
- ltgrd_ngt ? stmt_n
- Example
- (x gt y) ? x x - y
- (y gt x) ? y y - x
- A set of transitions (s0, s1)?
- grd is true in s0, and
- s1 is reach by atomic execution of stmt
11Canonical UPC Programs
- For simplicity, we consider a canonical version
of the program with - 2 threads
- An array with size 2
12Case Study-State
TSi Trying Section Thread i CSi Critical
Section Thread i LKi Lock of Thread
i GLKi Lock for Intra-thread Serialization
Thread i Si random value selected by Thread
i SSi Whether Thread i has selected a random
value
13Translation of Synchronization Skeleton to
Guarded Commands
Initial state values TS_i true CS_i
false sSet_i false Ai1 (sSet_i false)
-gt s_i 01 sSet_i true Ai2
(sSet_i true) /\ (TS_i true) /\ (lki
true) /\ (gotLock_i false) -gt lki
false gotLock_i true Ai3
(sSet_i true) /\ (TS_i true) /\ (lks_i
true) /\ gotLock_i true -gt lks_i
false gotLock_i false
TS_i false CS_i
true Ai4 (sSet_i true) /\ (CS_i true) /\
(lki false) /\ (lks_i false) -gt
lki true lks_i true CS_i
falseTS_i true sSet_i false
14Generating Reachability Graph for the program
15Reachability Graph Generation
- Start with initial states
- Check applicable commands
- Generate new reachable states
- run Steps 1 and 2 until no new state is generated
16Finite Model
17Finite Model
18Finite Model
19Finite Model
20Automatic Revision
21 Revised Model
22Revised Thread 1
Thread 1 A11 (!SS1 ? !S2) ? (!SS2 !S1)
-gtS11 SS1 true A12 (TS1 ?!CS1 ? LK0
?!GLK1 ?(S1) ? SS1)-gtLK0 falseGLK1
true A13 (TS1 ?!CS1 ?!LK0 ? GLK1 ?(S1) ?
SS1)-gtLK1 false GLK1falseTS1 falseCS1
true A14 (!TS1 ? CS1 ?!LK0 ?!GLK1 ?(S1) ? SS1
? SS2)-gtLK0 true LK1 true CS1
falseTS1 trueSS1 false
Avoid s Deadlock
Ai1 (sSet_i false) -gt s_i 01 sSet_i
true Ai2 (sSet_i true) ? (TS_i true) ?
(lki true) ? (gotLock_i false) -gt
lki false gotLock_i true Ai3 (sSet_i
true) ? (TS_i true) ? (lks_i true) ?
gotLock_i true -gt
lks_i false gotLock_i falseTS_i
falseCS_i true Ai4 (sSet_i true) ? (CS_i
true) ? (lki false) ? (lks_i false) -gt
lki true lks_i true CS_i
falseTS_i true sSet_i false
23Avoids Deadlock
Thread 2? A21 !SS2 -gtS20 SS2 true A22
TS2 ? !CS2 ? LK1 ? !GLK2 ? !(S2) ? S1 ? SS2
? !SS1 -gtLK1 falseGLK2 true A23 TS2 ?
!CS2 ? !LK1 ? GLK2 ? !(S2) ? SS2 -gtLK0
false GLK2falseTS2 falseCS2 true A24
!TS2 ? CS2 ? !LK1 ? !GLK2 ? !(S2) ? SS2
-gtLK0 true LK1 true CS2 falseTS2
trueSS2 false
Imposes sequential execution
Ai1 (sSet_i false) -gt s_i 01
sSet_i true Ai2 (sSet_i true) ?
(TS_i true) ? (lki true) ? (gotLock_i
false) -gt lki false
gotLock_i true Ai3 (sSet_i true) ? (TS_i
true) ? (lks_i true) ? gotLock_i true -gt
lks_i false gotLock_i falseTS_i
false CS_i true Ai4 (sSet_i
true) ? (CS_i true) ? (lki false) ?
(lks_i false) -gt lki true lks_i
true CS_i falseTS_i true sSet_i false
24Questions