groovyx.gpars.extra166y
Class PAS.FJScan

java.lang.Object
  extended by jsr166y.ForkJoinTask<java.lang.Void>
      extended by groovyx.gpars.extra166y.PAS.FJScan
All Implemented Interfaces:
java.io.Serializable, java.util.concurrent.Future<java.lang.Void>
Direct Known Subclasses:
PAS.FJDScan, PAS.FJLScan, PAS.FJOScan
Enclosing class:
PAS

abstract static class PAS.FJScan
extends jsr166y.ForkJoinTask<java.lang.Void>

Cumulative scan A basic version of scan is straightforward. Keep dividing by two to threshold segment size, and then: Pass 1: Create tree of partial sums for each segment Pass 2: For each segment, cumulate with offset of left sibling See G. Blelloch's http://www.cs.cmu.edu/~scandal/alg/scan.html This version improves performance within FJ framework mainly by allowing second pass of ready left-hand sides to proceed even if some right-hand side first passes are still executing. It also combines first and second pass for leftmost segment, and for cumulate (not precumulate) also skips first pass for rightmost segment (whose result is not needed for second pass). To manage this, it relies on "phase" phase/state control field maintaining bits CUMULATE, SUMMED, and FINISHED. CUMULATE is main phase bit. When false, segments compute only their sum. When true, they cumulate array elements. CUMULATE is set at root at beginning of second pass and then propagated down. But it may also be set earlier for subtrees with lo==origin (the left spine of tree). SUMMED is a one bit join count. For leafs, set when summed. For internal nodes, becomes true when one child is summed. When second child finishes summing, it then moves up tree to trigger cumulate phase. FINISHED is also a one bit join count. For leafs, it is set when cumulated. For internal nodes, it becomes true when one child is cumulated. When second child finishes cumulating, it then moves up tree, executing complete() at the root. This class maintains only the basic control logic. Subclasses maintain the "in" and "out" fields, and *Ops classes perform computations


Field Summary
(package private) static short CUMULATE
           
(package private) static short FINISHED
           
(package private)  int hi
           
(package private)  PAS.FJScan left
           
(package private)  int lo
           
(package private)  PAS.FJScanOp op
           
(package private)  PAS.FJScan parent
           
(package private)  int phase
           
(package private) static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<PAS.FJScan> phaseUpdater
           
(package private)  PAS.FJScan right
           
(package private) static short SUMMED
           
 
Constructor Summary
PAS.FJScan(PAS.FJScan parent, PAS.FJScanOp op, int lo, int hi)
           
 
Method Summary
(package private)  double dgetIn()
           
(package private)  double dgetOut()
           
(package private)  void dsetIn(double x)
           
(package private)  void dsetOut(double x)
           
 boolean exec()
           
 java.lang.Void getRawResult()
           
(package private)  long lgetIn()
           
(package private)  long lgetOut()
           
(package private)  void lsetIn(long x)
           
(package private)  void lsetOut(long x)
           
(package private)  java.lang.Object ogetIn()
           
(package private)  java.lang.Object ogetOut()
           
(package private)  void rsetIn(java.lang.Object x)
           
(package private)  void rsetOut(java.lang.Object x)
           
protected  void setRawResult(java.lang.Void mustBeNull)
           
(package private)  boolean transitionToCumulate()
          Returns true if can CAS CUMULATE bit true
 
Methods inherited from class jsr166y.ForkJoinTask
adapt, adapt, adapt, cancel, complete, completeExceptionally, fork, get, get, getException, getPool, getQueuedTaskCount, getSurplusQueuedTaskCount, helpQuiesce, inForkJoinPool, invoke, invokeAll, invokeAll, invokeAll, isCancelled, isCompletedAbnormally, isCompletedNormally, isDone, join, peekNextLocalTask, pollNextLocalTask, pollTask, quietlyInvoke, quietlyJoin, reinitialize, tryUnfork
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CUMULATE

static final short CUMULATE
See Also:
Constant Field Values

SUMMED

static final short SUMMED
See Also:
Constant Field Values

FINISHED

static final short FINISHED
See Also:
Constant Field Values

parent

final PAS.FJScan parent

op

final PAS.FJScanOp op

left

PAS.FJScan left

right

PAS.FJScan right

phase

volatile int phase

lo

final int lo

hi

final int hi

phaseUpdater

static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<PAS.FJScan> phaseUpdater
Constructor Detail

PAS.FJScan

PAS.FJScan(PAS.FJScan parent,
           PAS.FJScanOp op,
           int lo,
           int hi)
Method Detail

getRawResult

public final java.lang.Void getRawResult()
Specified by:
getRawResult in class jsr166y.ForkJoinTask<java.lang.Void>

setRawResult

protected final void setRawResult(java.lang.Void mustBeNull)
Specified by:
setRawResult in class jsr166y.ForkJoinTask<java.lang.Void>

transitionToCumulate

final boolean transitionToCumulate()
Returns true if can CAS CUMULATE bit true


exec

public final boolean exec()
Specified by:
exec in class jsr166y.ForkJoinTask<java.lang.Void>

ogetIn

java.lang.Object ogetIn()

ogetOut

java.lang.Object ogetOut()

rsetIn

void rsetIn(java.lang.Object x)

rsetOut

void rsetOut(java.lang.Object x)

dgetIn

double dgetIn()

dgetOut

double dgetOut()

dsetIn

void dsetIn(double x)

dsetOut

void dsetOut(double x)

lgetIn

long lgetIn()

lgetOut

long lgetOut()

lsetIn

void lsetIn(long x)

lsetOut

void lsetOut(long x)

Copyright © 2008–2012 Václav Pech. All Rights Reserved.