next up previous contents
Next: The Read function Up: The main Dtype Structure Previous: The main Dtype Structure

NotInvolved

As the programming model is SPMD, if we are traversing a large structure, we want to discourage processors from needlessly moving through parts of the structure where they own no nodes. This function can be inserted into code and used to implement this. As each processor can only affect nodes that they own, this cannot change the computation, and should increase the parallelism. As example of the user code that is required, consider fig. 5.2, a function to map a function over a binary tree. The upper code fragment is the sequential version, the lower the additions required to make it execute using the library functions. There is quite a close correspondance between the two. The test for a null pointer in the sequential is replaced by a call to check if the node exists in the parallel version, and the traversal of the sub-trees is handled in a similar way. The NotInvolved function is inserted in the body of the function, and causes the processor to return, and not spawn any more recursive calls.


 
Figure 5.2:   User code for mapping over a binary tree
\begin{figure}
\begin{verbatim}
void
Map(Tree *t, Data fn(Data)) {

 if (!t) {re...
 ... dt.Subnode(p,Right);

 Map(dt,l,fn);
 Map(dt,r,fn);
}\end{verbatim}\end{figure}


 
Figure 5.3:   Dtype functions available to user
\begin{figure}
\begin{verbatim}
Dtype(Algebra algebra); //Constructor, creates a...
 ...ion statistics
void Display(Path *p); //Outputs node p\end{verbatim}\end{figure}


next up previous contents
Next: The Read function Up: The main Dtype Structure Previous: The main Dtype Structure
Timothy Lewis
11/12/1997