11 |
|
// parallel sums and cumulations |
12 |
|
|
13 |
|
public class FJSums { |
14 |
– |
static final long NPS = (1000L * 1000 * 1000); |
14 |
|
static int THRESHOLD; |
15 |
+ |
static final int MIN_PARTITION = 64; |
16 |
+ |
|
17 |
+ |
interface LongByLongToLong { long apply(long a, long b); } |
18 |
+ |
|
19 |
+ |
static final class Add implements LongByLongToLong { |
20 |
+ |
public long apply(long a, long b) { return a + b; } |
21 |
+ |
} |
22 |
+ |
|
23 |
+ |
static final Add ADD = new Add(); |
24 |
|
|
25 |
|
public static void main(String[] args) throws Exception { |
18 |
– |
int procs = 0; |
26 |
|
int n = 1 << 25; |
27 |
|
int reps = 10; |
28 |
|
try { |
29 |
|
if (args.length > 0) |
30 |
< |
procs = Integer.parseInt(args[0]); |
30 |
> |
n = Integer.parseInt(args[0]); |
31 |
|
if (args.length > 1) |
32 |
< |
n = Integer.parseInt(args[1]); |
26 |
< |
if (args.length > 2) |
27 |
< |
reps = Integer.parseInt(args[2]); |
32 |
> |
reps = Integer.parseInt(args[1]); |
33 |
|
} |
34 |
|
catch (Exception e) { |
35 |
< |
System.out.println("Usage: java FJSums threads n reps"); |
35 |
> |
System.out.println("Usage: java FJSums n reps"); |
36 |
|
return; |
37 |
|
} |
38 |
< |
ForkJoinPool g = (procs == 0) ? new ForkJoinPool() : |
39 |
< |
new ForkJoinPool(procs); |
40 |
< |
System.out.println("Number of procs=" + g.getParallelism()); |
41 |
< |
// for now hardwire Cumulate threshold to 8 * #CPUs leaf tasks |
37 |
< |
THRESHOLD = 1 + ((n + 7) >>> 3) / g.getParallelism(); |
38 |
> |
int par = ForkJoinPool.getCommonPoolParallelism(); |
39 |
> |
System.out.println("Number of procs=" + par); |
40 |
> |
int p; |
41 |
> |
THRESHOLD = (p = n / (par << 3)) <= MIN_PARTITION ? MIN_PARTITION : p; |
42 |
|
|
43 |
|
long[] a = new long[n]; |
44 |
|
for (int i = 0; i < n; ++i) |
45 |
|
a[i] = i; |
46 |
|
long expected = ((long)n * (long)(n - 1)) / 2; |
43 |
– |
for (int i = 0; i < 2; ++i) { |
44 |
– |
System.out.print("Seq: "); |
45 |
– |
long last = System.nanoTime(); |
46 |
– |
long ss = seqSum(a, 0, n); |
47 |
– |
double elapsed = elapsedTime(last); |
48 |
– |
System.out.printf("sum = %24d time: %7.3f\n", ss, elapsed); |
49 |
– |
if (ss != expected) |
50 |
– |
throw new Error("expected " + expected + " != " + ss); |
51 |
– |
} |
47 |
|
for (int i = 0; i < reps; ++i) { |
48 |
< |
System.out.print("Par: "); |
49 |
< |
long last = System.nanoTime(); |
55 |
< |
Summer s = new Summer(a, 0, a.length, null); |
56 |
< |
g.invoke(s); |
57 |
< |
long ss = s.result; |
58 |
< |
double elapsed = elapsedTime(last); |
59 |
< |
System.out.printf("sum = %24d time: %7.3f\n", ss, elapsed); |
60 |
< |
if (i == 0 && ss != expected) |
61 |
< |
throw new Error("expected " + expected + " != " + ss); |
62 |
< |
System.out.print("Cum: "); |
63 |
< |
last = System.nanoTime(); |
64 |
< |
g.invoke(new Cumulater(null, a, 0, n)); |
65 |
< |
long sc = a[n - 1]; |
66 |
< |
elapsed = elapsedTime(last); |
67 |
< |
System.out.printf("sum = %24d time: %7.3f\n", ss, elapsed); |
68 |
< |
if (sc != ss) |
69 |
< |
throw new Error("expected " + ss + " != " + sc); |
48 |
> |
seqTest(a, i, expected); |
49 |
> |
parTest(a, i, expected); |
50 |
|
} |
51 |
< |
System.out.println(g); |
72 |
< |
g.shutdown(); |
51 |
> |
System.out.println(ForkJoinPool.commonPool()); |
52 |
|
} |
53 |
|
|
54 |
< |
static double elapsedTime(long startTime) { |
55 |
< |
return (double)(System.nanoTime() - startTime) / NPS; |
54 |
> |
static void seqTest(long[] a, int index, long expected) { |
55 |
> |
System.out.print("Seq "); |
56 |
> |
long last = System.nanoTime(); |
57 |
> |
int n = a.length; |
58 |
> |
long ss = seqSum(ADD, 0L, a, 0, n); |
59 |
> |
double elapsed = elapsedTime(last); |
60 |
> |
System.out.printf("sum = %24d time: %7.3f\n", ss, elapsed); |
61 |
> |
if (index == 0 && ss != expected) |
62 |
> |
throw new Error("expected " + expected + " != " + ss); |
63 |
|
} |
64 |
|
|
65 |
< |
static long seqSum(long[] array, int l, int h) { |
66 |
< |
long sum = 0; |
67 |
< |
for (int i = l; i < h; ++i) |
68 |
< |
sum += array[i]; |
69 |
< |
return sum; |
65 |
> |
static void parTest(long[] a, int index, long expected) { |
66 |
> |
System.out.print("Par "); |
67 |
> |
long last = System.nanoTime(); |
68 |
> |
int n = a.length; |
69 |
> |
Summer s = new Summer(null, ADD, 0L, a, 0, n, null); |
70 |
> |
s.invoke(); |
71 |
> |
long ss = s.result; |
72 |
> |
double elapsed = elapsedTime(last); |
73 |
> |
System.out.printf("sum = %24d time: %7.3f\n", ss, elapsed); |
74 |
> |
if (index == 0 && ss != expected) |
75 |
> |
throw new Error("expected " + expected + " != " + ss); |
76 |
> |
System.out.print("Par "); |
77 |
> |
last = System.nanoTime(); |
78 |
> |
new Cumulater(null, ADD, a, 0, n).invoke(); |
79 |
> |
long sc = a[n - 1]; |
80 |
> |
elapsed = elapsedTime(last); |
81 |
> |
System.out.printf("cum = %24d time: %7.3f\n", ss, elapsed); |
82 |
> |
if (sc != ss) |
83 |
> |
throw new Error("expected " + ss + " != " + sc); |
84 |
> |
if (index == 0) { |
85 |
> |
long cs = 0L; |
86 |
> |
for (int j = 0; j < n; ++j) { |
87 |
> |
if ((cs += j) != a[j]) |
88 |
> |
throw new Error("wrong element value"); |
89 |
> |
} |
90 |
> |
} |
91 |
|
} |
92 |
|
|
93 |
< |
static long seqCumulate(long[] array, int lo, int hi, long base) { |
94 |
< |
long sum = base; |
88 |
< |
for (int i = lo; i < hi; ++i) |
89 |
< |
array[i] = sum += array[i]; |
90 |
< |
return sum; |
93 |
> |
static double elapsedTime(long startTime) { |
94 |
> |
return (double)(System.nanoTime() - startTime) / (1000L * 1000 * 1000); |
95 |
|
} |
96 |
|
|
97 |
< |
/** |
98 |
< |
* Adapted from Applyer demo in RecursiveAction docs |
99 |
< |
*/ |
100 |
< |
static final class Summer extends RecursiveAction { |
101 |
< |
final long[] array; |
102 |
< |
final int lo, hi; |
99 |
< |
long result; |
100 |
< |
Summer next; // keeps track of right-hand-side tasks |
101 |
< |
Summer(long[] array, int lo, int hi, Summer next) { |
102 |
< |
this.array = array; this.lo = lo; this.hi = hi; |
103 |
< |
this.next = next; |
104 |
< |
} |
105 |
< |
|
106 |
< |
protected void compute() { |
107 |
< |
int l = lo; |
108 |
< |
int h = hi; |
109 |
< |
Summer right = null; |
110 |
< |
while (h - l > 1 && getSurplusQueuedTaskCount() <= 3) { |
111 |
< |
int mid = (l + h) >>> 1; |
112 |
< |
right = new Summer(array, mid, h, right); |
113 |
< |
right.fork(); |
114 |
< |
h = mid; |
115 |
< |
} |
116 |
< |
long sum = seqSum(array, l, h); |
117 |
< |
while (right != null) { |
118 |
< |
if (right.tryUnfork()) // directly calculate if not stolen |
119 |
< |
sum += seqSum(array, right.lo, right.hi); |
120 |
< |
else { |
121 |
< |
right.join(); |
122 |
< |
sum += right.result; |
123 |
< |
} |
124 |
< |
right = right.next; |
125 |
< |
} |
126 |
< |
result = sum; |
127 |
< |
} |
97 |
> |
static long seqSum(LongByLongToLong fn, long basis, |
98 |
> |
long[] a, int l, int h) { |
99 |
> |
long sum = basis; |
100 |
> |
for (int i = l; i < h; ++i) |
101 |
> |
sum = fn.apply(sum, a[i]); |
102 |
> |
return sum; |
103 |
|
} |
104 |
|
|
105 |
|
/** |
112 |
|
* See G. Blelloch's http://www.cs.cmu.edu/~scandal/alg/scan.html |
113 |
|
* |
114 |
|
* This version improves performance within FJ framework mainly by |
115 |
< |
* allowing second pass of ready left-hand sides to proceed even |
116 |
< |
* if some right-hand side first passes are still executing. It |
117 |
< |
* also combines first and second pass for leftmost segment, and |
118 |
< |
* for cumulate (not precumulate) also skips first pass for |
119 |
< |
* rightmost segment (whose result is not needed for second pass). |
115 |
> |
* allowing the second pass of ready left-hand sides to proceed |
116 |
> |
* even if some right-hand side first passes are still executing. |
117 |
> |
* It also combines first and second pass for leftmost segment, |
118 |
> |
* and skips the first pass for rightmost segment (whose result is |
119 |
> |
* not needed for second pass). |
120 |
|
* |
121 |
< |
* To manage this, it relies on "phase" phase/state control field |
122 |
< |
* maintaining bits CUMULATE, SUMMED, and FINISHED. CUMULATE is |
121 |
> |
* Managing this relies on ORing some bits in the pendingCount for |
122 |
> |
* phases/states: CUMULATE, SUMMED, and FINISHED. CUMULATE is the |
123 |
|
* main phase bit. When false, segments compute only their sum. |
124 |
|
* When true, they cumulate array elements. CUMULATE is set at |
125 |
|
* root at beginning of second pass and then propagated down. But |
126 |
< |
* it may also be set earlier for subtrees with lo==0 (the |
127 |
< |
* left spine of tree). SUMMED is a one bit join count. For leafs, |
128 |
< |
* set when summed. For internal nodes, becomes true when one |
129 |
< |
* child is summed. When second child finishes summing, it then |
130 |
< |
* moves up tree to trigger cumulate phase. FINISHED is also a one |
131 |
< |
* bit join count. For leafs, it is set when cumulated. For |
132 |
< |
* internal nodes, it becomes true when one child is cumulated. |
133 |
< |
* When second child finishes cumulating, it then moves up tree, |
134 |
< |
* executing complete() at the root. |
126 |
> |
* it may also be set earlier for subtrees with lo==0 (the left |
127 |
> |
* spine of tree). SUMMED is a one bit join count. For leafs, it |
128 |
> |
* is set when summed. For internal nodes, it becomes true when |
129 |
> |
* one child is summed. When the second child finishes summing, |
130 |
> |
* we then moves up tree to trigger the cumulate phase. FINISHED |
131 |
> |
* is also a one bit join count. For leafs, it is set when |
132 |
> |
* cumulated. For internal nodes, it becomes true when one child |
133 |
> |
* is cumulated. When the second child finishes cumulating, it |
134 |
> |
* then moves up tree, completing at the root. |
135 |
|
* |
136 |
+ |
* To better exploit locality and reduce overhead, the compute |
137 |
+ |
* method loops starting with the current task, moving if possible |
138 |
+ |
* to one of its subtasks rather than forking. |
139 |
|
*/ |
140 |
< |
static final class Cumulater extends ForkJoinTask<Void> { |
141 |
< |
static final short CUMULATE = (short)1; |
142 |
< |
static final short SUMMED = (short)2; |
143 |
< |
static final short FINISHED = (short)4; |
140 |
> |
static final class Cumulater extends CountedCompleter<Void> { |
141 |
> |
static final int CUMULATE = 1; |
142 |
> |
static final int SUMMED = 2; |
143 |
> |
static final int FINISHED = 4; |
144 |
|
|
167 |
– |
final Cumulater parent; |
145 |
|
final long[] array; |
146 |
+ |
final LongByLongToLong function; |
147 |
|
Cumulater left, right; |
148 |
< |
final int lo; |
149 |
< |
final int hi; |
172 |
< |
volatile int phase; // phase/state |
173 |
< |
long in, out; // initially zero |
174 |
< |
|
175 |
< |
static final AtomicIntegerFieldUpdater<Cumulater> phaseUpdater = |
176 |
< |
AtomicIntegerFieldUpdater.newUpdater(Cumulater.class, "phase"); |
177 |
< |
|
178 |
< |
Cumulater(Cumulater parent, long[] array, int lo, int hi) { |
179 |
< |
this.parent = parent; |
180 |
< |
this.array = array; |
181 |
< |
this.lo = lo; |
182 |
< |
this.hi = hi; |
183 |
< |
} |
184 |
< |
|
185 |
< |
public final Void getRawResult() { return null; } |
186 |
< |
protected final void setRawResult(Void mustBeNull) { } |
148 |
> |
final int lo, hi; |
149 |
> |
long in, out; |
150 |
|
|
151 |
< |
/** Returns true if can CAS CUMULATE bit true */ |
152 |
< |
final boolean transitionToCumulate() { |
153 |
< |
int c; |
154 |
< |
while (((c = phase) & CUMULATE) == 0) |
155 |
< |
if (phaseUpdater.compareAndSet(this, c, c | CUMULATE)) |
193 |
< |
return true; |
194 |
< |
return false; |
151 |
> |
Cumulater(Cumulater parent, LongByLongToLong function, |
152 |
> |
long[] array, int lo, int hi) { |
153 |
> |
super(parent); |
154 |
> |
this.function = function; this.array = array; |
155 |
> |
this.lo = lo; this.hi = hi; |
156 |
|
} |
157 |
|
|
158 |
< |
public final boolean exec() { |
159 |
< |
if (hi - lo > THRESHOLD) { |
160 |
< |
if (left == null) { // first pass |
161 |
< |
int mid = (lo + hi) >>> 1; |
162 |
< |
left = new Cumulater(this, array, lo, mid); |
163 |
< |
right = new Cumulater(this, array, mid, hi); |
164 |
< |
} |
165 |
< |
|
166 |
< |
boolean cumulate = (phase & CUMULATE) != 0; |
167 |
< |
if (cumulate) { |
168 |
< |
long pin = in; |
169 |
< |
left.in = pin; |
170 |
< |
right.in = pin + left.out; |
171 |
< |
} |
172 |
< |
|
173 |
< |
if (!cumulate || right.transitionToCumulate()) |
174 |
< |
right.fork(); |
175 |
< |
if (!cumulate || left.transitionToCumulate()) |
176 |
< |
left.exec(); |
177 |
< |
} |
178 |
< |
else { |
179 |
< |
int cb; |
180 |
< |
for (;;) { // Establish action: sum, cumulate, or both |
181 |
< |
int b = phase; |
182 |
< |
if ((b & FINISHED) != 0) // already done |
183 |
< |
return false; |
184 |
< |
if ((b & CUMULATE) != 0) |
185 |
< |
cb = FINISHED; |
186 |
< |
else if (lo == 0) // combine leftmost |
187 |
< |
cb = (SUMMED|FINISHED); |
188 |
< |
else |
189 |
< |
cb = SUMMED; |
190 |
< |
if (phaseUpdater.compareAndSet(this, b, b|cb)) |
191 |
< |
break; |
158 |
> |
public final void compute() { |
159 |
> |
final LongByLongToLong fn; |
160 |
> |
final long[] a; |
161 |
> |
if ((fn = this.function) == null || (a = this.array) == null) |
162 |
> |
throw new NullPointerException(); // hoist checks |
163 |
> |
int l, h; |
164 |
> |
Cumulater t = this; |
165 |
> |
outer: while ((l = t.lo) >= 0 && (h = t.hi) <= a.length) { |
166 |
> |
if (h - l > THRESHOLD) { |
167 |
> |
Cumulater lt = t.left, rt = t.right, f; |
168 |
> |
if (lt == null) { // first pass |
169 |
> |
int mid = (l + h) >>> 1; |
170 |
> |
f = rt = t.right = new Cumulater(t, fn, a, mid, h); |
171 |
> |
t = lt = t.left = new Cumulater(t, fn, a, l, mid); |
172 |
> |
} |
173 |
> |
else { // possibly refork |
174 |
> |
long pin = t.in; |
175 |
> |
lt.in = pin; |
176 |
> |
f = t = null; |
177 |
> |
if (rt != null) { |
178 |
> |
rt.in = fn.apply(pin, lt.out); |
179 |
> |
for (int c;;) { |
180 |
> |
if (((c = rt.getPendingCount()) & CUMULATE) != 0) |
181 |
> |
break; |
182 |
> |
if (rt.compareAndSetPendingCount(c, c|CUMULATE)){ |
183 |
> |
t = rt; |
184 |
> |
break; |
185 |
> |
} |
186 |
> |
} |
187 |
> |
} |
188 |
> |
for (int c;;) { |
189 |
> |
if (((c = lt.getPendingCount()) & CUMULATE) != 0) |
190 |
> |
break; |
191 |
> |
if (lt.compareAndSetPendingCount(c, c|CUMULATE)) { |
192 |
> |
if (t != null) |
193 |
> |
f = t; |
194 |
> |
t = lt; |
195 |
> |
break; |
196 |
> |
} |
197 |
> |
} |
198 |
> |
if (t == null) |
199 |
> |
break; |
200 |
> |
} |
201 |
> |
if (f != null) |
202 |
> |
f.fork(); |
203 |
|
} |
204 |
+ |
else { |
205 |
+ |
int state; // Transition to sum, cumulate, or both |
206 |
+ |
for (int b;;) { |
207 |
+ |
if (((b = t.getPendingCount()) & FINISHED) != 0) |
208 |
+ |
break outer; // already done |
209 |
+ |
state = (((b & CUMULATE) != 0) |
210 |
+ |
? FINISHED |
211 |
+ |
: (l > 0) ? SUMMED : (SUMMED|FINISHED)); |
212 |
+ |
if (t.compareAndSetPendingCount(b, b|state)) |
213 |
+ |
break; |
214 |
+ |
} |
215 |
|
|
216 |
< |
if (cb == SUMMED) |
217 |
< |
out = seqSum(array, lo, hi); |
218 |
< |
else if (cb == FINISHED) |
219 |
< |
seqCumulate(array, lo, hi, in); |
237 |
< |
else if (cb == (SUMMED|FINISHED)) |
238 |
< |
out = seqCumulate(array, lo, hi, 0L); |
239 |
< |
|
240 |
< |
// propagate up |
241 |
< |
Cumulater ch = this; |
242 |
< |
Cumulater par = parent; |
243 |
< |
for (;;) { |
244 |
< |
if (par == null) { |
245 |
< |
if ((cb & FINISHED) != 0) |
246 |
< |
ch.complete(null); |
247 |
< |
break; |
216 |
> |
long sum = t.in; |
217 |
> |
if (state != SUMMED) { |
218 |
> |
for (int i = l; i < h; ++i) // cumulate |
219 |
> |
a[i] = sum = fn.apply(sum, a[i]); |
220 |
|
} |
221 |
< |
int pb = par.phase; |
222 |
< |
if ((pb & cb & FINISHED) != 0) { // both finished |
223 |
< |
ch = par; |
252 |
< |
par = par.parent; |
221 |
> |
else if (h < a.length) { // skip rightmost |
222 |
> |
for (int i = l; i < h; ++i) // sum only |
223 |
> |
sum = fn.apply(sum, a[i]); |
224 |
|
} |
225 |
< |
else if ((pb & cb & SUMMED) != 0) { // both summed |
226 |
< |
par.out = par.left.out + par.right.out; |
227 |
< |
int refork = |
228 |
< |
((pb & CUMULATE) == 0 && |
229 |
< |
par.lo == 0) ? CUMULATE : 0; |
230 |
< |
int nextPhase = pb|cb|refork; |
260 |
< |
if (pb == nextPhase || |
261 |
< |
phaseUpdater.compareAndSet(par, pb, nextPhase)) { |
262 |
< |
if (refork != 0) |
263 |
< |
par.fork(); |
264 |
< |
cb = SUMMED; // drop finished bit |
265 |
< |
ch = par; |
266 |
< |
par = par.parent; |
225 |
> |
t.out = sum; |
226 |
> |
for (Cumulater par;;) { // propagate |
227 |
> |
if ((par = (Cumulater)t.getCompleter()) == null) { |
228 |
> |
if ((state & FINISHED) != 0) // enable join |
229 |
> |
t.quietlyComplete(); |
230 |
> |
break outer; |
231 |
|
} |
232 |
+ |
int b = par.getPendingCount(); |
233 |
+ |
if ((b & state & FINISHED) != 0) |
234 |
+ |
t = par; // both done |
235 |
+ |
else if ((b & state & SUMMED) != 0) { // both summed |
236 |
+ |
int nextState; Cumulater lt, rt; |
237 |
+ |
if ((lt = par.left) != null && |
238 |
+ |
(rt = par.right) != null) |
239 |
+ |
par.out = fn.apply(lt.out, rt.out); |
240 |
+ |
int refork = (((b & CUMULATE) == 0 && |
241 |
+ |
par.lo == 0) ? CUMULATE : 0); |
242 |
+ |
if ((nextState = b|state|refork) == b || |
243 |
+ |
par.compareAndSetPendingCount(b, nextState)) { |
244 |
+ |
state = SUMMED; // drop finished |
245 |
+ |
t = par; |
246 |
+ |
if (refork != 0) |
247 |
+ |
par.fork(); |
248 |
+ |
} |
249 |
+ |
} |
250 |
+ |
else if (par.compareAndSetPendingCount(b, b|state)) |
251 |
+ |
break outer; // sib not ready |
252 |
|
} |
269 |
– |
else if (phaseUpdater.compareAndSet(par, pb, pb|cb)) |
270 |
– |
break; |
253 |
|
} |
254 |
|
} |
273 |
– |
return false; |
255 |
|
} |
256 |
+ |
} |
257 |
|
|
258 |
+ |
// Uses CC reduction via firstComplete/nextComplete |
259 |
+ |
static final class Summer extends CountedCompleter<Void> { |
260 |
+ |
final long[] array; |
261 |
+ |
final LongByLongToLong function; |
262 |
+ |
final int lo, hi; |
263 |
+ |
final long basis; |
264 |
+ |
long result; |
265 |
+ |
Summer forks, next; // keeps track of right-hand-side tasks |
266 |
+ |
Summer(Summer parent, LongByLongToLong function, long basis, |
267 |
+ |
long[] array, int lo, int hi, Summer next) { |
268 |
+ |
super(parent); |
269 |
+ |
this.function = function; this.basis = basis; |
270 |
+ |
this.array = array; this.lo = lo; this.hi = hi; |
271 |
+ |
this.next = next; |
272 |
+ |
} |
273 |
+ |
|
274 |
+ |
public final void compute() { |
275 |
+ |
final long id = basis; |
276 |
+ |
final LongByLongToLong fn; |
277 |
+ |
final long[] a; |
278 |
+ |
if ((fn = this.function) == null || (a = this.array) == null) |
279 |
+ |
throw new NullPointerException(); |
280 |
+ |
int l = lo, h = hi; |
281 |
+ |
while (h - l >= THRESHOLD) { |
282 |
+ |
int mid = (l + h) >>> 1; |
283 |
+ |
addToPendingCount(1); |
284 |
+ |
(forks = new Summer(this, fn, id, a, mid, h, forks)).fork(); |
285 |
+ |
h = mid; |
286 |
+ |
} |
287 |
+ |
long sum = id; |
288 |
+ |
if (l < h && l >= 0 && h <= a.length) { |
289 |
+ |
for (int i = l; i < h; ++i) |
290 |
+ |
sum = fn.apply(sum, a[i]); |
291 |
+ |
} |
292 |
+ |
result = sum; |
293 |
+ |
CountedCompleter<?> c; |
294 |
+ |
for (c = firstComplete(); c != null; c = c.nextComplete()) { |
295 |
+ |
Summer t = (Summer)c, s = t.forks; |
296 |
+ |
while (s != null) { |
297 |
+ |
t.result = fn.apply(t.result, s.result); |
298 |
+ |
s = t.forks = s.next; |
299 |
+ |
} |
300 |
+ |
} |
301 |
+ |
} |
302 |
|
} |
303 |
|
|
304 |
|
} |