HPJava  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.
As explained in the previous section, the underlying distributed array model is equivalent to the HPF array model. Array mapping is described in terms of a slightly different set of basic concepts. 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 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 -dimensional distributed array involves double brackets surrounding 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
: '') of ranges
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
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 . Figure 2 illustrates the use of the 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). The communication library routine Adlib.writeHalo 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.
The short examples here have already covered much of the special syntax of HPJava. Other significant extensions allow Fortran-90-like sections of distributed arrays. This, in turn, forces us to define certain subranges and subgroups. Arrays constructed directly using subgroups and subranges can reproduce all the alignment options of HPF. In any case, the language itself is relatively simple. Complexities associated with varied and irregular patterns of communication are dealt with in libraries. These can implement many richer operations than the writeHalo and cshift functions of the examples.