org.javaseis.parallel
Class UniprocessorContext

java.lang.Object
  extended by org.javaseis.parallel.UniprocessorContext
All Implemented Interfaces:
IParallelContext

public class UniprocessorContext
extends java.lang.Object
implements IParallelContext


Constructor Summary
UniprocessorContext()
           
 
Method Summary
 void barrier()
          Parallel barrier that requires all tasks to particpate.
<T> void
bcast(int tag, T a, int offset, int count, int sender)
          Broadcast a message to all tasks in this parallel context
 void bcastByte(int tag, byte[] a, int offset, int count, int sender)
           
 void bcastDouble(int tag, double[] a, int offset, int count, int sender)
           
 void bcastFloat(int tag, float[] a, int offset, int count, int sender)
           
 void bcastInt(int tag, int[] a, int offset, int count, int sender)
           
 void bcastLong(int tag, long[] a, int offset, int count, int sender)
           
 void bcastShort(int tag, short[] a, int offset, int count, int sender)
           
<T> void
collect(T a, int aoffset, T b, int boffset, int count)
          Collect an array from all tasks and concatenate on the master task
 byte[] collectByte(byte a)
          Collect a scalar from all tasks into an array and return to all
 void collectByte(byte[] a, int aoffset, byte[] b, int boffset, int count)
           
 double[] collectDouble(double a)
           
 void collectDouble(double[] a, int aoffset, double[] b, int boffset, int count)
           
 float[] collectFloat(float a)
           
 void collectFloat(float[] a, int aoffset, float[] b, int boffset, int count)
           
 int[] collectInt(int a)
           
 void collectInt(int[] a, int aoffset, int[] b, int boffset, int count)
           
 long[] collectLong(long a)
           
 void collectLong(long[] a, int aoffset, long[] b, int boffset, int count)
           
 short[] collectShort(short a)
           
 void collectShort(short[] a, int aoffset, short[] b, int boffset, int count)
           
 void finish()
          Complete participation in the parallel context
<T> void
globalMax(T a, int aoffset, T b, int boffset, int count)
           
 void globalMaxByte(byte[] a, int aoffset, byte[] b, int boffset, int count)
           
 void globalMaxDouble(double[] a, int aoffset, double[] b, int boffset, int count)
           
 void globalMaxFloat(float[] a, int aoffset, float[] b, int boffset, int count)
           
 void globalMaxInt(int[] a, int aoffset, int[] b, int boffset, int count)
           
 void globalMaxLong(long[] a, int aoffset, long[] b, int boffset, int count)
           
 void globalMaxShort(short[] a, int aoffset, short[] b, int boffset, int count)
           
<T> void
globalMin(T a, int aoffset, T b, int boffset, int count)
           
 void globalMinByte(byte[] a, int aoffset, byte[] b, int boffset, int count)
           
 void globalMinDouble(double[] a, int aoffset, double[] b, int boffset, int count)
           
 void globalMinFloat(float[] a, int aoffset, float[] b, int boffset, int count)
           
 void globalMinInt(int[] a, int aoffset, int[] b, int boffset, int count)
           
 void globalMinLong(long[] a, int aoffset, long[] b, int boffset, int count)
           
 void globalMinShort(short[] a, int aoffset, short[] b, int boffset, int count)
           
<T> void
globalSum(T a, int aoffset, T b, int boffset, int count)
          Global operations across tasks in a ParallelContext Operations are provided for Sum, Min, and Max.
 void globalSumByte(byte[] a, int aoffset, byte[] b, int boffset, int count)
           
 void globalSumDouble(double[] a, int aoffset, double[] b, int boffset, int count)
           
 void globalSumFloat(float[] a, int aoffset, float[] b, int boffset, int count)
           
 void globalSumInt(int[] a, int aoffset, int[] b, int boffset, int count)
           
 void globalSumLong(long[] a, int aoffset, long[] b, int boffset, int count)
           
 void globalSumShort(short[] a, int aoffset, short[] b, int boffset, int count)
           
 boolean init(java.lang.String[] args)
          Return true if this is the "master" task for master/slave style algorithms
 boolean isMaster()
          Initialize the parallel context using mpiJava
