I have an application where I currently have "bubbles" in the pipeline. I.e. if a condition is met the data object does not need to be processed further. Is there a better way to do this than passing bubbles through? Perhaps one where succeeding stages of the pipeline are not invoked without losing the structure provided by TBB's pipeline construct.
Passing of bubbles might be a rather light overhead. This willdepend on the internal structure of how pipes are stitched together in TBB. The overhead could be measured using a test app. Example: pass N nodes of static data (no I/O) through pipe performing function representative of your application and measure the total time. Then pass the same N nodes and process every other node (NOOP for the other nodes). Compare the run times
The bubble passing may be a requirement when you also require the output data to be in the collation order of the input data. If collation is not a requirement then concievably you could return the bubble to the input side of the pipeline for immediate reuse.
Run the timing test, because this overhead may be smaller than you expect. Additionaly, the code and/or additional overhead to extract the bubble may exceed the time to pass the bubble.
While I have not examined the TBB code for this overhead, I do know the overhead on the QuickThread parallel_pipeline is on the order of 50 C++statements to pass a bubble from stage to stage. If you have a pipeline of a very few stages, the overhead is not worth going after in your hunt for places to optimize.