So a parallel HPJava program starts concurrently in all members of some process set. From inside the HPJava program, the processes are organized and labelled through special objects representing process groups. In general the processes in an HPJava group are organized into multidimensional grids2.1.
Suppose a program is running concurrently on 6 or
more processes. It may then define a 2 by 3 process grid as follows
![]() |
If a Procs2 constructor is invoked and the requested number of processes is greater than the number of processes the program is running on2.2, an hpjava.lang.ProcsArrayTooLargeException is thrown.
The Procs2 constructor is an example of a collective operation. It should be invoked concurrently by all members of the active process group. Perhaps it won't come as too much of a surprise that Procs2 is another example of an HPspmd class. The property of being an HPspmd class has implications beyond just ensuring that a main() method is started in multiple processes. Generally speaking, if a method or constructor is to be invoked in a collective way, it will be defined in a class that implements the HPspmd interface.
Procs2 is also a subclass of the special class hpjava.lang.Group. The Group class has a privileged status in the HPJava language. An object that inherits from this class can be used in a couple of special contexts. For example, it can be used to parametrize an on construct.
After creating p we will probably want to perform some operations
within the processes of this particular grid. An on construct
restricts control to processes in its parameter group. So in
If we save the following program:
The on construct in these examples establishes p as the active process group (or APG) within its body. The idea of an active process group that can change from line to line as the program is executed is an important concept in HPJava. The influence of the active process group will be seen in various places as we describe the language.
There is an auxilliary class hpjava.lang.Dimension associated with
process grids. Objects of class Dimension describe a particular
dimension or axis of a particular process grid. We will refer to
them as process dimensions. The process dimensions of a grid
are accessible through the inquiry method
of the
Procs class. The argument
is in the range
, where in general
is the rank (dimensionality) of the grid.
The Dimension class in turn has a method crd() that
returns the local process coordinate associated with the
dimension--ie, the position of the local process within the dimension.
If compile and execute the following HPJava program
There is nothing special about 2-dimensional grids. The full Group hierarchy of HPJava includes the classes of Figure 2.3. Not surprisingly, Procs1 is a one-dimensional process ``grid''. Less obviously, perhaps, Procs0 is a group containing exactly one process. This class is sometimes used to create a group that singles out a unique controlling process in a program. Higher dimensional grids are also allowed2.3.
Note that so far the only special syntax we have added to the Java language is the on construct. The Group class has special status in HPJava, but syntactically it is just a class. The status of Group in HPJava is comparable with the status of Throwable, say, in standard Java--only a Throwable object can appear in a throw statement, and only a Throwable class can appear in the header of a catch block or a throws clause. Likewise in HPJava, only a Group object can appear in the header of an on construct (or in the on clause of distributed arrays, which will be introduced later).