next up previous contents
Next: Organization of the Dissertation Up: Introduction Previous: Introduction   Contents


Features of HPJava

In this section, we present a high level overview of our HPJava. Some predefined classes and some extra syntax for dealing with distributed arrays are added into the basic language, Java. We will briefly review the features of the HPJava language by showing simple HPJava examples. In this section, we will only give an overview of features. Detailed description of those features will be presented in the Chapter 3.
Figure 1.1: Sequential Matrix multiplication in HPJava.

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{verbatim}
float [[*, ...
... k < L; k++)
c [i, j] += a [i, k] + b [k, j];
}\end{verbatim}\end{minipage}
$

Figure 1.1 is a basic HPJava program for sequential matrix multiplication. This program is simple and similar to the ordinary Java program. It uses simple sequential multiarrays--a feature HPJava adds to standard Java. A multiarray uses double brackets to distinguish the type signature from a standard Java array. The multiarray and ordinary Java array have many similarities. Both arrays have some index space and stores a collection of elements of fixed type. Syntax of accessing a multiarray is very similar with accessing ordinary Java array which uses single brackets, but an HPJava sequential multiarray uses double bracket and asterisks for its type signature. The most significant difference between ordinary Java array and the multiarray of HPJava is that the distributed array is true multi-dimensional array like the arrays of Fortran, while ordinary Java only provides arrays of arrays. These features of Fortran arrays have adapted and evolved to support scientific and parallel algorithms.
Figure 1.2: A parallel Matrix multiplication in HPJava.

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{verbatim}
Procs2 p = ...
...
sum += a[i, k] * b[k, j];
c[i, j] = sum;
}
}\end{verbatim}\end{minipage}
$

HPJava also adds a distributed array feature to the base language Java. The distributed array is a very important feature of HPJava. Like the name says, the elements of the distributed array are distributed among processes: each process only has a portion of the data. As we can see from the parallel version (Figure 1.2) of matrix multiplication, HPJava puts a hyphen in the type signature to indicate a particular dimension is distributed over processes. Input arrays a and b and result array c are distributed arrays. The array c is distributed in both its dimensions while array a and b each have one distributed dimension and one sequential dimension. Figure 1.2 is a simple program but it includes much of the HPJava special syntax. In this program, we can see some unusual key words and operations which we do not see in an ordinary Java program like control constructs on and overall. There are also some added standard classes, like Procs2, and BlockRange. The class Procs2 represents 2-dimensional grids of processes selected from the set of available processes. The on construct makes p the active process group within its body, and only the processes that belong to p execute the code inside of the on construct. Distribution format of each dimension of a distributed array is represented by a Range class. The BlockRange class used in this example describes block-distributed indexes. We also have a control construct which represents distributed parallel loops, similar the forall construct in High Performance Fortran (HPF), called overall. The overall construct introduced a distributed index for subscripting a distributed array. The program in Figure 1.2 depends on a special alignment relation between its distributed arrays.
Figure 1.3: A general Matrix multiplication in HPJava.

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{verbatim}
public void...
...m += ta [i, k] * tb [k, j];
c[i, j] = sum;
}
}\end{verbatim}\end{minipage}
$

We can create a general purpose matrix multiplication routine that works for arrays with any distributed format (Figure 1.3) from Figure 1.2 using collective communication. This program take arrays which may be distributed in both their dimensions, and copies into the temporary array with a special distribution format for better performance. A collective communication schedule remap() is used to copy the elements of one distributed array to another. From the viewpoint of this dissertation, the most important part of this code is communication method. We can divide the communication library of HPJava into two parts: the high-level Adlib library, and the low-level mpjdev library. The Adlib library is responsible for the collective communication schedules and the mpjdev library is responsible for the actual communication. One of the most characteristic and important communication library methods, remap(), takes two arrays as arguments and copies the elements of the source array to the destination array, regardless of the distribution format of the two arrays. In addition to the features described above, many more features and communication functions available to the HPJava are described in the Chapter 3 and Chapter 4. The HPJava software including Adlib and mpjdev is available for free download from www.hpjava.org.
next up previous contents
Next: Organization of the Dissertation Up: Introduction Previous: Introduction   Contents
Bryan Carpenter 2004-06-09