ibis.mpj
Class Comm

java.lang.Object
  extended by ibis.mpj.Comm
Direct Known Subclasses:
Intercomm, Intracomm

public class Comm
extends Object

Communicator for point-to-point messages.


Constructor Summary
Comm()
           
 
Method Summary
 void abort(int errorcode)
           
 Object attrGet(int keyval)
          Retrieves attribute value by key.
 void bsend(Object buf, int offset, int count, Datatype datatype, int dest, int tag)
          Send in buffered mode.
 Prequest bsendInit(Object buf, int offset, int count, Datatype datatype, int dest, int tag)
          Creates a persistent communication request for a buffered mode send.
 Object clone()
          Duplicate this communicator.
static int compare(Comm comm1, Comm comm2)
          Compare two communicators.
 Intercomm createIntercomm(Comm localComm, int localLeader, int remoteLeader, int tag)
           NOT IMPLEMENTED YET.
 void free()
           
 Group group()
          Return group associated with this communicator.
 Request ibsend(Object buf, int offset, int count, Datatype datatype, int dest, int tag)
          Start a buffered mode, nonblocking send.
 Status iprobe(int source, int tag)
          Check if there is an incoming message matching the pattern specified.
 Request irecv(Object buf, int offset, int count, Datatype datatype, int source, int tag)
          Start a nonblocking receive.
 Request irsend(Object buf, int offset, int count, Datatype datatype, int dest, int tag)
          Start a ready mode, nonblocking send.
 Request isend(Object buf, int offset, int count, Datatype datatype, int dest, int tag)
          Start a standard mode, nonblocking send.
 Request issend(Object buf, int offset, int count, Datatype datatype, int dest, int tag)
          Start a synchronous mode, nonblocking send.
 byte[] pack(Object inbuf, int offset, int incount, Datatype datatype)
          Packs message in send buffer inbuf into buffer space allocated internally
 int pack(Object inbuf, int offset, int incount, Datatype datatype, byte[] outbuf, int position)
          Packs message in send buffer inbuf into space specified in outbuf.
 int packSize(int incount, Datatype datatype)
          Returns an upper bound on the increment of position effected by pack.
 Status probe(int source, int tag)
          Wait until there is an incoming message matching the pattern specified.
 int rank()
          Return the rank inside the group of this communicator
 Status recv(Object buf, int offset, int count, Datatype datatype, int source, int tag)
          Blocking receive operation.
 Prequest recvInit(Object buf, int offset, int count, Datatype datatype, int source, int tag)
          Creates a persistent communication request for a receive operation.
 void rsend(Object buf, int offset, int count, Datatype datatype, int dest, int tag)
          Send in ready mode.
 Prequest rsendInit(Object buf, int offset, int count, Datatype datatype, int dest, int tag)
          Creates a persistent communication request for a ready mode send.
 void send(Object buf, int offset, int count, Datatype datatype, int dest, int tag)
          Blocking send operation.
 Prequest sendInit(Object buf, int offset, int count, Datatype datatype, int dest, int tag)
          Creates a persistent communication request for a standard mode send.
 Status sendrecv(Object sendbuf, int sendoffset, int sendcount, Datatype sendtype, int dest, int sendtag, Object recvbuf, int recvoffset, int recvcount, Datatype recvtype, int source, int recvtag)
          Execute a blocking send and receive operation.
 Status sendrecvReplace(Object buf, int offset, int count, Datatype datatype, int dest, int sendtag, int source, int recvtag)
          Execute a blocking send and receive operation, receiving message into send buffer.
 int size()
          Size of the group of this communicator.
 void ssend(Object buf, int offset, int count, Datatype datatype, int dest, int tag)
          Send in synchronous mode.
 Prequest ssendInit(Object buf, int offset, int count, Datatype datatype, int dest, int tag)
          Creates a persitent communication request for a synchronous mode send.
 boolean testInter()
           NOT IMPLEMENTED YET.
 int topoTest()
           NOT IMPLEMENTED YET.
 int unpack(byte[] inbuf, int position, Object outbuf, int offset, int outcount, Datatype datatype)
          Unpacks message in receive buffer outbuf into space specified in inbuf.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Comm

public Comm()
     throws MPJException
Throws:
MPJException
Method Detail

rank

public int rank()
         throws MPJException
Return the rank inside the group of this communicator

Returns:
the rank inside the group of this communicator
Throws:
MPJException

size

public int size()
         throws MPJException
