org.amino.alg.parallelprefix
Class ThreadedParallelPrefix.PartialReduction

java.lang.Object
  extended by org.amino.alg.parallelprefix.ThreadedParallelPrefix.PartialReduction
Enclosing class:
ThreadedParallelPrefix<T>

public class ThreadedParallelPrefix.PartialReduction
extends java.lang.Object

Class for performing partial reductions for Parallel-prefix operations across a pool of threads.

Author:
donawa
See Also:
ThreadedParallelPrefix, BinaryOp

Constructor Summary
ThreadedParallelPrefix.PartialReduction(int n)
           
 
Method Summary
 void modify(float[] partialReduction, float[] outputArray, BinaryOp<T> op)
          For every element in parallelReduction except the first one, spawn off a worker thread and with the value of that element, modify each element of outputArray with it using the op method.
 void modify(int[] partialReduction, int[] outputArray, BinaryOp<T> op)
          For every element in parallelReduction except the first one, spawn off a worker thread and with the value of that element, modify each element of outputArray with it using the op method.
 float[] reduce(float[] inputArray, float[] reducedArray, BinaryOp<T> op)
          Reduce across an array of float numbers.
 int[] reduce(int[] inputArray, int[] reducedArray, BinaryOp<T> op)
          Reduce across an array of integers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadedParallelPrefix.PartialReduction

public ThreadedParallelPrefix.PartialReduction(int n)
Parameters:
n - number of worker threads to use in the reduction
Method Detail

reduce

public int[] reduce(int[] inputArray,
                    int[] reducedArray,
                    BinaryOp<T> op)
Reduce across an array of integers.

Parameters:
inputArray - input array
reducedArray - contains intermediate reduction results
op - reduction operator
Returns:
array of partial reduced results

modify

public void modify(int[] partialReduction,
                   int[] outputArray,
                   BinaryOp<T> op)
For every element in parallelReduction except the first one, spawn off a worker thread and with the value of that element, modify each element of outputArray with it using the op method.

Parameters:
partialReduction - partial reductions from a previous scan
outputArray - destination array containing intermediate results
op - modifying function

reduce

public float[] reduce(float[] inputArray,
                      float[] reducedArray,
                      BinaryOp<T> op)
Reduce across an array of float numbers.

Parameters:
inputArray - input array
reducedArray - contains intermediate reduction results
op - reduction operator
Returns:
array of partial reduced results

modify

public void modify(float[] partialReduction,
                   float[] outputArray,
                   BinaryOp<T> op)
For every element in parallelReduction except the first one, spawn off a worker thread and with the value of that element, modify each element of outputArray with it using the op method.

Parameters:
partialReduction - partial reductions from a previous scan
outputArray - destination array containing intermediate results
op - modifying function


Copyright © 2008. All Rights Reserved.