--- jsr166/src/main/java/util/ArrayPrefixHelpers.java 2015/09/19 18:36:55 1.5 +++ jsr166/src/main/java/util/ArrayPrefixHelpers.java 2015/09/21 01:12:41 1.10 @@ -80,6 +80,20 @@ class ArrayPrefixHelpers { T in, out; final int lo, hi, origin, fence, threshold; + /** Root task constructor */ + public CumulateTask(CumulateTask parent, + BinaryOperator function, + T[] array, int lo, int hi) { + super(parent); + this.function = function; this.array = array; + this.lo = this.origin = lo; this.hi = this.fence = hi; + int p; + this.threshold = + (p = (hi - lo) / (ForkJoinPool.getCommonPoolParallelism() << 3)) + <= MIN_PARTITION ? MIN_PARTITION : p; + } + + /** Subtask constructor */ CumulateTask(CumulateTask parent, BinaryOperator function, T[] array, int origin, int fence, int threshold, int lo, int hi) { @@ -104,7 +118,7 @@ class ArrayPrefixHelpers { int mid = (l + h) >>> 1; f = rt = t.right = new CumulateTask(t, fn, a, org, fnc, th, mid, h); - t = lt = t.left = + t = lt = t.left = new CumulateTask(t, fn, a, org, fnc, th, l, mid); } else { // possibly refork @@ -218,6 +232,20 @@ class ArrayPrefixHelpers { long in, out; final int lo, hi, origin, fence, threshold; + /** Root task constructor */ + public LongCumulateTask(LongCumulateTask parent, + LongBinaryOperator function, + long[] array, int lo, int hi) { + super(parent); + this.function = function; this.array = array; + this.lo = this.origin = lo; this.hi = this.fence = hi; + int p; + this.threshold = + (p = (hi - lo) / (ForkJoinPool.getCommonPoolParallelism() << 3)) + <= MIN_PARTITION ? MIN_PARTITION : p; + } + + /** Subtask constructor */ LongCumulateTask(LongCumulateTask parent, LongBinaryOperator function, long[] array, int origin, int fence, int threshold, int lo, int hi) { @@ -242,7 +270,7 @@ class ArrayPrefixHelpers { int mid = (l + h) >>> 1; f = rt = t.right = new LongCumulateTask(t, fn, a, org, fnc, th, mid, h); - t = lt = t.left = + t = lt = t.left = new LongCumulateTask(t, fn, a, org, fnc, th, l, mid); } else { // possibly refork @@ -354,6 +382,20 @@ class ArrayPrefixHelpers { double in, out; final int lo, hi, origin, fence, threshold; + /** Root task constructor */ + public DoubleCumulateTask(DoubleCumulateTask parent, + DoubleBinaryOperator function, + double[] array, int lo, int hi) { + super(parent); + this.function = function; this.array = array; + this.lo = this.origin = lo; this.hi = this.fence = hi; + int p; + this.threshold = + (p = (hi - lo) / (ForkJoinPool.getCommonPoolParallelism() << 3)) + <= MIN_PARTITION ? MIN_PARTITION : p; + } + + /** Subtask constructor */ DoubleCumulateTask(DoubleCumulateTask parent, DoubleBinaryOperator function, double[] array, int origin, int fence, int threshold, int lo, int hi) { @@ -378,7 +420,7 @@ class ArrayPrefixHelpers { int mid = (l + h) >>> 1; f = rt = t.right = new DoubleCumulateTask(t, fn, a, org, fnc, th, mid, h); - t = lt = t.left = + t = lt = t.left = new DoubleCumulateTask(t, fn, a, org, fnc, th, l, mid); } else { // possibly refork @@ -490,6 +532,20 @@ class ArrayPrefixHelpers { int in, out; final int lo, hi, origin, fence, threshold; + /** Root task constructor */ + public IntCumulateTask(IntCumulateTask parent, + IntBinaryOperator function, + int[] array, int lo, int hi) { + super(parent); + this.function = function; this.array = array; + this.lo = this.origin = lo; this.hi = this.fence = hi; + int p; + this.threshold = + (p = (hi - lo) / (ForkJoinPool.getCommonPoolParallelism() << 3)) + <= MIN_PARTITION ? MIN_PARTITION : p; + } + + /** Subtask constructor */ IntCumulateTask(IntCumulateTask parent, IntBinaryOperator function, int[] array, int origin, int fence, int threshold, int lo, int hi) { @@ -514,7 +570,7 @@ class ArrayPrefixHelpers { int mid = (l + h) >>> 1; f = rt = t.right = new IntCumulateTask(t, fn, a, org, fnc, th, mid, h); - t = lt = t.left = + t = lt = t.left = new IntCumulateTask(t, fn, a, org, fnc, th, l, mid); } else { // possibly refork @@ -618,5 +674,4 @@ class ArrayPrefixHelpers { } private static final long serialVersionUID = 3731755594596840961L; } - }