Efficient Computation of MayHappeninParallel Information for Concurrent Java

  • Slides: 20
Download presentation
Efficient Computation of May-Happen-in-Parallel Information for Concurrent Java Programs Rajkishore Barik rajbarik@in. ibm. com

Efficient Computation of May-Happen-in-Parallel Information for Concurrent Java Programs Rajkishore Barik [email protected] ibm. com 3/10/2021 LCPC'05 1

Introduction May-happen-in-parallel (MHP) analysis: Statically determines statements that may execute in parallel in a

Introduction May-happen-in-parallel (MHP) analysis: Statically determines statements that may execute in parallel in a multithreaded program Application: n n n Detecting synchronization anomalies Program optimization Debuggers and program understanding tools Data flow analysis Enforce ordering among shared accesses Complexity: n NP-complete (Taylor) 3/10/2021 LCPC'05 2

Related Work n B 4 analysis (Callahan and Subhlok) Ada: n n n Java:

Related Work n B 4 analysis (Callahan and Subhlok) Ada: n n n Java: n Interprocedural B 4 analysis (Duesterwald and Soffa) Non-concurrency analysis (Masticola and Ryder) May-Happen-in-Parallel analysis (Naumovich and Avrunin) n n n Data flow analysis Constructs: start, join, notify, wait, notify. All, locks Number of runtime threads need to be explicitly enumerated during static analysis Worst-case complexity: (p. N)3 where p is the number of runtime threads and N is the number of PEG nodes per thread Happens-before, happens-after and happens-in-parallel (Sura et al. ) n n 3/10/2021 Data flow analysis Constructs: start, join, locks LCPC'05 3

Example 1 class Shared { int field=0; } 2 class Main { 3 static

Example 1 class Shared { int field=0; } 2 class Main { 3 static Shared s; 4 public static void main(String[] args) { 5 s = new Shared(); 6 s. field++; 7 Thread[] ta = new Thread[10]; 8 for(int i=0; i<10; i++) { 9 ta[i] = new Task 1(); 10 ta[i]. start(); 11 } 12 s. field++; 13 Thread t 2 = new Task 1(); 14 t 2. start(); 15 s. field++; 16 } 17 } 18 class Task 1 extends Thread { 19 public void run() { 20 Main. s. field++; 21 } 22 } 3/10/2021 LCPC'05 4

Thread Model n Abstract Thread (ti): n Compile-time entity that corresponds to invocation of

Thread Model n Abstract Thread (ti): n Compile-time entity that corresponds to invocation of Thread: : start in a context n is. Unique[ti] holds if ti has unique runtime correspondence n Intra-thread control flow graph, ICFG(ti) = <V(ti), E(ti)> V(ti) = USE(ti) 4 ASS(ti) 4 NEW(ti) 4 BEGIN(ti) 4 END(ti ) 4 ENTRY(ti ) 4 EXIT(ti) 4 CSTART(ti) 4 CJOIN(ti) 4 CALL(ti) 4 ACQUIRE(ti) 4 RELEASE(ti) contains both intra and inter procedural control flow edges locks[vi] denotes the set of objects that are locked while executing vi c. V(ti) 3/10/2021 LCPC'05 5

Program Representation n Must-join abstract thread (tj): CJOIN(ti, tj) postdom CSTART(tk, tj) and ti

Program Representation n Must-join abstract thread (tj): CJOIN(ti, tj) postdom CSTART(tk, tj) and ti = tk n Thread Creation Tree (TCT) n n n Encodes start relationship among abstract threads Nodes are abstract threads; Edges represent thread creation Nodes in TCT are colored black if it is not a must-join abstract thread yca(ti, tj) denotes the youngest common ancestor of ti and tj in TCT canc(ti, tj) denotes the child of ti that is an ancestor of tj 3/10/2021 LCPC'05 6

MHP Computation: n n Thread-level MHP (È t) Node-level MHP (È n) Thread-level MHP:

MHP Computation: n n Thread-level MHP (È t) Node-level MHP (È n) Thread-level MHP: ti È t tj = true, if ti c 3/10/2021 anc(tj ) or tj c LCPC'05 anc(ti ) 7

MHP Computation 3/10/2021 LCPC'05 8

MHP Computation 3/10/2021 LCPC'05 8

MHP Computation 3/10/2021 LCPC'05 9

MHP Computation 3/10/2021 LCPC'05 9

MHP Computation 3/10/2021 LCPC'05 10

MHP Computation 3/10/2021 LCPC'05 10

MHP Computation n Node-level MHP 3/10/2021 LCPC'05 11

MHP Computation n Node-level MHP 3/10/2021 LCPC'05 11

MHP Computation 3/10/2021 LCPC'05 12

MHP Computation 3/10/2021 LCPC'05 12

MHP Computation 3/10/2021 LCPC'05 13

MHP Computation 3/10/2021 LCPC'05 13

MHP Computation 3/10/2021 LCPC'05 14

MHP Computation 3/10/2021 LCPC'05 14

MHP Computation Algorithm 1. Identify abstract threads and their ICFGs. 2. for every abstract

MHP Computation Algorithm 1. Identify abstract threads and their ICFGs. 2. for every abstract thread ti do 3. Compute postdom for every node in Vi. 4. Compute reachability information. 5. for every child abstract thread tj of ti do 6. Compute start-dominance information w. r. to tj. 7. end for 8. Add a node to TCT. 9. end for 10. Compute must-join chains and yca information. 11. for all abstract thread ti do 12 for all abstract thread tj do 13 for all vim c. Vi do 14 for all vjn c. Vj do 15 Determine vim È vj n 16 end for 17 end for 18 end for 19 end for 3/10/2021 LCPC'05 15

Complexity Worst-case complexity is (k. N)2, where k is the number of abstract threads

Complexity Worst-case complexity is (k. N)2, where k is the number of abstract threads and N is the number of ICFG nodes per thread 3/10/2021 LCPC'05 16

Experimental Setup n Infrastructure n n n Benchmarks n n n ERCO (ETH Research

Experimental Setup n Infrastructure n n n Benchmarks n n n ERCO (ETH Research COmpiler at ETH, Zurich) Pentium IV at 2. 66 GHz on Red. Hat Linux Java Grande Forum Philo, tsp, elevator, sor and mtrt Comparison n Naumovich et al, our approach 3/10/2021 LCPC'05 17

Experimental Results 3/10/2021 LCPC'05 18

Experimental Results 3/10/2021 LCPC'05 18

Experimental Results 3/10/2021 LCPC'05 19

Experimental Results 3/10/2021 LCPC'05 19

Conclusion n n A new thread model based on context and flow sensitive analysis

Conclusion n n A new thread model based on context and flow sensitive analysis is presented. MHP computation is split into thread-level and node-level based on TCT and is obtained efficiently. TCT depicts interaction among threads and can perform various thread structure analysis. Our MHP algorithm is on an average 1. 77 x faster than Naumovich et al. 3/10/2021 LCPC'05 20