Example 5: Two splitters
In this example of user-defined parallelism, one stream feeds multiple parallel regions. Each parallel region needs an independent splitter.
The parallel transformation replicates operators A and B for the first parallel region, and operators C and D for the second parallel region.
The Src operator is given two splitters, one to feed each parallel region. Fusion places the sibling operators for operators A, B, C and D for each channel into a PE. Fusion places the Src and Snk
operators into their own PEs.
composite Comp5_1(input In; output B) {
graph
stream<Type> A = Functor(In) {}
stream<Type> B = Functor(A) {}
}
composite Comp5_2(input In; output D) {
graph
stream<Type> C = Functor(In) {}
stream<Type> D = Functor(C) {}
}
composite Main5 {
graph
stream<Type> Src = Source() {
config placement: partitionIsolation;
}
@parallel(width=2)
stream<Type> Out_1 = Comp5_1(Src) {
config placement: partitionColocation(byChannel());
}
@parallel(width=2)
stream<Type> Out_2 = Comp5_2(Src) {
config placement: partitionColocation(byChannel());
}
() as Snk = Sink(Out_1, Out_2) {
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.