towards automating the redesign of the synchronization skeletons of upc programs
DESCRIPTION
Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs. Presenter: Amin Alipour Adviser: Ali Ebnenasir. Motivations. Help developers in automated behavioral debugging, and - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/1.jpg)
Towards Automating the Redesign of the Synchronization
Skeletons of UPC Programs
Presenter: Amin Alipour
Adviser:
Ali Ebnenasir
![Page 2: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/2.jpg)
Motivations
• Help developers in – automated behavioral debugging, and– design of synchronization mechanisms of
multithreaded programs, i.e., synchronization skeleton
![Page 3: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/3.jpg)
Example: A UPC Program
![Page 4: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/4.jpg)
Problem
• Deadlock– Need deadlock-freedom
![Page 5: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/5.jpg)
Outline
• Problem Statement
• Proposed Solution
• Case Study
![Page 6: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/6.jpg)
Problem 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
![Page 7: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/7.jpg)
Proposed Solution
![Page 8: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/8.jpg)
Synchronization Skeleton of the UPC Program
Synch. Skeleton of thread i
// Generate an array element index 0/1
TS_i:
{ upc_lock(lk[i]);
upc_lock(lk[s]);
}
CS_i:
{ // Swap
...
}
// Dont forget to unlock
upc_unlock(lk[i]);
upc_unlock(lk[s]);
![Page 9: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/9.jpg)
Transforming Synchronization Skeleton to Guarded Commands
![Page 10: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/10.jpg)
Guarded Commands• State: snapshot valuation to program variables
• Guarded command:
<grd_1> stmt_1;
[] <grd_2> stmt_2;
[] …
[] <grd_n> stmt_n;
• Example:
(x > y) x := x - y;
[] (y > x) y := y - x;
• A set of transitions (s0, s
1)
– grd is true in s0, and
– s1 is reach by atomic execution of stmt
![Page 11: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/11.jpg)
Canonical UPC Programs
• For simplicity, we consider a canonical version of the program with– 2 threads– An array with size 2
![Page 12: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/12.jpg)
Case Study-State
TSi Trying Section Thread iCSi Critical Section Thread iLKi Lock of Thread iGLKi Lock for Intra-thread Serialization Thread iSi random value selected by Thread iSSi Whether Thread i has selected a random value
![Page 13: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/13.jpg)
Translation of Synchronization Skeleton to Guarded CommandsInitial state values:
TS_i := true; CS_i := false; sSet_i = false;
Ai1: (sSet_i = false) -> s_i := 0|1;
sSet_i := true;
Ai2: (sSet_i = true) /\ (TS_i = true) /\ (lk[i] = true) /\ (gotLock_i = false)
-> lk[i] := false;
gotLock_i := true;
Ai3: (sSet_i = true) /\ (TS_i = true) /\ (lk[s_i] = true) /\ gotLock_i = true ->
lk[s_i] := false;
gotLock_i :=false;
TS_i := false;
CS_i := true;
Ai4: (sSet_i = true) /\ (CS_i = true) /\ (lk[i] = false) /\ (lk[s_i] = false) ->
lk[i] := true; lk[s_i] := true; CS_i := false;TS_i := true; sSet_i := false;
![Page 14: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/14.jpg)
Generating Reachability Graph for the program
![Page 15: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/15.jpg)
Reachability Graph Generation
• Start with initial states1. Check applicable commands
2. Generate new reachable states
3. run Steps 1 and 2 until no new state is generated
![Page 16: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/16.jpg)
Finite Model
![Page 17: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/17.jpg)
Finite Model
![Page 18: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/18.jpg)
Finite Model
![Page 19: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/19.jpg)
Finite Model
![Page 20: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/20.jpg)
Automatic Revision
![Page 21: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/21.jpg)
Revised Model
![Page 22: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/22.jpg)
Revised Thread 1Thread 1{A11: (!SS1 !S2) (!SS2 || !S1) ->S1=1; SS1 = true;A12: (TS1 !CS1 LK[0] !GLK1 (S1) SS1)->LK[0] = false;GLK1 = true;A13: (TS1 !CS1 !LK[0] GLK1 (S1) SS1)->LK[1] = false; GLK1=false;TS1 = false;CS1 = true;A14: (!TS1 CS1 !LK[0] !GLK1 (S1) SS1 SS2)->LK[0] = true; LK[1] = true; CS1 = false;TS1 = true;SS1= false;}
Avoid s Deadlock
Ai1: (sSet_i = false) -> s_i := 0|1; sSet_i := true;Ai2: (sSet_i = true) (TS_i = true) (lk[i] = true) (gotLock_i = false)
-> lk[i] := false; gotLock_i := true;Ai3: (sSet_i = true) (TS_i = true) (lk[s_i] = true) gotLock_i = true -> lk[s_i] := false; gotLock_i :=false;TS_i := false;CS_i := true;Ai4: (sSet_i = true) (CS_i = true) (lk[i] = false) (lk[s_i] = false) ->
lk[i] := true; lk[s_i] := true; CS_i := false;TS_i := true; sSet_i := false;
![Page 23: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/23.jpg)
Ai1: (sSet_i = false) -> s_i := 0|1; sSet_i := true;
Ai2: (sSet_i = true) (TS_i = true) (lk[i] = true) (gotLock_i = false) -> lk[i] := false; gotLock_i := true;
Ai3: (sSet_i = true) (TS_i = true) (lk[s_i] = true) gotLock_i = true -> lk[s_i] := false; gotLock_i :=false;TS_i := false; CS_i := true;Ai4: (sSet_i = true) (CS_i = true) (lk[i] = false) (lk[s_i] = false) -> lk[i] := true; lk[s_i] := true; CS_i := false;TS_i := true; sSet_i := false;
Thread 2{
A21: !SS2 ->S2=0; SS2 = true;A22: TS2 !CS2 LK[1] !GLK2 !(S2) S1 SS2 !SS1 ->LK[1] = false;GLK2 = true;A23: TS2 !CS2 !LK[1] GLK2 !(S2) SS2 ->LK[0] = false; GLK2=false;TS2 = false;CS2 = true;A24: !TS2 CS2 !LK[1] !GLK2 !(S2) SS2 ->LK[0] = true; LK[1] = true; CS2 = false;TS2 = true;SS2= false;}
Avoids Deadlock
Imposes sequential execution
![Page 24: Towards Automating the Redesign of the Synchronization Skeletons of UPC Programs](https://reader035.vdocument.in/reader035/viewer/2022062519/568154c6550346895dc2cbda/html5/thumbnails/24.jpg)
Questions