next up previous contents
Next: Task-Parallelism in HPJava Up: Message-passing for HPJava Previous: Message-passing for HPJava   Contents


The mpiJava wrapper

The Message-Passing Interface (MPI) [39] was developed by a group of researchers from industry, government, and academia. It provides a rich set of communication libraries, application topologies and user defined data types. MPI is the first message-passing standard for programming parallel processors. Our mpiJava software implements a Java binding for MPI proposed late in 1997. The API is modeled as closely as practical on the C++ binding defined in the MPI 2.0 standard, specifically supporting the MPI 1.1 subset of that standard. The mpiJava is developed by our research group and currently version 1.2 is available. The MPI standard is explicitly object-based. The C and Fortran bindings rely on ``opaque objects'' that can be manipulated only by acquiring object handles from constructor functions, and passing the handles to suitable functions in the library. The C++ binding specified in the MPI 2 standard collects these objects into suitable class hierarchies and defines most of the library functions as class member functions. The mpiJava API follows this model, lifting the structure of its class hierarchy directly from the C++ binding. The major classes of mpiJava are illustrated in Figure 3.7.
Figure 3.7: Principal classes of mpiJava
\begin{figure}
\centerline{\epsfig{figure=Figs/mpiJava.eps,width=5in}}
\end{figure}
The class MPI only has static members. It acts as a module containing global services, such as initialization of MPI, and many global constants including the default communicator COMM_WORLD. The most important class in the package is the communicator class Comm. All communication functions in mpiJava are members of Comm or its subclasses. As usual in MPI, a communicator stands for a ``collective object'' logically shared by a group of processors. The processes communicate, typically by addressing messages to their peers through the common communicator. Another class that is important later discussion is the Datatype class. This describes the type of the elements in the message buffers passed to send, receive, and all other communication functions. Various basic data types are predefined in the package. These mainly correspond to the primitive types of Java, shown in Table 3.1 that allows Java objects to be communicated. The MPI.OBJECT type is a new predefined basic data type of mpiJava. The standard send and receive operations of MPI are members of Comm with interfaces:

$\displaystyle \begin{minipage}[t]{\linewidth}\small\verb$ public void Send(Obje...
...ount, $\\
\verb$ Datatype datatype, int source, int tag)$\\ 
\end{minipage}
$

In both cases the actual argument corresponding to buf must be a Java array. In these and all other mpiJava calls, the buffer array argument is followed by an offset that specifies the element of in array where the message actually starts. A native MPI library, a version of the Java Development Toolkit (JDK), and a C compiler is necessary to install mpiJava. The MPI Java classes and the C stubs that bind the MPI Java classes to the underlying native MPI implementation are two core parts of mpiJava. We create these C stubs using Java Native Interface (JNI), which Java can call and pass parameters to and from a native API. The new version 1.2 of the software supports direct communication of objects via object serialization, which is an important step toward implementing the specification in [14].

Table 3.1: Basic data types of mpiJava
MPI data type Java data type
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


The mpiJava software is available from
  http://www.hpjava.org/mpiJava.html
The releases of mpiJava include complete source, make files, configuration scripts, compiled libraries for WMPI, release test codes (based on the IBM MPI test suit), example applications, javadoc documentation, and installation usage notes.
next up previous contents
Next: Task-Parallelism in HPJava Up: Message-passing for HPJava Previous: Message-passing for HPJava   Contents
Bryan Carpenter 2004-06-09