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
mesh can be done by:
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.