next up previous
Next: Distributed Loops Up: Towards a Java Environment Previous: The on Construct and

Locations and the at Construct

Returning to the example at the end of Sect.3, we need a mechanism to ensure that the array access

  a [17, 23] = 13 ;
is legal, because the local process holds the element in question. In general determining whether an element is local may be a non-trivial task.

In practise it is unusual to use integer values directly as local subscripts in distributed array dimensions. Instead the idea of a location is introduced. A location can be viewed as an abstract element, or ``slot'', of a distributed range. Conversely, a range can be thought of as a set of locations. An individual location is described by an object of the class Location. Each Location element is mapped to a particular slice of a process grid. In general two locations are identical only if they come from the same position in the same range. A subscripting syntax is used to represent location n in range x:

  Location i = x [n]

This is an important idea in HPJava. By working in terms of abstract locations--elements of distributed ranges--one can usually respect locality of reference without resorting explicitly to low-level local subscripts and process ids. In fact the location can be viewed as an abstract data type incorporating these lower-level offsets. The data fields of Location include dim and crd. The first is the process dimension of the parent range. The second is the coordinate in that dimension to which the element is mapped.

Locations are used to parametrize a new distributed control construct called the at construct. This is analogous to on, except that its body is executed only on processes that hold the specified location. Locations can also be used directly as array subscripts, in place on integers. So the access to element a [17, 23] could now be safely written as follows:

  Location i = x [17], j = y [23] ;

      a [i, j] = 13 ;
Locations used as array subscripts must be elements of the corresponding ranges of the array.

There is a restriction that an at(i) construct should only appear at a point of execution where i.dim is a dimension of the active process group. In the examples of this section this means that an at(i) construct, say, should normally be nested directly or indirectly inside an on(p) construct.

The range class has a member function idx which can be used to recover the integer subscript, given a location in the range.

next up previous
Next: Distributed Loops Up: Towards a Java Environment Previous: The on Construct and
Bryan Carpenter 2002-07-11