Next: Data type matching and
Up: Point-to-Point Communication
Previous: Introduction
Contents
Blocking Send and Receive operations
void Comm.send(Object buf, int offset, int count,
Datatype datatype, int dest, int tag)
| 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 |
Blocking send operation.
Java binding of the MPI operation MPI_SEND.
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 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.
If the datatype argument represents an MPI basic type, its
value must agree with the element type of buf:
the basic MPI datatypes supported, and their correspondence to Java types,
are as follows
| MPI datatype |
Java datatype |
| MPI.BYTE |
byte |
| MPI.CHAR |
char |
| MPI.SHORT |
short |
| MPI.BOOLEAN |
boolean |
| MPI.INT |
int |
| MPI.LONG |
long |
| MPI.FLOAT |
float |
| MPI.DOUBLE |
double |
| MPI.OBJECT |
Object |
If the datatype argument represents an MPI derived type, its
base type must agree with the element type of buf
(see section A.3.12).
- Rationale. The datatype argument is not redundant in Java, because
this proposal includes support for MPI derived types. If it was decided
to remove derived types from the API, datatype arguments
could be removed from various functions, and Java runtime inquiries
could be used internally to extract the element type of the buffer,
or methods like send could be overloaded to accept
buffers with elements of the 9 basic types. (The disadvantage of the
latter approach is that it leads to a large proliferation in the
number of methods. Historically MPI has eschewed this kind of
overloading. Java at least provides runtime mechanisms for checking
type correctness, so the extra security provided by overloading is
probably not an essential requirement.)(End of rationale.)
If a data type has MPI.OBJECT as its base type, the objects in
the buffer will be transparently serialized and unserialized inside the
communication operations.
- Advice to implementors. While straightforward in principle, this extension involves several
complications for JNI-based wrapper implementations. The size of
the physical receive buffer cannot be computed in advance, so
it may be necessary to split the physical message into a header
message containing buffer size, followed by the data. This
notably complicates wrappers for communication methods based on
Request classes. Also, the wrapper has to be prepared to
interpret derived types with MPI.OBJECT as the base type,
because of course the underlying C MPI cannot do this.(End of advice to implementors.)
Status Comm.recv(Object buf, int offset, int count,
Datatype datatype, int source, int tag)
| 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 |
Blocking receive operation. Java binding of the MPI operation MPI_RECV. 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.
The elements of buf may have primitive type or class type.
If the datatype argument represents an MPI basic type, its
value must agree with the element type of buf;
if datatype represents an MPI derived type, its
base type must agree with the element type of buf
(see section A.3.12).
The MPI constants MPI_ANY_SOURCE and MPI_ANY_TAG are
available as MPI.ANY_SOURCE and MPI.ANY_TAG.
The following methods can be used to interrogate the return status
of a receive operation.
int Status.getSource()
| returns: |
source of the received message. |
int Status.getTag()
| returns: |
tag of the received message. |
- Rationale. Following common object-oriented practices, source and
tag values are returned by inquiry functions getSource
and getTag, rather than through publicly accessible fields
in the Status class.(End of rationale.)
int Status.getCount(Datatype datatype)
| datatype |
datatype of each item in receive buffer |
| |
|
| returns: |
number of received entries |
Java binding of the MPI operation MPI_GET_COUNT.
Next: Data type matching and
Up: Point-to-Point Communication
Previous: Introduction
Contents
Bryan Carpenter
2002-07-12