The Intel® Threading Building Blocks flow graph is now fully supported

Intel® Threading Building Blocks (Intel® TBB) 3.0 Update 5 introduced the graph API as a Community Preview feature.  After several months of evaluation by development teams across media, gaming, financial services, and technical computing segments the graph is now being introduced as a fully supported Feature in Intel® TBB 4.0.   In addition to some API changes and performance improvements, the graph also has a new name.  We now use the name flow graph to emphasize that this feature expresses the control-flow in an application.  The more generic name graph falsely implied a more data-structure centric approach. 

An Intel® TBB flow graph still consists of three primary components: a graph object, nodes and edges.  All of these components are now found in a new namespace tbb::flow.  A graph object for example is of type tbb::flow::graph.  As in the Community Preview version of graph, the graph object provides methods to run tasks in the context of the flow graph and to wait for the flow graph to complete.



Figure 1: The components of an Intel® TBB flow graph.

As show in Figure 2, there a variety of different node types.  Some are functional, that is, they perform a user-provided computation to generate, transform, or consume messages.  Some node types provide buffering.  Other nodes such as the join_node, split_node and or_node create or break apart an n-tuple of messages.  And then there are also a set of utility nodes that perform other useful functions.



* the multioutput_function_node, split_node and or_node are being introduced as Community Preview features in Intel® TBB 4.0.

Figure 2: The node types support by the Intel® Threading Building Blocks flow graph

The flow graph adds significant functionality to Intel® Threading Building Blocks 4.0.  However, some applications suited to the flow graph can also be implemented using the library’s low-level support for acyclic graphs of tasks and the generic pipeline class or parallel_pipeline algorithm.   Table 1 compares these different features and provides characteristics that may help in selecting the most appropriate model to use.

Table 1: Comparing flow graph, pipeline / parallel_pipeline and graphs of tasks

  task graphs pipeline / parallel_pipeline flow graph
Expressiveness Can express acyclic dependency graphs. Can express linear pipelines. Can express acyclic dependency graphs as well as acyclic and cyclic messaging graphs.
Ease-of-use Requires low-level book-keeping code and explicit spawning of tasks. A concise, type safe interface More verbose than parallel_pipeline, but does not require explicit book-keeping or task spawning.
Persistence Graphs are executed destructively.  Cannot be re-executed. Can be executed multiple times. Can be executed multiple times.
Scheduling Uses spawned tasks, which optimize for cache locality. Uses spawned tasks, which optimize for cache locality. Uses enqueued tasks, which are fairness-oriented and support fire-and-forget use cases.
Performance Very low overhead since it is built directly on tasks and is executed destructively. Overhead is comparable to flow graph. Overhead is comparable to pipeline and parallel_pipeline.


Intel® Threading Building Blocks (Intel® TBB) 4.0 includes flow graph as a fully supported feature.   A flow graph can be used to express static and dynamic dependency graphs, as well as reactive or event-based graphs that respond to and pass messages between computations.

To help explore the types of algorithms that can be expressed with the Intel® TBB flow graph, we will be posting several other blog articles over the coming days that describe example applications in detail.  You can find all of the flow graph related blogs at /en-us/blogs/tag/flow_graph/.

Tags:
For more complete information about compiler optimizations, see our Optimization Notice.

Comments

's picture

Hello Michael!

Which software did You use to create the symbols of the various node types, and which software to create the visual representation of the sample flow graphs posted in some other blog entries?
Are the symbols freely downloadable?

Thanks in advance
Josef