Size of the group of this communicator.

Returns:
number of processes in the group of this communicator
Throws:
MPJException

group

public Group group()
            throws MPJException
Return group associated with this communicator.

Returns:
group corresponding to this communicator
Throws:
MPJException

compare

public static int compare(Comm comm1,
                          Comm comm2)
                   throws MPJException
Compare two communicators. MPJ.IDENT results if this communicator and comm1 are references to the same object. MPJ.CONGRUENT results if the underlying groups are identical but the communicators differ by context. MPJ.SIMILAR results if the group members of both communicators are the same but the rank order differs. MPJ.UNEQUAL results otherwise

Parameters:
comm1 - communicator to compare with
Returns:
MPJ.IDENT, MPJ.CONGRUENT of MPJ.UNEQUAL
Throws:
MPJException

clone

public Object clone()
Duplicate this communicator. The new communicator is "congruent" to the old one, but has a differnt context.

Overrides:
clone in class Object
Returns:
copy of this communicator

free

public void free()
          throws MPJException
Throws:
MPJException

testInter

public boolean testInter()
                  throws MPJException
NOT IMPLEMENTED YET. Test if this is an inter-communicator, false otherwise.

Returns:
true if this is an inter-communicator
Throws:
MPJException

createIntercomm

public Intercomm createIntercomm(Comm localComm,
                                 int localLeader,
                                 int remoteLeader,
                                 int tag)
                          throws MPJException
NOT IMPLEMENTED YET. Create an inter communicator.

Parameters:
localComm - local intra communicator
localLeader - rank of local leader in localComm
remoteLeader - rank of remote leader in this communicator
tag - "safe tag"
Returns:
new inter communicator
Throws:
MPJException

attrGet

public Object attrGet(int keyval)
               throws MPJException
Retrieves attribute value by key. Valid key values are MPJ.TAG_UB, MPJ.HOST, MPJ.IO and MPJ.WTIME_IS_GLOBAL

Parameters:
keyval - one of the key values predefined by MPJ
Returns:
attribute value
Throws:
MPJException

send

public void send(Object buf,
                 int offset,
                 int count,
                 Datatype datatype,
                 int dest,
                 int tag)
          throws MPJException
Blocking send operation. The data part of the message consists of a sequence of count values, each of the type indicated by datatype. The actual argument associated with buf must be an array. The value of offset is a subscript in this array, defining the position of the first item of the message. The elements of buf may have primitive type or class type. If the elements are objects, they must be serializable objects.

Parameters:
buf - send buffer array
offset - initial offset in send buffer
count - number of items to send
datatype - datatype of each item in send buffer
dest - rank of destination
tag - message tag
Throws:
MPJException

recv

public Status recv(Object buf,
                   int offset,
                   int count,
                   Datatype datatype,
                   int source,
                   int tag)
            throws MPJException
Blocking receive operation. The actual argument associated with buf must be an array. The value offset is a subscript in this array, defining the position into which the first item of the incoming message will be copied.

Parameters:
buf - receive buffer array
offset - initial offset in receive buffer
count - number of items in receive buffer
datatype - datatype of each item in receive buffer
source - rank of source
tag - message tag
Returns:
status object
Throws:
MPJException

bsend

public void bsend(Object buf,
                  int offset,
                  int count,
                  Datatype datatype,
                  int dest,
                  int tag)
           throws MPJException
Send in buffered mode. Further comment as for send.

Parameters:
buf - send buffer array
offset - initial offset in send buffer
count - number of items to send
datatype - datatype of each item in send buffer
dest - rank of destination
tag - message tag
Throws:
MPJException

ssend

public void ssend(Object buf,
                  int offset,
                  int count,
                  Datatype datatype,
                  int dest,
                  int tag)
           throws MPJException
Send in synchronous mode. Further comments as for send.

Parameters:
buf - send buffer array
offset - initial offset in send buffer
count - number of items to send
datatype - datatype of each item in send buffer
dest - rank of destination
tag - message tag
Throws:
MPJException

rsend

public void rsend(Object buf,
                  int offset,
                  int count,
                  Datatype datatype,
                  int dest,
                  int tag)
           throws MPJException
Send in ready mode. Further comments as for send.

Parameters:
buf - send buffer array
offset - initial offset in send buffer
count - number of items to send
datatype - datatype of each item in send buffer
dest - rank of destination
tag - message tag
Throws:
MPJException

isend