static void main(java.lang.String[] args)
           
 void masterPrint(java.lang.String s)
          Print a string from the rank 0 task only A barrier is invoked, so all tasks must participate in the call to this method.
 int rank()
          Return the rank (task index) of this task in the parallel context
<T> void
recv(int tag, T a, int offset, int count)
          Receive a message from another task in this parallel context
 void recvByte(int tag, byte[] a, int offset, int count)
           
 void recvDouble(int tag, double[] a, int offset, int count)
           
 void recvFloat(int tag, float[] a, int offset, int count)
           
 void recvInt(int tag, int[] a, int offset, int count)
           
 void recvLong(int tag, long[] a, int offset, int count)
           
 void recvShort(int tag, short[] a, int offset, int count)
           
<T> void
send(int tag, T a, int offset, int count, int dest)
          Send a message to another task in this parallel context
 void sendByte(int tag, byte[] a, int offset, int count, int dest)
           
 void sendDouble(int tag, double[] a, int offset, int count, int dest)
           
 void sendFloat(int tag, float[] a, int offset, int count, int dest)
           
 void sendInt(int tag, int[] a, int offset, int count, int dest)
           
 void sendLong(int tag, long[] a, int offset, int count, int dest)
           
 void sendShort(int tag, short[] a, int offset, int count, int dest)
           
 void serialPrint(java.lang.String s)
          Serialize printing a string from all tasks, so that one line at a time is printed A barrier is invoked, so all tasks must participate in the call to this method.
<T> void
shift(int nshift, T a, int offset, int count, T buf)
          Shift an array of primitive or objects types across tasks in a parallel context
 void shiftByte(int nshift, byte[] a, int offset, int count, byte[] buf)
           
 void shiftDouble(int nshift, double[] a, int offset, int count, double[] buf)
           
 void shiftFloat(int nshift, float[] a, int offset, int count, float[] buf)
           
 void shiftInt(int nshift, int[] a, int offset, int count, int[] buf)
           
 void shiftLong(int nshift, long[] a, int offset, int count, long[] buf)
           
 void shiftShort(int nshift, short[] a, int offset, int count, short[] buf)
           
 int size()
          Return the size (total number of tasks) in the parallel context
<T> void
ttran(int tileSize, T a, int offset, T buf)
          Transpose a "tiled" array across tasks in this parallel context.
 void ttranByte(int tileSize, byte[] a, int offset, byte[] buf)
           
 void ttranDouble(int tileSize, double[] a, int offset, double[] buf)
           
 void ttranFloat(int tileSize, float[] a, int offset, float[] buf)
           
 void ttranInt(int tileSize, int[] a, int offset, int[] buf)
           
 void ttranLong(int tileSize, long[] a, int offset, long[] buf)
           
 void ttranShort(int tileSize, short[] a, int offset, short[] buf)
           
<T> void
ttranv(int[] lena, int[] aoffset, T[] a, int[] lenb, int[] boffset, T[] b)
           
 void ttranvInit(int[] lena, int[] aoffset, int[] lenb, int[] boffset)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UniprocessorContext

public UniprocessorContext()
Method Detail

barrier

public void barrier()
Description copied from interface: IParallelContext
Parallel barrier that requires all tasks to particpate. Serves as a synchronization point for parallel codes.

Specified by:
barrier in interface IParallelContext
See Also:
IParallelContext.barrier()

bcast

public <T> void bcast(int tag,
                      T a,
                      int offset,
                      int count,
                      int sender)
Description copied from interface: IParallelContext
Broadcast a message to all tasks in this parallel context

Specified by:
bcast in interface IParallelContext
a - array containing data to be sent
offset - offset into array where broadcast will start
count - count of elements to be sent
sender - rank of the source for this broadcast
See Also:
org.javaseis.parallel.IParallelContext#bcast(int, T, int, int, int)

bcastByte

public void bcastByte(int tag,
                      byte[] a,
                      int offset,
                      int count,
                      int sender)
