next up previous contents
Next: A distributed array communication Up: Some rules and definitions Previous: Rules for accessing array   Contents

Recommendations for updating variables

The definition of the home group of a distributed array element can be generalized to other kinds of variable: the home group of a variable (not a distributed array element) is the active process group at the point where the variable is declared.

A good rule of thumb for updating variables in general is

A variable should only be updated when the active process group is identical to the home group of the variable.
If this rule is followed rigorously throughout a program (and if different processes only ever diverge in behaviour through dependencies on values of global indexes in overall constructs, or values of locally held program variables) it has the agreeable consequence that all variables remain coherent. A variable is coherent if, at corresponding stages of execution of an SPMD program, all processes in the home group of a variable always hold identical values in their local copies of the variable.

There are many places in HPJava programs where variables are required to be coherent. This is particularly true of arguments to collective operations. There are other places where it can be convenient to relax the coherence rule, which is why it is only advisory (also because it is relatively expensive to enforce this rule by runtime checks).

The style of programming in which all variables are held coherent is called the canonical HPspmd style. Out of the examples given so far in this article, the only one that doesn't follow canonical style is the Monte Carlo program of Figure 3.10. In that program the variable rand has home group p, but it is updated inside nested overall constructs, where the active process group is p / i / j (also, the initialization of rand involves a dependency on the crd method of Dimension, which is intrinsically incoherent). All other variables in all other examples are coherent5.4. The canonical HPspmd style has an affinity with the pure data parallel programming style of languages like HPF.


next up previous contents
Next: A distributed array communication Up: Some rules and definitions Previous: Rules for accessing array   Contents
Bryan Carpenter 2002-07-12