![]() |
The HPJava Project |
||
|
|||
![]()
![]() ![]() ![]() |
Distributed arraysThe distributed arrays of HPJava are built-in container classes analogous to, but distinct from, the ordinary arrays of Java. They are true multidimensional arrays, they support an idea of array sections imported from Fortran 90, and their elements can be distributed over a group of processes.In principle the elements of a distributed array can be arbitrary objects, including arrays or even other distributed arrays. To simplify implementation, the initial HPJava compiler restricts the elements of distributed arrays to be variables of primitive type. In any case, distributed arrays can appear as data members of objects and as elements of ordinary Java arrays. The type signature of a distributed array differs from the type signature of an ordinary array in using double brackets, [[ and ]]. A double-bracket pair encloses one or more comma-separated slots. The number of these slots determines the rank of the array. The slots may be empty, or they may include a single asterisk. An asterisk indicates that the associated array dimension is sequential, rather than distributed. The syntax for creating a distributed array is modelled on the corresponding syntax for ordinary arrays, but again it uses double brackets enclosing comma-separated slots. This time each slot contains a range object (if the dimension is distributed) or an integer expression (if the dimension is sequential). Any distributed array is distributed over a specific process group. By default this is the current active process group, but this default can be overridden by appending an on clause to the array constructor, specifying some subset of the APG. In any case, all non-collapsed ranges appearing in the constructor brackets must be distributed over distinct dimensions of the group which the array as a whole is distributed over.
Here are some examples of distributed array declarations:
Arrays a and b have essentially identical structure. They are block-distributed in their first dimension and cyclically distributed in their second. Array c is block-distributed in its first dimension but sequential in its second. Implicitly c is replicated over the second dimension of p, because it has no range distributed over this process dimension. Both dimensions of d are sequential, and the array is replicated over the whole of the active process group.
Groups, ranges and distributed arrays are objects, and like any
other object they can appear as data members of other objects and be
passed to or returned from member functions. When an array is passed
to a member furnction, some limited information about the array is
picked up at compile-time from the type signature of the array - the
type of its elements, the rank of the array, and possibly a
specification that some of the dimensions are sequential. Further
information about the structure of the array can be obtained at
runtime through the inquiries grp and rng:
Next: Accessing array elements |