public Request isend(Object buf,
                     int offset,
                     int count,
                     Datatype datatype,
                     int dest,
                     int tag)
              throws MPJException
Start a standard mode, nonblocking send. Further comments as for send.

Parameters:
buf - send buffer array
offset - initial offset in send buffer
count - number of items to send
datatype - datatype of each item in send buffer
dest - rank of destination
tag - message tag
Returns:
communication request
Throws:
MPJException

ibsend

public Request ibsend(Object buf,
                      int offset,
                      int count,
                      Datatype datatype,
                      int dest,
                      int tag)
               throws MPJException
Start a buffered mode, nonblocking send. Further comments as for send.

Parameters:
buf - send buffer array
offset - initial offset in send buffer
count - number of items to send
datatype - datatype of each item in send buffer
dest - rank of destination
tag - message tag
Returns:
communication request
Throws:
MPJException

issend

public Request issend(Object buf,
                      int offset,
                      int count,
                      Datatype datatype,
                      int dest,
                      int tag)
               throws MPJException
Start a synchronous mode, nonblocking send. Further comments as for send.

Parameters:
buf - send buffer array
offset - initial offset in send buffer
count - number of items to send
datatype - datatype of each item in send buffer
dest - rank of destination
tag - message tag
Returns:
communication request
Throws:
MPJException

irsend

public Request irsend(Object buf,
                      int offset,
                      int count,
                      Datatype datatype,
                      int dest,
                      int tag)
               throws MPJException
Start a ready mode, nonblocking send. Further comments as for send.

Parameters:
buf - send buffer array
offset - initial offset in send buffer
count - number of items to send
datatype - datatype of each item in send buffer
dest - rank of destination
tag - message tag
Returns:
communication request
Throws:
MPJException

irecv

public Request irecv(Object buf,
                     int offset,
                     int count,
                     Datatype datatype,
                     int source,
                     int tag)
              throws MPJException
Start a nonblocking receive. Further comments as for recv.

Parameters:
buf - receiver buffer array
offset - initial offset in receive buffer
count - number of items in receive buffer
datatype - datatype of each item in receive buffer
source - rank of source
tag - message tag
Returns:
communication request
Throws:
MPJException

iprobe

public Status iprobe(int source,
                     int tag)
              throws MPJException
Check if there is an incoming message matching the pattern specified. If such a message is currently available, a status object similar to the return value of a matching recv operation is returned. Otherwise a null reference is returned.

Parameters:
source - source rank
tag - tag value
Returns:
status object or null reference
Throws:
MPJException

probe

public Status probe(int source,
                    int tag)
             throws MPJException
Wait until there is an incoming message matching the pattern specified. Return a status object similar to the return value of a matching recv operation.

Parameters:
source - source rank
tag - tag value
Returns:
status object or null reference
Throws:
MPJException

sendInit

public Prequest sendInit(Object buf,
                         int offset,
                         int count,
                         Datatype datatype,
                         int dest,
                         int tag)
                  throws MPJException
Creates a persistent communication request for a standard mode send. Further comments as for send.

Parameters:
buf - send buffer array
offset - initial offset in send buffer
count - number of items to send
datatype - datatype of each item in send buffer
dest - rank of destination
tag - message tag
Returns:
peristent communication request
Throws:
MPJException

bsendInit

public Prequest bsendInit(Object buf,
                          int offset,
                          int count,
                          Datatype datatype,
                          int dest,
                          int tag)
                   throws MPJException
Creates a persistent communication request for a buffered mode send. Further comment as for send.

Parameters:
buf - send buffer array
offset - initial offset in send buffer
count - number of items to send
datatype - datatype of each item in send buffer
dest - rank of destination
tag - message tag
Returns:
peristent communication request
Throws:
MPJException

ssendInit

public Prequest ssendInit(Object buf,
                          int offset,
                          int count,
                          Datatype datatype,
                          int dest,
                          int tag)
                   throws MPJException
Creates a persitent communication request for a synchronous mode send. Further comments as for send.

Parameters:
buf - send buffer array
offset - initial offset in send buffer
count - number of items to send
datatype - datatype of each item in send buffer
dest - rank of destination
tag - message tag
Returns:
peristent communication request
Throws:
MPJException

rsendInit

public Prequest rsendInit(Object buf,
                          int offset,
                          int count,
                          Datatype datatype,
                          int dest,
                          int tag)
                   throws MPJException
