org.apfloat.samples
Class PiParallel.ParallelBinarySplittingPiCalculator

java.lang.Object
  extended by org.apfloat.samples.Pi.BinarySplittingPiCalculator
      extended by org.apfloat.samples.PiParallel.ParallelBinarySplittingPiCalculator
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
PiDistributed.DistributedBinarySplittingPiCalculator
Enclosing class:
PiParallel

protected static class PiParallel.ParallelBinarySplittingPiCalculator
extends Pi.BinarySplittingPiCalculator

Parallel version of the binary splitting algorithm. Uses multiple threads to calculate pi in parallel.

See Also:
Serialized Form

Constructor Summary
PiParallel.ParallelBinarySplittingPiCalculator(Pi.BinarySplittingSeries series)
          Construct a parallel pi calculator with the specified precision and radix.
 
Method Summary
 OperationExecutor[] getNodes()
          Get the available set of operation executor nodes.
 void r(long n1, long n2, ApfloatHolder T, ApfloatHolder Q, ApfloatHolder P, ApfloatHolder F, OperationExecutor[] nodes, Pi.BinarySplittingProgressIndicator progressIndicator)
          Entry point for the parallel binary splitting algorithm.
 OperationExecutor[] recombineNodes(OperationExecutor[] nodes, int numberNeeded)
          Attempt to combine or split nodes to form the needed number of nodes.
 
Methods inherited from class org.apfloat.samples.Pi.BinarySplittingPiCalculator
r
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PiParallel.ParallelBinarySplittingPiCalculator

public PiParallel.ParallelBinarySplittingPiCalculator(Pi.BinarySplittingSeries series)
                                               throws ApfloatRuntimeException
Construct a parallel pi calculator with the specified precision and radix.

Parameters:
series - The binary splitting series to be used.
Throws:
ApfloatRuntimeException
Method Detail

r

public void r(long n1,
              long n2,
              ApfloatHolder T,
              ApfloatHolder Q,
              ApfloatHolder P,
              ApfloatHolder F,
              OperationExecutor[] nodes,
              Pi.BinarySplittingProgressIndicator progressIndicator)
       throws ApfloatRuntimeException
Entry point for the parallel binary splitting algorithm.

Parameters:
n1 - Start term.
n2 - End term.
T - Algorithm parameter.
Q - Algorithm parameter.
P - Algorithm parameter.
F - Pointer to inverse square root parameter.
nodes - The operation executors to be used for the calculation.
progressIndicator - Class to print out the progress of the calculation.
Throws:
ApfloatRuntimeException

getNodes

public OperationExecutor[] getNodes()
Get the available set of operation executor nodes. This implementation returns LocalOperationExecutors but subclasses may return other operation executors.

Returns:
The set of available operation executors.

recombineNodes

public OperationExecutor[] recombineNodes(OperationExecutor[] nodes,
                                          int numberNeeded)
Attempt to combine or split nodes to form the needed number of nodes. The returned number of nodes is something between the number of nodes input and the number of nodes requested. The requested number of nodes can be less than or greater than the number of input nodes.

Parameters:
nodes - The operation executors to recombine.
numberNeeded - The requested number of operation executors.
Returns:
The set of recombined operation executors.