next up previous
Next: MPJ as an MPI-like Up: The MPJ API Specification Previous: Rationale

Example and data types

In general the point-to-point communication operations are realized as methods of the Comm class. The basic point-to-point communication operations are send and receive. Their use is illustrated in Figure 2.
Figure 2: Example MPJ program
\begin{figure}\small\begin{verbatim}import mpj.* ;class Hello {
static pu...
...essage) + '':'') ;
Consider, for example, the MPJ analogue of the operation MPI_SEND. The method prototype is:
        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 data type of each item in send buffer
dest rank of destination
tag message tag

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 with elements of corresponding type. 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-compatible basic type, its value must be consistent with the element type of buf. Thus, the basic data type values included in the MPJ API specification are MPJ.BYTE, MPJ.CHAR, MPJ.SHORT, MPJ.BOOLEAN, MPJ.INT, MPJ.LONG, MPJ.FLOAT, MPJ.DOUBLE, and MPJ.OBJECT. If the datatype value is MPJ.OBJECT the objects in the buffer are transparently serialized and unserialized inside the communication operations.

The datatype argument is not redundant in the current specification of MPJ, because the proposal includes support for an analogue of MPI derived types. The derived types of MPJ are restricted to have a unique base type, one of the nine types enumerated above. If the datatype argument of a communication function represents an MPJ derived type, its base type must agree with the Java element type of the associated buf argument. Alternatively, if it was decided to remove derived types from MPJ, datatype arguments could be removed from many functions, and Java runtime inquiries could be used internally to extract the element type of the buffer3.

next up previous
Next: MPJ as an MPI-like Up: The MPJ API Specification Previous: Rationale
Bryan Carpenter 2004-04-24