Creates a persistent communication request for a ready mode send. Further comments as for send.

Parameters:
buf - send buffer array
offset - initial offset in send buffer
count - number of items to send
datatype - datatype of each item in send buffer
dest - rank of destination
tag - message tag
Returns:
peristent communication request
Throws:
MPJException

recvInit

public Prequest recvInit(Object buf,
                         int offset,
                         int count,
                         Datatype datatype,
                         int source,
                         int tag)
                  throws MPJException
Creates a persistent communication request for a receive operation. Further comments as for recv.

Parameters:
buf - receive buffer array
offset - initial offset in receive buffer
count - number of items in receive buffer
datatype - datatype of each item in receive buffer
source - rank of source
tag - message tag
Returns:
peristent communication request
Throws:
MPJException

sendrecv

public Status sendrecv(Object sendbuf,
                       int sendoffset,
                       int sendcount,
                       Datatype sendtype,
                       int dest,
                       int sendtag,
                       Object recvbuf,
                       int recvoffset,
                       int recvcount,
                       Datatype recvtype,
                       int source,
                       int recvtag)
                throws MPJException
Execute a blocking send and receive operation. Further comments as for send and recv.

Parameters:
sendbuf - send buffer array
sendoffset - initial offset in send buffer
sendcount - number of items to send
sendtype - datatype of each item in send buffer
dest - rank of destination
sendtag - send tag
recvbuf - receive buffer array
recvoffset - initial offset in receive buffer
recvcount - number of items in receive buffer
recvtype - datatype of each item in recveive buffer
source - rank of source
recvtag - receive tag
Returns:
status object
Throws:
MPJException

sendrecvReplace

public Status sendrecvReplace(Object buf,
                              int offset,
                              int count,
                              Datatype datatype,
                              int dest,
                              int sendtag,
                              int source,
                              int recvtag)
                       throws MPJException
Execute a blocking send and receive operation, receiving message into send buffer. Further comments as for send and recv.

Parameters:
buf - buffer array
offset - initial offset in buffer
count - number of items to send
datatype - datatype of each item in buffer
dest - rank of destination
sendtag - send tag
source - rank of source
recvtag - receive tag
Returns:
status object
Throws:
MPJException

pack

public int pack(Object inbuf,
                int offset,
                int incount,
                Datatype datatype,
                byte[] outbuf,
                int position)
         throws MPJException
Packs message in send buffer inbuf into space specified in outbuf. The return value is the output value of position-the initial value incremented by the number of byte written.

Parameters:
inbuf - input buffer array
offset - initial offset in input buffer
incount - number of items in input buffer
datatype - datatype of each item in input buffer
outbuf - output buffer
position - initial position in output buffer
Returns:
final position in output buffer
Throws:
MPJException

pack

public byte[] pack(Object inbuf,
                   int offset,
                   int incount,
                   Datatype datatype)
            throws MPJException
Packs message in send buffer inbuf into buffer space allocated internally

Parameters:
inbuf - input buffer array
offset - initial offset in input buffer
incount - number of items in input buffer
datatype - datatype of each item in input buffer
Returns:
output buffer
Throws:
MPJException

unpack

public int unpack(byte[] inbuf,
                  int position,
                  Object outbuf,
                  int offset,
                  int outcount,
                  Datatype datatype)
           throws MPJException
Unpacks message in receive buffer outbuf into space specified in inbuf. The return value is the output value of position - the internal value incremented by the number of bytes read.

Parameters:
inbuf - input buffer
position - initial position in input buffer
outbuf - output buffer array
offset - initial offset in output buffer
outcount - number of items in output buffer
datatype - datatype of each item in output buffer
Returns:
final position in input buffer
Throws:
MPJException

packSize

public int packSize(int incount,
                    Datatype datatype)
             throws MPJException
Returns an upper bound on the increment of position effected by pack. It is an error to call this function if the base type of datatype is MPJ.OBJECT.

Parameters:
incount - number of items in input buffer
datatype - datatype of each item in input buffer
Returns:
upper bound on size of packed message
Throws:
MPJException

topoTest

public int topoTest()
             throws MPJException
NOT IMPLEMENTED YET. Returns the type of topology associated with the communicator. The return value will be one of MPJ.GRAPH, MPJ.CART or MPJ.UNDEFINED.

Returns:
topology type of communicator
Throws:
MPJException

abort

public void abort(int errorcode)
           throws MPJException
Throws:
MPJException


The Ibis project