next up previous
Next: Array sections Up: Semantic Checking in HPJava Previous: Introduction


HPJava--an HPspmd language

HPJava [3] is an instance of our HPsmpd language model. HPJava extends its base language, Java, by adding some predefined classes and some additional syntax for dealing with distributed arrays.

We aim to provide a flexible hybrid of the data parallel and low-level SPMD paradigms. To this end HPF-like distributed arrays appear as language primitives. But a design decision is made that all access to non-local array elements should go through library functions--either calls to a collective communication library, or simply get and put functions for access to remote blocks of a distributed array1.

A subscripting syntax is applied to distributed arrays to reference elements. But an array element reference must not imply access to a value held on a different processor. To simplify the task of the programmer, who must be sure accessed elements are held locally, the languages adds distributed control constructs. These play a role something like the ON HOME directives of HPF 2.0 and earlier data parallel languages [8]. One special control construct--a distributed parallel loop--facilitates traversal of locally held elements from a group of aligned arrays.

Array mapping is described in terms of a slightly different set of basic concepts from HPF. Process group objects generalize the processor arrangements of HPF. Distributed range objects are used instead HPF templates. A distributed range is comparable with a single dimension of an HPF template. These substitutions are a change of parametrization only. Groups and ranges fit better with our distributed control constructs.

Figure 1: A parallel matrix addition.
\begin{figure*}\small\begin{verbatim}Procs2 p = new Procs2(P, P) ;
on(p) {
...
...or :)
c [i, j] = a [i, j] + b [i, j] ;
}\end{verbatim}\normalsize\end{figure*}

Figure 1 is a simple example of an HPJava program. It illustrates creation of distributed arrays, and access to their elements. The class Procs2 is a standard library class derived from the special base class Group. It represents a two-dimensional grid of processes. Similarly the distributed range class BlockRange is a library class derived from the special class Range; it denotes a range of subscripts distributed with BLOCK distribution format over a specific process dimension. Process dimensions associated with a grid are returned by the dim() inquiry. The on(p) construct is a new control construct specifying that the enclosed actions are performed only by processes in group p.

The variables a, b and c are all distributed array objects. The type signature of an $r$-dimensional distributed array involves double brackets surrounding $r$ comma-separated slots. The constructors specify that these all have ranges x and y--they are all M by N arrays, block-distributed over p.

A second new control construct, overall, implements a distributed parallel loop. The constructs here iterate over all locations (selected by the degenerate interval `` : '') of ranges x and y. The symbols i and j scoped by these constructs are bound locations. In HPF, a distributed array element is referenced using integer subscripts, like an ordinary array. In HPJava, with a couple of exceptions noted below, the subscripts in element references must be bound locations, and these must be locations in the range associated with the array dimension. This rather drastic restriction is a principal means of ensuring that referenced array elements are held locally.

Figure 2: Red-black iteration.
\begin{figure}\par\small\begin{verbatim}Procs2 p = new Procs2(P, P) ;
on(p) ...
...+
u [i, j - 1] + u [i, j + 1]) ;
}
}\end{verbatim}\normalsize\par\end{figure}

The general policy is relaxed slightly to simplify coding of stencil updates. A subscript can be a shifted location. Usually this is only legal if the subscripted array is declared with suitable ghost regions [6]. Figure 2 illustrates the use of the standard library class ExtBlockRange to create arrays with ghost extensions (in this case, extensions of width 1 on either side of the locally held ``physical'' segment). A function, writeHalo, from the communication library Adlib updates the ghost region. This example also illustrates application of a postfix backquote operator to a bound location. The expression i` (read ``i-primed'') yields the integer global loop index.

Distributed arrays can be defined with some sequential dimensions. The sequential attribute of an array dimension is flagged by an asterisk in the type signature. As illustrated in Figure 3, element reference subscripts in sequential dimensions can be ordinary integer expressions.

Figure 3: A pipelined matrix multiplication program.
\begin{figure}\small\begin{verbatim}Procs1 p = new Procs1(P) ;
on(p) {
Rang...
...mp, b, 1, 1) ;
HPspmd.copy(b, tmp) ;
}
}\end{verbatim}\normalsize\end{figure}

The short examples here have covered the basic syntax of HPJava. The language itself is relatively simple. Complexities associated with varied and irregular patterns of communication are dealt with in libraries, which can implement many richer operations than the writeHalo and cshift functions of the examples. The remaining important extensions to the language itself can be motivated most easily by considering the need to support Fortran 90 style sections of distributed arrays.


next up previous
Next: Array sections Up: Semantic Checking in HPJava Previous: Introduction
Bryan Carpenter 2002-07-11