equal
deleted
inserted
replaced
126 this.origin = origin; this.fence = fence; |
126 this.origin = origin; this.fence = fence; |
127 this.threshold = threshold; |
127 this.threshold = threshold; |
128 this.lo = lo; this.hi = hi; |
128 this.lo = lo; this.hi = hi; |
129 } |
129 } |
130 |
130 |
131 @SuppressWarnings("unchecked") |
|
132 public final void compute() { |
131 public final void compute() { |
133 final BinaryOperator<T> fn; |
132 final BinaryOperator<T> fn; |
134 final T[] a; |
133 final T[] a; |
135 if ((fn = this.function) == null || (a = this.array) == null) |
134 if ((fn = this.function) == null || (a = this.array) == null) |
136 throw new NullPointerException(); // hoist checks |
135 throw new NullPointerException(); // hoist checks |
140 if (h - l > th) { |
139 if (h - l > th) { |
141 CumulateTask<T> lt = t.left, rt = t.right, f; |
140 CumulateTask<T> lt = t.left, rt = t.right, f; |
142 if (lt == null) { // first pass |
141 if (lt == null) { // first pass |
143 int mid = (l + h) >>> 1; |
142 int mid = (l + h) >>> 1; |
144 f = rt = t.right = |
143 f = rt = t.right = |
145 new CumulateTask<>(t, fn, a, org, fnc, th, mid, h); |
144 new CumulateTask<T>(t, fn, a, org, fnc, th, mid, h); |
146 t = lt = t.left = |
145 t = lt = t.left = |
147 new CumulateTask<>(t, fn, a, org, fnc, th, l, mid); |
146 new CumulateTask<T>(t, fn, a, org, fnc, th, l, mid); |
148 } |
147 } |
149 else { // possibly refork |
148 else { // possibly refork |
150 T pin = t.in; |
149 T pin = t.in; |
151 lt.in = pin; |
150 lt.in = pin; |
152 f = t = null; |
151 f = t = null; |
211 } |
210 } |
212 else |
211 else |
213 sum = t.in; |
212 sum = t.in; |
214 t.out = sum; |
213 t.out = sum; |
215 for (CumulateTask<T> par;;) { // propagate |
214 for (CumulateTask<T> par;;) { // propagate |
216 if ((par = (CumulateTask<T>)t.getCompleter()) == null) { |
215 @SuppressWarnings("unchecked") CumulateTask<T> partmp |
|
216 = (CumulateTask<T>)t.getCompleter(); |
|
217 if ((par = partmp) == null) { |
217 if ((state & FINISHED) != 0) // enable join |
218 if ((state & FINISHED) != 0) // enable join |
218 t.quietlyComplete(); |
219 t.quietlyComplete(); |
219 break outer; |
220 break outer; |
220 } |
221 } |
221 int b = par.getPendingCount(); |
222 int b = par.getPendingCount(); |
243 break outer; // sib not ready |
244 break outer; // sib not ready |
244 } |
245 } |
245 } |
246 } |
246 } |
247 } |
247 } |
248 } |
|
249 private static final long serialVersionUID = 5293554502939613543L; |
248 } |
250 } |
249 |
251 |
250 static final class LongCumulateTask extends CountedCompleter<Void> { |
252 static final class LongCumulateTask extends CountedCompleter<Void> { |
251 final long[] array; |
253 final long[] array; |
252 final LongBinaryOperator function; |
254 final LongBinaryOperator function; |
392 break outer; // sib not ready |
394 break outer; // sib not ready |
393 } |
395 } |
394 } |
396 } |
395 } |
397 } |
396 } |
398 } |
|
399 private static final long serialVersionUID = -5074099945909284273L; |
397 } |
400 } |
398 |
401 |
399 static final class DoubleCumulateTask extends CountedCompleter<Void> { |
402 static final class DoubleCumulateTask extends CountedCompleter<Void> { |
400 final double[] array; |
403 final double[] array; |
401 final DoubleBinaryOperator function; |
404 final DoubleBinaryOperator function; |
541 break outer; // sib not ready |
544 break outer; // sib not ready |
542 } |
545 } |
543 } |
546 } |
544 } |
547 } |
545 } |
548 } |
|
549 private static final long serialVersionUID = -586947823794232033L; |
546 } |
550 } |
547 |
551 |
548 static final class IntCumulateTask extends CountedCompleter<Void> { |
552 static final class IntCumulateTask extends CountedCompleter<Void> { |
549 final int[] array; |
553 final int[] array; |
550 final IntBinaryOperator function; |
554 final IntBinaryOperator function; |
690 break outer; // sib not ready |
694 break outer; // sib not ready |
691 } |
695 } |
692 } |
696 } |
693 } |
697 } |
694 } |
698 } |
|
699 private static final long serialVersionUID = 3731755594596840961L; |
695 } |
700 } |
696 } |
701 } |