Specified by:
bcastByte in interface IParallelContext

bcastDouble

public void bcastDouble(int tag,
                        double[] a,
                        int offset,
                        int count,
                        int sender)
Specified by:
bcastDouble in interface IParallelContext

bcastFloat

public void bcastFloat(int tag,
                       float[] a,
                       int offset,
                       int count,
                       int sender)
Specified by:
bcastFloat in interface IParallelContext

bcastInt

public void bcastInt(int tag,
                     int[] a,
                     int offset,
                     int count,
                     int sender)
Specified by:
bcastInt in interface IParallelContext

bcastLong

public void bcastLong(int tag,
                      long[] a,
                      int offset,
                      int count,
                      int sender)
Specified by:
bcastLong in interface IParallelContext

bcastShort

public void bcastShort(int tag,
                       short[] a,
                       int offset,
                       int count,
                       int sender)
Specified by:
bcastShort in interface IParallelContext

collect

public <T> void collect(T a,
                        int aoffset,
                        T b,
                        int boffset,
                        int count)
Description copied from interface: IParallelContext
Collect an array from all tasks and concatenate on the master task

Specified by:
collect in interface IParallelContext
Parameters:
a - source array
aoffset - offset within source array for the operation
b - result array, length size*count, where size is the context size
boffset - offset in the result array where results are placed
count - number of elements to collect from each task. Output array b will have count*ParallelContext.size() elements on output. Methods support object and primitive types.

collectByte

public byte[] collectByte(byte a)
Description copied from interface: IParallelContext
Collect a scalar from all tasks into an array and return to all

Specified by:
collectByte in interface IParallelContext
Parameters:
a - input scalar
Returns:
array length ParallelContext.size() containing collected scalars

collectByte

public void collectByte(byte[] a,
                        int aoffset,
                        byte[] b,
                        int boffset,
                        int count)
Specified by:
collectByte in interface IParallelContext

collectDouble

public double[] collectDouble(double a)
Specified by:
collectDouble in interface IParallelContext

collectDouble

public void collectDouble(double[] a,
                          int aoffset,
                          double[] b,
                          int boffset,
                          int count)
Specified by:
collectDouble in interface IParallelContext

collectFloat

public float[] collectFloat(float a)
Specified by:
collectFloat in interface IParallelContext

collectFloat

public void collectFloat(float[] a,
                         int aoffset,
                         float[] b,
                         int boffset,
                         int count)
Specified by:
collectFloat in interface IParallelContext

collectInt

public int[] collectInt(int a)
Specified by:
collectInt in interface IParallelContext

collectInt

public void collectInt(int[] a,
                       int aoffset,
                       int[] b,
                       int boffset,
                       int count)
Specified by:
collectInt in interface IParallelContext

collectLong

public long[] collectLong(long a)
Specified by:
collectLong in interface IParallelContext

collectLong

public void collectLong(long[] a,
                        int aoffset,
                        long[] b,
                        int boffset,
                        int count)
Specified by:
collectLong in interface IParallelContext

collectShort

public short[] collectShort(short a)
Specified by:
collectShort in interface IParallelContext

collectShort

public void collectShort(short[] a,
                         int aoffset,
                         short[] b,
                         int boffset,
                         int count)
Specified by:
collectShort in interface IParallelContext

finish

public void finish()
Description copied from interface: IParallelContext
Complete participation in the parallel context

Specified by:
finish in interface IParallelContext
See Also:
IParallelContext.finish()

globalMax

public <T> void globalMax(T a,
                          int aoffset,
                          T b,
                          int boffset,
                          int count)
Specified by:
globalMax in interface IParallelContext

globalMaxByte

public void globalMaxByte(byte[] a,
                          int aoffset,
                          byte[] b,
                          int boffset,
                          int count)
Specified by:
globalMaxByte in interface IParallelContext

globalMaxDouble

public void globalMaxDouble(double[] a,
                            int aoffset,
                            double[] b,
                            int boffset,
                            int count)
