|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.amino.alg.parallelprefix.AbstractParallelPrefix<T> org.amino.alg.parallelprefix.ThreadedParallelPrefix<T>
T
- Element type of array, if array is a non-primitive type.
Irrelevant if array is of a primitive type.public class ThreadedParallelPrefix<T>
Threaded implementation of parallel-prefix operation.
Inspired by Guy E. Blelloch "Prefix Sums and Their Applications". In John H. Reif (Ed.), Synthesis of Parallel Algorithms, Morgan Kaufmann, 1990.
In the first pass, the input array is divided into M/N sequential chunks, where M is the number of elements in the array, and N the number of worker threads. A partial reduction is performed in parallel, the results going into a temporary work array of size M/N, with each element corresponding to a particular worker thread.
A recursive call to scan this work array is then performed.
Finally, each thread then adds the corresponding value to each of it's elements.
ParallelPrefix
Nested Class Summary | |
---|---|
class |
ThreadedParallelPrefix.PartialReduction
Class for performing partial reductions for Parallel-prefix operations across a pool of threads. |
Field Summary | |
---|---|
static int |
DEFAULT_MINIMUM_ARRAY_SIZE
minimum size. |
Constructor Summary | |
---|---|
ThreadedParallelPrefix()
Set number of worker threads to the number of availableProcessors. |
|
ThreadedParallelPrefix(int nthreads)
|
Method Summary | |
---|---|
int |
getMinimumArraySize()
|
void |
scan(byte[] inputArray,
byte[] outputArray,
BinaryOp<T> op)
Perform a parallel-prefix operation on input array 'array'. |
void |
scan(char[] inputArray,
char[] outputArray,
BinaryOp<T> op)
Perform a parallel-prefix operation on input array 'array'. |
void |
scan(double[] inputArray,
double[] outputArray,
BinaryOp<T> op)
Perform a parallel-prefix operation on input array 'array'. |
void |
scan(float[] inputArray,
float[] outputArray,
BinaryOp<T> op)
Perform a parallel-prefix operation on input array 'array'. |
void |
scan(int[] inputArray,
int[] outputArray,
BinaryOp<T> op)
Perform a parallel-prefix operation on input array 'array'. |
void |
scan(long[] inputArray,
long[] outputArray,
BinaryOp<T> op)
Perform a parallel-prefix operation on input array 'array'. |
void |
scan(short[] inputArray,
short[] outputArray,
BinaryOp<T> op)
Perform a parallel-prefix operation on input array 'array'. |
void |
scan(T[] inputArray,
T[] outputArray,
BinaryOp<T> op)
Perform a parallel-prefix operation on input array 'array'. |
void |
setMinimumArraySize(int size)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_MINIMUM_ARRAY_SIZE
Constructor Detail |
---|
public ThreadedParallelPrefix(int nthreads)
nthreads
- Number of threads to use in parallelizing the scan operation.public ThreadedParallelPrefix()
Method Detail |
---|
public void setMinimumArraySize(int size)
size
- minimum size of array for non-serial scan to be used.public int getMinimumArraySize()
public void scan(int[] inputArray, int[] outputArray, BinaryOp<T> op)
scan
in interface ParallelPrefix<T>
scan
in class AbstractParallelPrefix<T>
inputArray
- Single dimension input arrayoutputArray
- Single dimension destination array. Can be the same as
inputArrayop
- binary operatorpublic void scan(float[] inputArray, float[] outputArray, BinaryOp<T> op)
scan
in interface ParallelPrefix<T>
scan
in class AbstractParallelPrefix<T>
inputArray
- Single dimension input arrayoutputArray
- Single dimension destination array. Can be the same as
inputArrayop
- binary operatorpublic void scan(double[] inputArray, double[] outputArray, BinaryOp<T> op)
scan
in interface ParallelPrefix<T>
scan
in class AbstractParallelPrefix<T>
inputArray
- Single dimension input arrayoutputArray
- Single dimension destination array. Can be the same as
inputArrayop
- binary operatorpublic void scan(char[] inputArray, char[] outputArray, BinaryOp<T> op)
scan
in interface ParallelPrefix<T>
scan
in class AbstractParallelPrefix<T>
inputArray
- Single dimension input arrayoutputArray
- Single dimension destination array. Can be the same as
inputArrayop
- binary operatorpublic void scan(byte[] inputArray, byte[] outputArray, BinaryOp<T> op)
scan
in interface ParallelPrefix<T>
scan
in class AbstractParallelPrefix<T>
inputArray
- Single dimension input arrayoutputArray
- Single dimension destination array. Can be the same as
inputArrayop
- binary operatorpublic void scan(short[] inputArray, short[] outputArray, BinaryOp<T> op)
scan
in interface ParallelPrefix<T>
scan
in class AbstractParallelPrefix<T>
inputArray
- Single dimension input arrayoutputArray
- Single dimension destination array. Can be the same as
inputArrayop
- binary operatorpublic void scan(long[] inputArray, long[] outputArray, BinaryOp<T> op)
scan
in interface ParallelPrefix<T>
scan
in class AbstractParallelPrefix<T>
inputArray
- Single dimension input arrayoutputArray
- Single dimension destination array. Can be the same as
inputArrayop
- binary operatorpublic void scan(T[] inputArray, T[] outputArray, BinaryOp<T> op)
scan
in interface ParallelPrefix<T>
scan
in class AbstractParallelPrefix<T>
inputArray
- Single dimension input arrayoutputArray
- Single dimension destination array. Can be the same as
inputArrayop
- binary operator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |