7 |
|
package java.util; |
8 |
|
|
9 |
|
import java.util.concurrent.CountedCompleter; |
10 |
+ |
import java.util.concurrent.ForkJoinPool; |
11 |
|
import java.util.function.BinaryOperator; |
12 |
|
import java.util.function.DoubleBinaryOperator; |
13 |
|
import java.util.function.IntBinaryOperator; |
80 |
|
T in, out; |
81 |
|
final int lo, hi, origin, fence, threshold; |
82 |
|
|
83 |
+ |
/** Root task constructor */ |
84 |
+ |
public CumulateTask(CumulateTask<T> parent, |
85 |
+ |
BinaryOperator<T> function, |
86 |
+ |
T[] array, int lo, int hi) { |
87 |
+ |
super(parent); |
88 |
+ |
this.function = function; this.array = array; |
89 |
+ |
this.lo = this.origin = lo; this.hi = this.fence = hi; |
90 |
+ |
int p; |
91 |
+ |
this.threshold = |
92 |
+ |
(p = (hi - lo) / (ForkJoinPool.getCommonPoolParallelism() << 3)) |
93 |
+ |
<= MIN_PARTITION ? MIN_PARTITION : p; |
94 |
+ |
} |
95 |
+ |
|
96 |
+ |
/** Subtask constructor */ |
97 |
|
CumulateTask(CumulateTask<T> parent, BinaryOperator<T> function, |
98 |
|
T[] array, int origin, int fence, int threshold, |
99 |
|
int lo, int hi) { |
118 |
|
int mid = (l + h) >>> 1; |
119 |
|
f = rt = t.right = |
120 |
|
new CumulateTask<T>(t, fn, a, org, fnc, th, mid, h); |
121 |
< |
t = lt = t.left = |
121 |
> |
t = lt = t.left = |
122 |
|
new CumulateTask<T>(t, fn, a, org, fnc, th, l, mid); |
123 |
|
} |
124 |
|
else { // possibly refork |
222 |
|
} |
223 |
|
} |
224 |
|
} |
225 |
+ |
// OPENJDK @java.io.Serial |
226 |
|
private static final long serialVersionUID = 5293554502939613543L; |
227 |
|
} |
228 |
|
|
233 |
|
long in, out; |
234 |
|
final int lo, hi, origin, fence, threshold; |
235 |
|
|
236 |
+ |
/** Root task constructor */ |
237 |
+ |
public LongCumulateTask(LongCumulateTask parent, |
238 |
+ |
LongBinaryOperator function, |
239 |
+ |
long[] array, int lo, int hi) { |
240 |
+ |
super(parent); |
241 |
+ |
this.function = function; this.array = array; |
242 |
+ |
this.lo = this.origin = lo; this.hi = this.fence = hi; |
243 |
+ |
int p; |
244 |
+ |
this.threshold = |
245 |
+ |
(p = (hi - lo) / (ForkJoinPool.getCommonPoolParallelism() << 3)) |
246 |
+ |
<= MIN_PARTITION ? MIN_PARTITION : p; |
247 |
+ |
} |
248 |
+ |
|
249 |
+ |
/** Subtask constructor */ |
250 |
|
LongCumulateTask(LongCumulateTask parent, LongBinaryOperator function, |
251 |
|
long[] array, int origin, int fence, int threshold, |
252 |
|
int lo, int hi) { |
271 |
|
int mid = (l + h) >>> 1; |
272 |
|
f = rt = t.right = |
273 |
|
new LongCumulateTask(t, fn, a, org, fnc, th, mid, h); |
274 |
< |
t = lt = t.left = |
274 |
> |
t = lt = t.left = |
275 |
|
new LongCumulateTask(t, fn, a, org, fnc, th, l, mid); |
276 |
|
} |
277 |
|
else { // possibly refork |
373 |
|
} |
374 |
|
} |
375 |
|
} |
376 |
+ |
// OPENJDK @java.io.Serial |
377 |
|
private static final long serialVersionUID = -5074099945909284273L; |
378 |
|
} |
379 |
|
|
384 |
|
double in, out; |
385 |
|
final int lo, hi, origin, fence, threshold; |
386 |
|
|
387 |
+ |
/** Root task constructor */ |
388 |
+ |
public DoubleCumulateTask(DoubleCumulateTask parent, |
389 |
+ |
DoubleBinaryOperator function, |
390 |
+ |
double[] array, int lo, int hi) { |
391 |
+ |
super(parent); |
392 |
+ |
this.function = function; this.array = array; |
393 |
+ |
this.lo = this.origin = lo; this.hi = this.fence = hi; |
394 |
+ |
int p; |
395 |
+ |
this.threshold = |
396 |
+ |
(p = (hi - lo) / (ForkJoinPool.getCommonPoolParallelism() << 3)) |
397 |
+ |
<= MIN_PARTITION ? MIN_PARTITION : p; |
398 |
+ |
} |
399 |
+ |
|
400 |
+ |
/** Subtask constructor */ |
401 |
|
DoubleCumulateTask(DoubleCumulateTask parent, DoubleBinaryOperator function, |
402 |
|
double[] array, int origin, int fence, int threshold, |
403 |
|
int lo, int hi) { |
422 |
|
int mid = (l + h) >>> 1; |
423 |
|
f = rt = t.right = |
424 |
|
new DoubleCumulateTask(t, fn, a, org, fnc, th, mid, h); |
425 |
< |
t = lt = t.left = |
425 |
> |
t = lt = t.left = |
426 |
|
new DoubleCumulateTask(t, fn, a, org, fnc, th, l, mid); |
427 |
|
} |
428 |
|
else { // possibly refork |
524 |
|
} |
525 |
|
} |
526 |
|
} |
527 |
+ |
// OPENJDK @java.io.Serial |
528 |
|
private static final long serialVersionUID = -586947823794232033L; |
529 |
|
} |
530 |
|
|
535 |
|
int in, out; |
536 |
|
final int lo, hi, origin, fence, threshold; |
537 |
|
|
538 |
+ |
/** Root task constructor */ |
539 |
+ |
public IntCumulateTask(IntCumulateTask parent, |
540 |
+ |
IntBinaryOperator function, |
541 |
+ |
int[] array, int lo, int hi) { |
542 |
+ |
super(parent); |
543 |
+ |
this.function = function; this.array = array; |
544 |
+ |
this.lo = this.origin = lo; this.hi = this.fence = hi; |
545 |
+ |
int p; |
546 |
+ |
this.threshold = |
547 |
+ |
(p = (hi - lo) / (ForkJoinPool.getCommonPoolParallelism() << 3)) |
548 |
+ |
<= MIN_PARTITION ? MIN_PARTITION : p; |
549 |
+ |
} |
550 |
+ |
|
551 |
+ |
/** Subtask constructor */ |
552 |
|
IntCumulateTask(IntCumulateTask parent, IntBinaryOperator function, |
553 |
|
int[] array, int origin, int fence, int threshold, |
554 |
|
int lo, int hi) { |
573 |
|
int mid = (l + h) >>> 1; |
574 |
|
f = rt = t.right = |
575 |
|
new IntCumulateTask(t, fn, a, org, fnc, th, mid, h); |
576 |
< |
t = lt = t.left = |
576 |
> |
t = lt = t.left = |
577 |
|
new IntCumulateTask(t, fn, a, org, fnc, th, l, mid); |
578 |
|
} |
579 |
|
else { // possibly refork |
675 |
|
} |
676 |
|
} |
677 |
|
} |
678 |
+ |
// OPENJDK @java.io.Serial |
679 |
|
private static final long serialVersionUID = 3731755594596840961L; |
680 |
|
} |
620 |
– |
|
681 |
|
} |