Specified by:
globalMaxDouble in interface IParallelContext

globalMaxFloat

public void globalMaxFloat(float[] a,
                           int aoffset,
                           float[] b,
                           int boffset,
                           int count)
Specified by:
globalMaxFloat in interface IParallelContext

globalMaxInt

public void globalMaxInt(int[] a,
                         int aoffset,
                         int[] b,
                         int boffset,
                         int count)
Specified by:
globalMaxInt in interface IParallelContext

globalMaxLong

public void globalMaxLong(long[] a,
                          int aoffset,
                          long[] b,
                          int boffset,
                          int count)
Specified by:
globalMaxLong in interface IParallelContext

globalMaxShort

public void globalMaxShort(short[] a,
                           int aoffset,
                           short[] b,
                           int boffset,
                           int count)
Specified by:
globalMaxShort in interface IParallelContext

globalMin

public <T> void globalMin(T a,
                          int aoffset,
                          T b,
                          int boffset,
                          int count)
Specified by:
globalMin in interface IParallelContext

globalMinByte

public void globalMinByte(byte[] a,
                          int aoffset,
                          byte[] b,
                          int boffset,
                          int count)
Specified by:
globalMinByte in interface IParallelContext

globalMinDouble

public void globalMinDouble(double[] a,
                            int aoffset,
                            double[] b,
                            int boffset,
                            int count)
Specified by:
globalMinDouble in interface IParallelContext

globalMinFloat

public void globalMinFloat(float[] a,
                           int aoffset,
                           float[] b,
                           int boffset,
                           int count)
Specified by:
globalMinFloat in interface IParallelContext

globalMinInt

public void globalMinInt(int[] a,
                         int aoffset,
                         int[] b,
                         int boffset,
                         int count)
Specified by:
globalMinInt in interface IParallelContext

globalMinLong

public void globalMinLong(long[] a,
                          int aoffset,
                          long[] b,
                          int boffset,
                          int count)
Specified by:
globalMinLong in interface IParallelContext

globalMinShort

public void globalMinShort(short[] a,
                           int aoffset,
                           short[] b,
                           int boffset,
                           int count)
Specified by:
globalMinShort in interface IParallelContext

globalSum

public <T> void globalSum(T a,
                          int aoffset,
                          T b,
                          int boffset,
                          int count)
Description copied from interface: IParallelContext
Global operations across tasks in a ParallelContext Operations are provided for Sum, Min, and Max. The input array contains data for the global operation. The output array contains the sum/min/max of the individual elements from all tasks.

Specified by:
globalSum in interface IParallelContext
aoffset - offset in input array at which to begin the operation
b - output array containing result across tasks
boffset - offset in output array where results will be placed
count - number of elements to operate on

globalSumByte

public void globalSumByte(byte[] a,
                          int aoffset,
                          byte[] b,
                          int boffset,
                          int count)
Specified by:
globalSumByte in interface IParallelContext

globalSumDouble

public void globalSumDouble(double[] a,
                            int aoffset,
                            double[] b,
                            int boffset,
                            int count)
Specified by:
globalSumDouble in interface IParallelContext

globalSumFloat

public void globalSumFloat(float[] a,
                           int aoffset,
                           float[] b,
                           int boffset,
                           int count)
Specified by:
globalSumFloat in interface IParallelContext

globalSumInt

public void globalSumInt(int[] a,
                         int aoffset,
                         int[] b,
                         int boffset,
                         int count)
Specified by:
globalSumInt in interface IParallelContext

globalSumLong

public void globalSumLong(long[] a,
                          int aoffset,
                          long[] b,
                          int boffset,
                          int count)
Specified by:
globalSumLong in interface IParallelContext

globalSumShort

public void globalSumShort(short[] a,
                           int aoffset,
                           short[] b,
                           int boffset,
                           int count)
Specified by:
globalSumShort in interface IParallelContext

init

public boolean init(java.lang.String[] args)
Description copied from interface: IParallelContext
Return true if this is the "master" task for master/slave style algorithms

