next up previous contents
Next: Parallel Programming and Locations Up: The HPJava Language Previous: Processes   Contents


Distributed Arrays

One of the most important feature HPJava adds to Java is the distributed array. A distributed array is a generalized kind of multiarray, a collective array shared by a number of processes. Like an ordinary multiarray, a distributed array has a rectangular, multidimensional index space, and stores a collection of elements of fixed type. Unlike an ordinary array, associates elements are distributed over the processes that share the array. The type signatures and constructors of distributed arrays are similar to those of sequential multiarrays (see the section 3.4.1). But the distribution of the index space is parameterized by a special class, Range or its subclasses. In the following HPJava program we create a two-dimensional, N $ \times $N, array of floating points distributed over the grid p. The distribution of the array, a, for N = 8 is illustrated in Figure 3.4.

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{verbatim}
Procs2 p = ...
...le [[-,-]] a = new double [[x, y]] on p ;
...
}\end{verbatim}\end{minipage}
$

Figure 3.4: A two-dimensional array distributed over p.
\includegraphics[width=4in]{Figures/2d-array-distribution}
The subclass BlockRange for index range of the array allows the index space of each array dimension to be divided into consecutive blocks. Ranges of a single array should be distributed over distinct dimensions of the same process grid. The type signature of a multiarray is generally represented as

$\displaystyle T \verb$ [[$$   attr$\displaystyle _0, \ldots,$   attr$\displaystyle _{R-1} \verb$]] $$   bras$\displaystyle $

where $ R$ is the rank of the array and each term attr$ _r$ is either a single hyphen, -, for a distributed dimension or a single asterisk, *, for a sequential dimension, the term bras is a string of zero or more bracket pairs, []. In principle, $ T$ can be any Java type other than an array type. This signature represents the type of a multiarray whose elements have Java type

$\displaystyle T \verb$ $$   bras$\displaystyle $

If `bras' is non-empty, the elements of the multiarray are (standard Java) arrays.
next up previous contents
Next: Parallel Programming and Locations Up: The HPJava Language Previous: Processes   Contents
Bryan Carpenter 2004-06-09