next up previous
Next: Distributed arrays Up: HPJava: data parallel extensions Previous: Multidimensional arrays


Process arrays

HPJava adds class libraries and some additional syntax for dealing with distributed arrays. These arrays are viewed as coherent global entities, but their elements are divided across a set of cooperating processes. As a pre-requisite to introducing distributed arrays we discuss the process arrays over which their elements are scattered.

An abstract base class Procs has subclasses Procs1, Procs2, ..., representing one-dimensional process arrays, two-dimensional process arrays, and so on.

  Procs2 p = new Procs2(2, 2) ;
  Procs1 q = new Procs1(4) ;
These declarations set p to represent a 2 by 2 process array and q to represent a 4-element, one-dimensional process array. In either case the object created describes a group of 4 processes. At the time the Procs constructors are executed the program should be executing on four or more processes. Either constructor selects four processes from this set and identifies them as members of the constructed group4.

Procs has a member function called member, returning a boolean value. This is true if the local process is a member of the group, false otherwise.

  if(p.member()) {
    ...
  }
The code inside the if is executed only if the local process is a member p. We will say that inside this construct the active process group is restricted to p.

The multi-dimensional structure of a process array is reflected in its set of process dimensions. An object is associated with each dimension. These objects are accessed through the inquiry member dim:

  Dimension x = p.dim(0) ;
  Dimension y = p.dim(1) ;

  Dimension z = q.dim(0) ;
The object returned by the dim inquiry has class Dimension. The members of this class include the inquiry crd. This returns the coordinate of the local process with respect to the process dimension. The result is only well-defined if the local process is a member of the parent process array. The inner body code in
  if(p.member())
    if(x.crd() == 0)
      if(y.crd() == 0) {
        ...
      }
will only execute on the first process from p, with coordinates $(0, 0)$.


next up previous
Next: Distributed arrays Up: HPJava: data parallel extensions Previous: Multidimensional arrays
Bryan Carpenter 2002-07-11