Specified by:
init in interface IParallelContext
Returns:
true if this is the "master" task
See Also:
org.javaseis.parallel.IParallelContext#init()

isMaster

public boolean isMaster()
Description copied from interface: IParallelContext
Initialize the parallel context using mpiJava

Specified by:
isMaster in interface IParallelContext
See Also:
org.javaseis.parallel.IParallelContext#init()

main

public static void main(java.lang.String[] args)
Parameters:
args -

masterPrint

public void masterPrint(java.lang.String s)
Description copied from interface: IParallelContext
Print a string from the rank 0 task only A barrier is invoked, so all tasks must participate in the call to this method.

Specified by:
masterPrint in interface IParallelContext
Parameters:
s - string to be printed

rank

public int rank()
Description copied from interface: IParallelContext
Return the rank (task index) of this task in the parallel context

Specified by:
rank in interface IParallelContext
Returns:
the rank of this task
See Also:
IParallelContext.rank()

recv

public <T> void recv(int tag,
                     T a,
                     int offset,
                     int count)
Description copied from interface: IParallelContext
Receive a message from another task in this parallel context

Specified by:
recv in interface IParallelContext
Parameters:
tag - unique integer tag for this message
a - array to receive data
offset - offset into array where receive will start
count - maximum count of elements to be received
See Also:
org.javaseis.parallel.IParallelContext#recv(int, T, int, int)

recvByte

public void recvByte(int tag,
                     byte[] a,
                     int offset,
                     int count)
Specified by:
recvByte in interface IParallelContext

recvDouble

public void recvDouble(int tag,
                       double[] a,
                       int offset,
                       int count)
Specified by:
recvDouble in interface IParallelContext

recvFloat

public void recvFloat(int tag,
                      float[] a,
                      int offset,
                      int count)
Specified by:
recvFloat in interface IParallelContext

recvInt

public void recvInt(int tag,
                    int[] a,
                    int offset,
                    int count)
Specified by:
recvInt in interface IParallelContext

recvLong

public void recvLong(int tag,
                     long[] a,
                     int offset,
                     int count)
Specified by:
recvLong in interface IParallelContext

recvShort

public void recvShort(int tag,
                      short[] a,
                      int offset,
                      int count)
Specified by:
recvShort in interface IParallelContext

send

public <T> void send(int tag,
                     T a,
                     int offset,
                     int count,
                     int dest)
Description copied from interface: IParallelContext
Send a message to another task in this parallel context

Specified by:
send in interface IParallelContext
Parameters:
tag - unique integer tag for this message
a - array containing data to be sent
offset - offset into array where send will start
count - count of elements to be sent
dest - rank of the destination for this message
See Also:
org.javaseis.parallel.IParallelContext#send(int, T, int, int, int)

sendByte

public void sendByte(int tag,
                     byte[] a,
                     int offset,
                     int count,
                     int dest)
Specified by:
sendByte in interface IParallelContext

sendDouble

public void sendDouble(int tag,
                       double[] a,
                       int offset,
                       int count,
                       int dest)
Specified by:
sendDouble in interface IParallelContext

sendFloat

public void sendFloat(int tag,
                      float[] a,
                      int offset,
                      int count,
                      int dest)
Specified by:
sendFloat in interface IParallelContext

sendInt

public void sendInt(int tag,
                    int[] a,
                    int offset,
                    int count,
                    int dest)
Specified by:
sendInt in interface IParallelContext

sendLong

public void sendLong(int tag,
                     long[] a,
                     int offset,
                     int count,
                     int dest)
Specified by:
sendLong in interface IParallelContext

sendShort

public void sendShort(int tag,
                      short[] a,
                      int offset,
                      int count,
                      int dest)
Specified by:
sendShort in interface IParallelContext

serialPrint

public void serialPrint(java.lang.String s)
Description copied from interface: IParallelContext
Serialize printing a string from all tasks, so that one line at a time is printed A barrier is invoked, so all tasks must participate in the call to this method.

Specified by:
serialPrint in interface IParallelContext
Parameters:
s - string to be printed

shift

