Locations

An HPJava range object can be thought of as a set of abstract *locations*.
In our earlier example,

Procs2 p = new Procs2(2, 3) ; on(p) { Range x = new BlockRange(N, p.dim(0)) ; Range y = new BlockRange(N, p.dim(1)) ; ... }the range

overall(i = x for 1 : N - 2) { ... }the symbol

With a few exceptions that will be discussed later, the
subscript of a distributed array *must be a bound location*, and the
location must be an element of the range associated with the array dimension.
This is why we introduced the temporary arrays for 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^{2.6}.

Figure 2.6 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 .

Besides overall, there is another control construct in HPJava that
defines a bound location--the simpler *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). We
cannot simply write something like

float [[,]] a = new float [[x, y]] ; ... a [1, 4] = 73 ;because 1 and 4 are not bound locations, and therefore not legal subscripts. We

float [[,]] a = new float [[x, y]] ; ... at(i = x [1]) at(j = y [4]) a [i, j] = 73 ;Again the symbols

The operational meaning 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 again to Figure 2.6, the outer

at(i = x [1])construct limits execution of its body to processes with coordinates , and . The inner

at(j = y [4])restricts execution further to just process . This is exactly the process that owns element

An operational definition of overall can be given in terms of the simpler at construct. The construct

overall(i = x for l : u : s) { ... }is equivalent in behaviour to

for(int n = l; n <= u ; n += s) at(i = x [n]) { ... }The body of the at construct is skipped for values of

The at construct completes the contingent of new control
constructs in HPJava. We sometimes refer to the three constructs
on, at and overall as *distributed control*
constructs, and sometimes, more grandiosely, as *structured SPMD*
control constructs.

The backquote symbol, ```

, can be used as a postfix operator on
a bound location, thus:

i`This expression evaluates to the integer global index value. In the operational definition of the overall given above, this is the value called

We now know enough about HPJava to write some complete examples.