next up previous contents
Next: Multithreaded Implementation Up: Implementations Previous: Implementations   Contents


mpiJava-based Implementation

The mpiJava-based implementation assumes C binding of native method calls to MPI from mpiJava (see section 3.4.1) as basic communication protocol. This implementation can be divided into two parts: Java APIs (Buffer and Comm classes) which are described in the previous sections and C native methods that construct the message vector and perform communication. The Java-side methods of communicator class Comm and message buffer class Buffer are used to call native methods via JNI. The C stubs that bind the mpjdev communication class to the underlying native MPI implementation are created using JNI, which Java can call and thus pass parameters to and from a native API.

To optimize the performance of this version, we maintain the message buffer inside the C code. Instances of a C struct type (lightweight object) Buffer (differnt from the Java side Buffer class) is used for maintain message vector. This lightweight object stores a pointer to the message vectors and other information that is used for operation on the message vector: information like original capacity, current capacity, and current write and read position of vector.

Message elements of all data types other than Object are stored as C char [] array. This architectural decision means actual communication takes place only with MPI_BYTE data type. Before sending, we extract char [] array from the C object and store the total number of data bytes of the array into the Primary header (see section 5.3). This size information is used to make sure capacity of receive side vector is large enough to hold incoming data. For elements of Object type, the serialized data are stored into a Java byte [] array. We can send this array by copying into the existing message vector if it has space to hold serialized data array, or by using separate send if the original message vector is not large enough.

In latter case there will be two different sends from the sender side. The receiver side will have to expect a second message.


next up previous contents
Next: Multithreaded Implementation Up: Implementations Previous: Implementations   Contents
Bryan Carpenter 2004-06-09