next up previous contents
Next: Analysis of Method Up: Implementation on the Cray Previous: The Combine function

The Dist class

This class is used to create single, temporary, distributed items of Data . These have been created as solution to the following problem. If the user wants to form a computation using the nodes in the structure, it will be necessary to Read the data values, perform the computation, and then Write the values back into the structure. As the program is run in a SPMD fashion, this will result in all the processors reading, and computing with the data. This is obviously wasteful, and the read function also requires a global broadcast of data, which all processors much participate in. One solution would be to have combined operations that read values, compute, then write updated values back. Only the processors directly involved with the relevant parts of the structure are then required to take part. As has been shown the function Combine is provided, which partly gets around the problem, and can be used when efficiency is important. The disadvantage of this is that these combined functions are cumbersome to use, so we introduce the idea of a distributed temporary data item, which allows computations to be expressed in a much cleaner way.

Each Dist object is a single item of data, located on one of the processors. When the user creates the object, a node in the data structure is specified, and the data will be placed on the processor that owns that particular node. This enables the user to write code as in fig. 5.4.


 
Figure 5.4:   Use of dist object
\begin{figure}
\begin{verbatim}
Dist a(dt,p), b(dt,q), c(dt,r); 
b = p;
c = r;
a = b + c;\end{verbatim}\end{figure}

Here p,q,r are all nodes of data structure dt. We first initialise b and c with values from dt, and then form a sum. The assignment and addition operators are overloaded in such a way that only the processors that store the arguments, actually carry out the computation. This allows parallelism in the code to be extracted, whilst making the user code clearer.


next up previous contents
Next: Analysis of Method Up: Implementation on the Cray Previous: The Combine function
Timothy Lewis
11/12/1997