next up previous contents
Next: LAPI Implementation Up: Implementations Previous: mpiJava-based Implementation   Contents


Multithreaded Implementation

In this implementation, the processes of an HPJava program are mapped to the Java threads of a single JVM. This allows to debug and demonstrate HPJava programs without facing the ordeal of installing MPI or running on a network. A single JVM is used to debug programs before launching them on a network or parallel computer. If an HPJava program is written for execution on distributed memory parallel computers then it may be possible to run the program in this implementation and have behave the same way. As a by-product, it also means we can run HPJava programs on shared memory parallel computers. These kinds of machines are quite widely available today--sold, for example, as high-end UNIX servers. Because the Java threads of modern JVMs are usually executed in parallel on this kind of machine, it is possible to get quit reasonable parallel speedup running HPJava programs in the multithreaded mode.

Figure 5.13: Multithreaded implementation.
\includegraphics[width=6.6in height=3in]{Figs/thread.eps}
Figure 5.13 illustrates multithreaded implementation. In this implementation, communications are involved between Java threads. The set of all threads is stored as an array. Each index in this array represents node id.

Two different static queues send and receive queue are maintained to store early arrival of send and receive requests. Each thread also maintains a wait set in the Request class. Communication of any thread that is stroed in this set will be blocked untile complete transaction. If tasks of a non-blocking send or receive are not completed by the time to call completion method of non-blocking communication, like iwait() or iwaitany(), that particular send or receive is stored into the wait set and is blocked for its completion.

Current version of send() and recv() methods are implemented using isend() and irecv() with iwait() method call. When a send request is created by the send thread, it looks for a matching receive request in the receive queue. If a matching receive request is exist, it copies data from the send buffer to the receive request buffer. It also checks if any other thread is iwait-ing on ``matching receive'' and removes all requests from wait set, and signal the waiting thread. This signal makes the waiting thread awake and continue its operation. The send request will be added into the send queue if it fails to find matching receive queue. A receive request work similarly as the send request. The receive request searches the send queue instead of receive queue for a matching request.


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