Download presentation
Presentation is loading. Please wait.
Published byPiers Preston Modified over 9 years ago
1
Sep/05/2001PaCT 20011 Fusion of Concurrent Invocations of Exclusive Methods Yoshihiro Oyama (Japan Science and Technology Corporation, working in University of Tsukuba) Kenjiro Taura Akinori Yonezawa (University of Tokyo)
2
Sep/05/2001PaCT 20012 Context of This Work Languages OO languages + concurrent extension (ex. Java) Concurrent OO languages Machines Shared-memory parallel computers SMP cc-NUMA MP
3
Sep/05/2001PaCT 20013 Exclusive Methods Methods that are executed exclusively Ex: synchronized methods in Java Concurrent invocations serialized and executed in turn
4
Sep/05/2001PaCT 20014 Problem Low scalability Reason: serialization of concurrent invocations Amdahl’s law 5% is sequential speedup < 20 time #procs
5
Sep/05/2001PaCT 20015 Goal of This Work Fusion of concurrent invocations (method fusion) Ex: “plus(1)” + “plus(2)” = “plus(3)” Fusing two invocations that are serialized dynamically Reducing the number of executions of exclusive methods eliminating bottlenecks
6
Sep/05/2001PaCT 20016 Example class Counter { int val; … sync void inc(int n) { val += n; } } inc(10); inc(20); can be emulated with inc(30); observation fusion inc(x) & inc(y) { inc(x + y); }
7
Sep/05/2001PaCT 20017 Outline of Presentation Language design API Sample programs Details of design Discussion Implementation Experimental results Related work
8
Sep/05/2001PaCT 20018 Target Language C++ - Inheritance + Thread creation + Exclusive methods + Fusion rules
9
Sep/05/2001PaCT 20019 API (1/2) Syntax Semantics Invocations of p and q may be replaced with S S is executed concurrently with other exclusive methods on the same object fusion p(x 1,…, x n ) & q(y 1,…, y n ) { S; }
10
Sep/05/2001PaCT 200110 API (2/2) Return value fusion p(x 1,…, x n ) & q(y 1,…, y n ) { … mreturn a and b; } To p’s caller To q’s caller
11
Sep/05/2001PaCT 200111 Sample Program (1/2) class Buffer { int len; double elems[…];... sync void put (double f) { elems[len++] = f; } sync double get (void) { return elems[--len]; } fusion put(f) & get() { return f; } } “Bypassing” put and get
12
Sep/05/2001PaCT 200112 Sample Program (2/2) class Window { … fusion resize(x1, y1) & resize(x2, y2) { resize(x1, y1); } fusion repaint() & repaint() { repaint(); } We can easily describe the specification for omitting GUI events
13
Sep/05/2001PaCT 200113 Sample Program (2/2) Existing technique Programmers describe the detail implementation of event-queues Our technique Programmers describe only the specifications of event-queues
14
Sep/05/2001PaCT 200114 What is Fused? What is not? Two dynamically-serialized invocations Dynamic occurrence of the execution of two consecutive exclusive methods Static fusion not supported c->inc(10); c->inc(20);
15
Sep/05/2001PaCT 200115 Discussion How and where we intend method fusion is used This work from wider view
16
Sep/05/2001PaCT 200116 How and Where We Intend Method Fusion is Used Fusion rules should be “performance hints” Should not change the behavior i.e., whether method fusion happened should not be observable “transparent” fusion rules
17
Sep/05/2001PaCT 200117 But Currently... Our compiler accepts non-transparent fusion rules No check for transparency Fusion rules may bring bugs fusion inc(x) & inc(y) { inc(x - y); }
18
Sep/05/2001PaCT 200118 This Work from Wider View (1/2) Found new optimization for parallel langs Sequential langs: Parallel langs: control flow not in program texts Overlooked in existing works x = y-2; x += 3; x = y+1; val +=1; val +=2; val +=3;
19
Sep/05/2001PaCT 200119 This Work from Wider View (2/2) Proposed useful and novel API for optimizing programs with human’s help cf. parallel for, register, inline Technical challenge we addressed: What kind of API is Easy-to-use? Useful for speedup?
20
Sep/05/2001PaCT 200120 Implementation Lock is added to each object Exclusive methods are serialized with locks Acquires lock Executes exclusive methods Releases lock
21
Sep/05/2001PaCT 200121 Object Representation FREE LOCKED Task = data structure storing info. of invocation Lock = flag + queue
22
Sep/05/2001PaCT 200122 Implementation of Method Fusion LOCKED inc (y) thread Xthread Y inc (x) thread Z
23
Sep/05/2001PaCT 200123 Implementation of Method Fusion LOCKED inc (y) thread X inc (x) thread Z thread Y
24
Sep/05/2001PaCT 200124 Implementation of Method Fusion LOCKED thread Z thread Xthread Y ST
25
Sep/05/2001PaCT 200125 Implementation of Method Fusion LOCKED inc (x+y) thread Z thread Xthread Y ST
26
Sep/05/2001PaCT 200126 Implementation of Method Fusion LOCKED thread Y T thread X S inc(x+y)
27
Sep/05/2001PaCT 200127 Implementation of Method Fusion FREE thread Y T thread X S Ret. val. 1 Ret. val. 2 Ret. val. 1
28
Sep/05/2001PaCT 200128 Experiment We implemented a compiler of the language Sun Ultra Enterprise 10000 (64 CPUs) Applications: Counter: inc(x) & inc(y) inc(x+y) FileWriter: write(str1) & write(str2) write(str) FileReader: get(path1) & get(path2) get(path1) ImageViewer: repaint() & repaint() repaint()
29
Sep/05/2001PaCT 200129 Experiment Implemented exclusive methods in 4 ways Spin-locks Mutex locks provided by OS Our locks (w/o fusion rules) Our locks (with fusion rules)
30
Sep/05/2001PaCT 200130 FileReader
31
Sep/05/2001PaCT 200131 ImageViewer
32
Sep/05/2001PaCT 200132 FileWriter
33
Sep/05/2001PaCT 200133 Counter
34
Sep/05/2001PaCT 200134 Related Work (1/2) Concurrent execution of associative exclusive operations Reduction, Concurrent Aggregates (CA) [Chien 91], Adaptive Replication [Rinard et al. 99], Program fusion [Hu et al. 99] Partial results are stored in multiple data area Ours: stored in method arguments Timing to summarize partial data is obvious Ours: obviousness not assumed summarize immediately
35
Sep/05/2001PaCT 200135 Related Work (2/2) Network combining [Gottlieb et al. 83] Fusing machine instructions Ours: fusing method invocations Composite functions [Bird 89], [Fisher et al. 94] (map f) ・ (map g) = (map f ・ g) Static fusion of statically-detected consecutive ops Ours: dynamic fusion of dynamically-detected consecutive ops Runtime overhead ⇔ applicability of fusion
36
Sep/05/2001PaCT 200136 Future Work Analysis of transparency fusion inc(x) & inc(y) { inc(x - y); } Inheritance What if fused method is overridden? Parallel fusions on a single object Using (v + x) + y ≠ v + (x - y) ?
37
Sep/05/2001PaCT 200137 Concluding Remarks First proposed new optimization for parallel languages Various studies related to method fusion Language design and implementation scheme Many sample programs (see our paper) Experiments
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.