The HPJava Project


HPJava Home Page
HPspmd lectures
mpiJava
HPJava language

PCRC Home Page

NPAC Home Page



Java Grande Home

Process groups

The syntax extensions of HPJava depend on a two base classes that have a special status in the language - the Group and Range classes. This section is concerned with groups.

A group, or process group, defines some subset of the processes executing the SPMD program. Groups have two important roles in HPJava. First are used to describe how program variables such as arrays are distributed or replicated across the process pool. Secondly they are used to specify which subset of processes execute a particular code fragment.

In HPJava groups are represented by objects of class Group. There are several ways to create group objects. The most common is to use the constructor for one of the subclasses representing a process grid. The class hierarchy of groups and process grids is shown below

Procs1 is a one-dimensional ``grid'' of processes, Procs2 is a two-dimensional grid, and so on. As a special case, Procs0 is a group containing a single process. The constructors for these classes generally take a list of extents specifying the shape of the grid. In all cases, the constructor selects the processes of the grid from the set of processes that collectively call the constructor; if specified size of the grid is larger than this set of processes, an exception occurs.

A straightforward use of grids was illustrated in a previous section, where the elements of various arrays were distributed over the processes in a grid. Grids and groups have another important role. The language incorporates a formal idea of an active process group. At a typical point of execution in a program some group of processes is sharing the current ``thread of control''. This group is engaged in ``loosely synchronous'' collective behaviour. The cooperating group is called the ``Active Process Group'' (APG). There may be points of program execution where all processes are performing quite independent tasks. HPJava regards this as a special case where all processes belong to active groups of one - themselves.

The on construct seen in a previous section is an obvious example of a program construct that affects the active process group. Inside the construct on(p) (which can only appear when p is a subset of the active process group) the APG is reduced to p. More subtly, the overall distributed loop construct also affects the APG, breaking it into smaller, independently operating groups. This point will be discussed more in detail later.

We have seen how ranges and hence arrays can be divided over the dimensions of a grid (``process dimensions''). Groups and the APG have another role in describing program variables. They appear in the idea of coherence. An explicit example of coherence was given in the matrix multiplication example. It was mentioned that arrays like a and b declared with replicated storage should be initialized with identical values in each copy of the array. The elements of a and b are then coherent variables.

Coherence is relevant to other variables besides array elements. In the matrix multiplication example, scalar expressions like P and N should take the same value in every active process, otherwise very odd behaviour can be expected. Again this is an example of coherence. Without some idea of coherence it is difficult to write a sensible SPMD program.

Coherence is sufficiently important that one might expect an SPMD language to somehow enforce it. HPJava does not attempt this for a couple of reasons. For one thing, there are various practical examples where deliberate use of incoherent variables can be convenient. For another, it may be difficult for the compiler to check globally that variables are updated in a coherent way (unless some very strict restrictions are placed on variable usage).

Applied sufficiently rigorously, the following advisory rule will ensure variables remain coherent: define the home group of a variable (other than an array element) as the APG that was in effect when the variable was created. The general rule is that a variable should only be updated when the APG is equal to the home group of that variable. The home group of an array element will be defined later.

In principle coherence is a fragile thing. Once any variable in the program loses coherence, this lack of coherence can creep into other variables. In practice this is less of a problem than it sounds in theory. In a canonically written HPJava program the majority of variables are likely to be coherent.

Next: Ranges


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