< prev index next >

src/java.base/share/classes/java/util/ArrayPrefixHelpers.java

Print this page




  68      * phases/states: CUMULATE, SUMMED, and FINISHED. CUMULATE is the
  69      * main phase bit. When false, segments compute only their sum.
  70      * When true, they cumulate array elements. CUMULATE is set at
  71      * root at beginning of second pass and then propagated down. But
  72      * it may also be set earlier for subtrees with lo==0 (the left
  73      * spine of tree). SUMMED is a one bit join count. For leafs, it
  74      * is set when summed. For internal nodes, it becomes true when
  75      * one child is summed.  When the second child finishes summing,
  76      * we then moves up tree to trigger the cumulate phase. FINISHED
  77      * is also a one bit join count. For leafs, it is set when
  78      * cumulated. For internal nodes, it becomes true when one child
  79      * is cumulated.  When the second child finishes cumulating, it
  80      * then moves up tree, completing at the root.
  81      *
  82      * To better exploit locality and reduce overhead, the compute
  83      * method loops starting with the current task, moving if possible
  84      * to one of its subtasks rather than forking.
  85      *
  86      * As usual for this sort of utility, there are 4 versions, that
  87      * are simple copy/paste/adapt variants of each other.  (The
  88      * double and int versions differ from long version soley by
  89      * replacing "long" (with case-matching)).
  90      */
  91 
  92     // see above
  93     static final int CUMULATE = 1;
  94     static final int SUMMED   = 2;
  95     static final int FINISHED = 4;
  96 
  97     /** The smallest subtask array partition size to use as threshold */
  98     static final int MIN_PARTITION = 16;
  99 
 100     static final class CumulateTask<T> extends CountedCompleter<Void> {
 101         final T[] array;
 102         final BinaryOperator<T> function;
 103         CumulateTask<T> left, right;
 104         T in, out;
 105         final int lo, hi, origin, fence, threshold;
 106 
 107         /** Root task constructor */
 108         public CumulateTask(CumulateTask<T> parent,




  68      * phases/states: CUMULATE, SUMMED, and FINISHED. CUMULATE is the
  69      * main phase bit. When false, segments compute only their sum.
  70      * When true, they cumulate array elements. CUMULATE is set at
  71      * root at beginning of second pass and then propagated down. But
  72      * it may also be set earlier for subtrees with lo==0 (the left
  73      * spine of tree). SUMMED is a one bit join count. For leafs, it
  74      * is set when summed. For internal nodes, it becomes true when
  75      * one child is summed.  When the second child finishes summing,
  76      * we then moves up tree to trigger the cumulate phase. FINISHED
  77      * is also a one bit join count. For leafs, it is set when
  78      * cumulated. For internal nodes, it becomes true when one child
  79      * is cumulated.  When the second child finishes cumulating, it
  80      * then moves up tree, completing at the root.
  81      *
  82      * To better exploit locality and reduce overhead, the compute
  83      * method loops starting with the current task, moving if possible
  84      * to one of its subtasks rather than forking.
  85      *
  86      * As usual for this sort of utility, there are 4 versions, that
  87      * are simple copy/paste/adapt variants of each other.  (The
  88      * double and int versions differ from long version solely by
  89      * replacing "long" (with case-matching)).
  90      */
  91 
  92     // see above
  93     static final int CUMULATE = 1;
  94     static final int SUMMED   = 2;
  95     static final int FINISHED = 4;
  96 
  97     /** The smallest subtask array partition size to use as threshold */
  98     static final int MIN_PARTITION = 16;
  99 
 100     static final class CumulateTask<T> extends CountedCompleter<Void> {
 101         final T[] array;
 102         final BinaryOperator<T> function;
 103         CumulateTask<T> left, right;
 104         T in, out;
 105         final int lo, hi, origin, fence, threshold;
 106 
 107         /** Root task constructor */
 108         public CumulateTask(CumulateTask<T> parent,


< prev index next >