org.codehaus.gpars

groovyx.gpars.extra166y
[Java] Class PAS.FJScan

java.lang.Object
  jsr166y.ForkJoinTask
      groovyx.gpars.extra166y.PAS.FJScan

static abstract class PAS.FJScan
extends ForkJoinTask

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
static short CUMULATE

static short FINISHED

static short SUMMED

int hi

FJScan left

int lo

FJScanOp op

FJScan parent

int phase

static java.util.concurrent.atomic.AtomicIntegerFieldUpdater phaseUpdater

FJScan right

 
Constructor Summary
PAS.FJScan(FJScan parent, FJScanOp op, int lo, int hi)

 
Method Summary
double dgetIn()

double dgetOut()

void dsetIn(double x)

void dsetOut(double x)

boolean exec()

java.lang.Void getRawResult()

long lgetIn()

long lgetOut()

void lsetIn(long x)

void lsetOut(long x)

java.lang.Object ogetIn()

java.lang.Object ogetOut()

void rsetIn(java.lang.Object x)

void rsetOut(java.lang.Object x)

protected void setRawResult(java.lang.Void mustBeNull)

boolean transitionToCumulate()

 

Field Detail

CUMULATE

static final short CUMULATE


FINISHED

static final short FINISHED


SUMMED

static final short SUMMED


hi

final int hi


left

FJScan left


lo

final int lo


op

final FJScanOp op


parent

final FJScan parent


phase

int phase


phaseUpdater

static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater phaseUpdater


right

FJScan right


 
Constructor Detail

PAS.FJScan

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


 
Method Detail

dgetIn

double dgetIn()


dgetOut

double dgetOut()


dsetIn

void dsetIn(double x)


dsetOut

void dsetOut(double x)


exec

public final boolean exec()


getRawResult

public final java.lang.Void getRawResult()


lgetIn

long lgetIn()


lgetOut

long lgetOut()


lsetIn

void lsetIn(long x)


lsetOut

void lsetOut(long x)


ogetIn

java.lang.Object ogetIn()


ogetOut

java.lang.Object ogetOut()


rsetIn

void rsetIn(java.lang.Object x)


rsetOut

void rsetOut(java.lang.Object x)


setRawResult

protected final void setRawResult(java.lang.Void mustBeNull)


transitionToCumulate

final boolean transitionToCumulate()


 

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