Example 12: Nested user-defined parallelism
In this example of user-defined parallelism there are two parallel regions, one nested inside the other.
In this example, all operators from within the parallel regions are fused into two PEs corresponding to the two channels in the outer parallel region.
The parallel transformation replicates operators B and C, and then replicates operators A and all replicas of B and C. This gives two replicas of operator
A and four replicas of operators B and C. Fusion then places the replicas of operator A for each channel in their own PE along with the replicas of
operators B and C for each inner local channel.
composite Comp12-2(input In; output C) {
graph
stream<Type> B = Functor(In) {}
stream<Type> C = Functor(B) {}
}
composite Comp12-1(input In; output O) {
graph
stream<Type> A = Functor(In) {}
@parallel(width=2)
stream<Type> O = Comp12-2(A) {}
}
composite Main12 {
graph
stream<Type> Src = Source() {
config placement: partitionIsolation;
}
@parallel(width=2)
stream<Type> Out = Comp12-1(Src) {
config placement: partitionColocation(byChannel());
}
() as Snk = Sink(Out) {
config placement: partitionIsolation;
}
}

Note that, depending on the fusion mode, explicit colocation only guarantees that operators which are specified to be colocated will be colocated, but not necessarily isolated from other operators. In this example, operators from different channels within the parallel regions could be placed in the same PE.