The HPJava Project


HPJava Home Page
HPspmd lectures
mpiJava
HPJava language

PCRC Home Page

NPAC Home Page



Java Grande Home

Accessing array elements

The mechanism for subscripting distributed arrays in HPJava is complicated by the fact that only local elements are supposed to be directly accessible. One cannot simply use a global integer subscript in a distributed dimension of an array, because in general that might refer to an element held by some other process.

The language incorporates a special syntactic entity called a location. A location is a particular element of a particular distributed range. The nth location (starting from zero) of range x is designated x[n]. In a normal subscripting operation, any subscript in a distributed dimension of an array must be a location in the range associated with that dimension of the array. This constraint alone doesn't guarantee that the location (and thus array element) is locally resident. To ensure this, we insist that the location used as a subscript must be a named subscript scoped by an at or overall construct.

In

    Range x = new BlockRange(N, p.dim(0)) ;
    Range y = new BlockRange(N, p.dim(1)) ;

    float [[]] d = new float [[x]] ;

    d [0] = 27 ;          // Illegal!

    d [x [0]] = 27 ;      // Illegal!

    at(i = x [0])
      d [i] = 27 ;        // OK

    at(j = y [0])
      d [j] = 27 ;        // Illegal!
the first assignment is illegal because an integer subscript cannot be used in a distributed array dimension. The second assignment is still illegal, because the subscript is not a named location. The third assignment is OK: the at construct scopes a named location. The body of the construct is only executed by processors that hold the specified location. The final assignment is illegal again, because j is not a location in the range, x, of d.

Locations have a peculiar status in the language. They can only be named through overall or at constructs. This implies that location values cannot be stored in ordinary Java variables or passed as arguments to user-defined methods. It is sometimes convenient to regard locations as having class Location, but really they live somewhere outside the normal type system - essentially a symbolic convenience. Locations are not ``first class'' entities of the language. Their status is comparable with, say, the FORALL indices, or the alignment dummies, of HPF.

Next: Subgroups


Bryan Carpenter, (dbc@npac.syr.edu). Last updated January 2000.