7 |
|
package java.util; |
8 |
|
|
9 |
|
import java.util.concurrent.CountedCompleter; |
10 |
– |
import java.util.concurrent.ForkJoinPool; |
10 |
|
import java.util.function.BinaryOperator; |
11 |
|
import java.util.function.DoubleBinaryOperator; |
12 |
|
import java.util.function.IntBinaryOperator; |
79 |
|
T in, out; |
80 |
|
final int lo, hi, origin, fence, threshold; |
81 |
|
|
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 */ |
82 |
|
CumulateTask(CumulateTask<T> parent, BinaryOperator<T> function, |
83 |
|
T[] array, int origin, int fence, int threshold, |
84 |
|
int lo, int hi) { |
217 |
|
long in, out; |
218 |
|
final int lo, hi, origin, fence, threshold; |
219 |
|
|
235 |
– |
/** Root task constructor */ |
236 |
– |
public LongCumulateTask(LongCumulateTask parent, |
237 |
– |
LongBinaryOperator function, |
238 |
– |
long[] array, int lo, int hi) { |
239 |
– |
super(parent); |
240 |
– |
this.function = function; this.array = array; |
241 |
– |
this.lo = this.origin = lo; this.hi = this.fence = hi; |
242 |
– |
int p; |
243 |
– |
this.threshold = |
244 |
– |
(p = (hi - lo) / (ForkJoinPool.getCommonPoolParallelism() << 3)) |
245 |
– |
<= MIN_PARTITION ? MIN_PARTITION : p; |
246 |
– |
} |
247 |
– |
|
248 |
– |
/** Subtask constructor */ |
220 |
|
LongCumulateTask(LongCumulateTask parent, LongBinaryOperator function, |
221 |
|
long[] array, int origin, int fence, int threshold, |
222 |
|
int lo, int hi) { |
353 |
|
double in, out; |
354 |
|
final int lo, hi, origin, fence, threshold; |
355 |
|
|
385 |
– |
/** Root task constructor */ |
386 |
– |
public DoubleCumulateTask(DoubleCumulateTask parent, |
387 |
– |
DoubleBinaryOperator function, |
388 |
– |
double[] array, int lo, int hi) { |
389 |
– |
super(parent); |
390 |
– |
this.function = function; this.array = array; |
391 |
– |
this.lo = this.origin = lo; this.hi = this.fence = hi; |
392 |
– |
int p; |
393 |
– |
this.threshold = |
394 |
– |
(p = (hi - lo) / (ForkJoinPool.getCommonPoolParallelism() << 3)) |
395 |
– |
<= MIN_PARTITION ? MIN_PARTITION : p; |
396 |
– |
} |
397 |
– |
|
398 |
– |
/** Subtask constructor */ |
356 |
|
DoubleCumulateTask(DoubleCumulateTask parent, DoubleBinaryOperator function, |
357 |
< |
double[] array, int origin, int fence, int threshold, |
358 |
< |
int lo, int hi) { |
357 |
> |
double[] array, int origin, int fence, int threshold, |
358 |
> |
int lo, int hi) { |
359 |
|
super(parent); |
360 |
|
this.function = function; this.array = array; |
361 |
|
this.origin = origin; this.fence = fence; |
489 |
|
int in, out; |
490 |
|
final int lo, hi, origin, fence, threshold; |
491 |
|
|
535 |
– |
/** Root task constructor */ |
536 |
– |
public IntCumulateTask(IntCumulateTask parent, |
537 |
– |
IntBinaryOperator function, |
538 |
– |
int[] array, int lo, int hi) { |
539 |
– |
super(parent); |
540 |
– |
this.function = function; this.array = array; |
541 |
– |
this.lo = this.origin = lo; this.hi = this.fence = hi; |
542 |
– |
int p; |
543 |
– |
this.threshold = |
544 |
– |
(p = (hi - lo) / (ForkJoinPool.getCommonPoolParallelism() << 3)) |
545 |
– |
<= MIN_PARTITION ? MIN_PARTITION : p; |
546 |
– |
} |
547 |
– |
|
548 |
– |
/** Subtask constructor */ |
492 |
|
IntCumulateTask(IntCumulateTask parent, IntBinaryOperator function, |
493 |
< |
int[] array, int origin, int fence, int threshold, |
494 |
< |
int lo, int hi) { |
493 |
> |
int[] array, int origin, int fence, int threshold, |
494 |
> |
int lo, int hi) { |
495 |
|
super(parent); |
496 |
|
this.function = function; this.array = array; |
497 |
|
this.origin = origin; this.fence = fence; |