An HPJava range object can be thought of as a set of abstract locations.
In our earlier example,
With a few exceptions that will be discussed later, the subscript of a distributed array must be a distributed index, and the location must be an element of the range associated with the array dimension. This is why we introduced the temporary arrays of neighbours in the stencil update example of the previous section. Arbitrary expressions are not usually legal subscripts for a distributed array. If we want to combine elements of arrays that are not precisely aligned, we first have to use a library function such as shift to align them.
Figure 2.7 is an attempt to visualize the mapping of
locations from x and y. We will write the locations of
x as x[0], x[1], ..., x[N - 1]. Each
location is mapped to a particular group of processes. Location x[1] is mapped to the three processes with coordinates
,
and
. Location y[4] is mapped to the two
processes with coordinates
and
.
There is one other construct in HPJava besides overall that
defines a distributed index. This is the relatively simple
at construct. Suppose we
want to update or access a single element of a distributed array
(rather than accessing a whole set of of elements in parallel).
it is not allowed to write simply
The effect of the at construct should be fairly
clear. It is similar to the on construct. It restricts control
to processes in the set that hold the specified location.
Referring back to Figure 2.7, the outer
So we see that the odd-looking restriction that subscripts must be distributed indices helps ensure that processes only manipulate array elements stored locally. If a process has to access non-local data, some explicit library call is needed to fetch it, like the Adlib.shift() operations used in the previous section.
We can now formally define the meaning of the overall construct
in terms of the simpler at construct. If s is greater
than zero, the construct
The at construct completes the contingent of special control constructs in HPJava. We sometimes refer to the three constructs on, at and overall as distributed control constructs.
The backquote symbol, `, can be used as a postfix operator on
a distributed index, thus:
We now know enough about HPJava to write some more complete examples.