public <T> void shift(int nshift,
                      T a,
                      int offset,
                      int count,
                      T buf)
Description copied from interface: IParallelContext
Shift an array of primitive or objects types across tasks in a parallel context

Specified by:
shift in interface IParallelContext
a - input array of objects or primitive types to be shifted
offset - offset into array a that the shift will be performed upon
count - number of array elements to shift
buf - a matching array to input array a, at least count elements in length
See Also:
org.javaseis.parallel.IParallelContext#shift(int, T, int, int)

shiftByte

public void shiftByte(int nshift,
                      byte[] a,
                      int offset,
                      int count,
                      byte[] buf)
Specified by:
shiftByte in interface IParallelContext

shiftDouble

public void shiftDouble(int nshift,
                        double[] a,
                        int offset,
                        int count,
                        double[] buf)
Specified by:
shiftDouble in interface IParallelContext

shiftFloat

public void shiftFloat(int nshift,
                       float[] a,
                       int offset,
                       int count,
                       float[] buf)
Specified by:
shiftFloat in interface IParallelContext

shiftInt

public void shiftInt(int nshift,
                     int[] a,
                     int offset,
                     int count,
                     int[] buf)
Specified by:
shiftInt in interface IParallelContext

shiftLong

public void shiftLong(int nshift,
                      long[] a,
                      int offset,
                      int count,
                      long[] buf)
Specified by:
shiftLong in interface IParallelContext

shiftShort

public void shiftShort(int nshift,
                       short[] a,
                       int offset,
                       int count,
                       short[] buf)
Specified by:
shiftShort in interface IParallelContext

size

public int size()
Description copied from interface: IParallelContext
Return the size (total number of tasks) in the parallel context

Specified by:
size in interface IParallelContext
Returns:
number of tasks in this parallel context
See Also:
IParallelContext.size()

ttran

public <T> void ttran(int tileSize,
                      T a,
                      int offset,
                      T buf)
Description copied from interface: IParallelContext
Transpose a "tiled" array across tasks in this parallel context. The tiled array is of size "tileSize x size", where "size" is the number of tasks in this parallel context. All tasks have an array of this size, so the full array is "tileSize x size | size". This primitive can be used to construct transposes for multidimensional rectangular arrays. "ttran" operates on objects, ttranPrimitive operates on primitive types. "ttranv" allows for variable length tiles, were tileSize[i] and offset[i] are the length and offset of each tile in the source array

Specified by:
ttran in interface IParallelContext
Parameters:
tileSize - size of the tile for the transpose
a - array containing data to be transposed
offset - index of start position in array a for transpose
buf - array of matching type of length "tileSize" used as work space

ttranByte

public void ttranByte(int tileSize,
                      byte[] a,
                      int offset,
                      byte[] buf)
Specified by:
ttranByte in interface IParallelContext

ttranDouble

public void ttranDouble(int tileSize,
                        double[] a,
                        int offset,
                        double[] buf)
Specified by:
ttranDouble in interface IParallelContext

ttranFloat

public void ttranFloat(int tileSize,
                       float[] a,
                       int offset,
                       float[] buf)
Specified by:
ttranFloat in interface IParallelContext

ttranInt

public void ttranInt(int tileSize,
                     int[] a,
                     int offset,
                     int[] buf)
Specified by:
ttranInt in interface IParallelContext

ttranLong

public void ttranLong(int tileSize,
                      long[] a,
                      int offset,
                      long[] buf)
Specified by:
ttranLong in interface IParallelContext

ttranShort

public void ttranShort(int tileSize,
                       short[] a,
                       int offset,
                       short[] buf)
Specified by:
ttranShort in interface IParallelContext

ttranv

public <T> void ttranv(int[] lena,
                       int[] aoffset,
                       T[] a,
                       int[] lenb,
                       int[] boffset,
                       T[] b)
Specified by:
ttranv in interface IParallelContext

ttranvInit

public void ttranvInit(int[] lena,
                       int[] aoffset,
                       int[] lenb,
                       int[] boffset)
Specified by:
ttranvInit in interface IParallelContext