next up previous contents
Next: Expressing Run-Time Values Up: The Communications Language Previous: Multiple Threads of Control

Communicating in Subsets of the Mesh

  Applications need to be able to express that a given operator functions on a subset of the whole mesh (as was assumed implicitly when discussing multiple threads of control, above). For example, the user may wish to specify a broadcast on the first column of a mesh only. Accordingly, the language includes a subset operator that can be used to specify that the operators within it run on the given subset. Multiple operators may appear within a subset construct, in an implicit sequential context. Given a $4\times 4$ mesh, a first-column broadcast would be specified as


\begin{singlespace}
\begin{verbatim}
(subset '((0 4 8 12))
 (broadcast 'b 0))\end{verbatim} \end{singlespace}

Often, what an application needs to do is express that it is performing a broadcast, for example, on all the columns of a mesh. While this could be done syntactically by placing multiple subset constructs within a parallel, the subset construct itself can be used to express this more elegantly. The first argument to the subset construct is actually a list of subsets; the resulting COP code is equivalent to wrapping a parallel around separate subset constructs, one for each member of the list. To express a broadcast on each column of a $4\times 4$ mesh can be done by:


\begin{singlespace}
\begin{verbatim}
(subset '((0 4 8 12) (1 5 9 13) (2 6 10 14) (3 7 11 15))
 (broadcast 'b 0))\end{verbatim} \end{singlespace}

This is equivalent to four (broadcast 'b) operators in parallel, each specifying a different column of the mesh. The broadcast source (zero) is taken to be relative to the subset, so the broadcast on the second column is from node 1, on the third column from node 2, and so forth. The language allows multiple instances of an operator, as in this case; however, multiple instances can't be specified as reading from or writing to the same node, and they must appear in the same context in the COP program. The four broadcasts specified implicitly in the example above are thus considered to be a single operator defined with four instances.

Some global variables are defined in COP to make parameterizing COP programs easier; they include *nodes* (the total number of nodes), *xsize*, *ysize*, and *zsize* (the size in each dimension). Like operator operands, these values are relative to the current subset context. It is also possible to nest subset constructs, with the subset argument being, again, relative to the enclosing subset context. Subsets are dynamically scoped, rather than lexically scoped like the rest of the language.


next up previous contents
Next: Expressing Run-Time Values Up: The Communications Language Previous: Multiple Threads of Control
Back to Chris Metcalf's home page