next up previous contents index
Next: A Distributed Array Communication Up: Some Rules and Definitions Previous: A final rule for   Contents   Index


A recommendation for updating variables

We will define the concept of a home group for every kind of variable that can occur in an HPspmd code in an HPJava program.

Suppose the distribution group of a distributed array $a$ is $p$, and the list of subscripts $e_0, \ldots, e_r, \ldots$ in the element reference

\begin{displaymath}
a \mbox{\tt [} e_0 \mbox{\tt ,}\ldots
\mbox{\tt ,} e_r \mbox{\tt ,}\ldots
\mbox{\tt ]}
\end{displaymath}

includes locations $i,
j, \ldots$, then the home group of the array element is defined to be

\begin{displaymath}
p / i / j / \ldots
\end{displaymath}

If the array has a replicated distribution this group may contain several processes; otherwise it contains a single process.

The home group for a local variable is simply the active process group at the point where the variable is declared.

The home group for an instance variable is the active process group in effect when the parent instance is created.

The home group for an element of a standard Java array is the active process group in effect when the array is created.

The home group for a static field can be taken to be the set of processes in which the program is initiated5.7.

Now, a good rule of thumb for updating variables in general is:

Recommendation 1   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) then we claim that all variables remain coherent. We say a variable is coherent if, at corresponding stages of execution of an HPspmd program, all processes in the home group of a variable hold identical values in their local copies of the variable5.8.

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 one reason why it is only advisory (another reason is that it is probably relatively expensive to enforce this rule by runtime checks).

We call the style of programming in which all variables are held coherent the canonical HPspmd style. Out of the examples given so far in this document, the only one that doesn't follow canonical style is the Monte Carlo program of Figure 3.13. In that program the variable rand has home group p, but it is updated inside nested overall constructs, where the active process group is $\mbox{\tt p} / \mbox{\tt i} / \mbox{\tt 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 algorithmic examples are coherent5.9. The canonical HPspmd style has a close affinity with the pure data parallel programming style of languages like HPF.


next up previous contents index
Next: A Distributed Array Communication Up: Some Rules and Definitions Previous: A final rule for   Contents   Index
Bryan Carpenter 2003-04-15