User Guide


Identifying Tasks that Operate on Common Input

Threading Building Blocks (TBB) 2018 Update 5 introduced a new preview feature that adds additional meta information to trace data, such as a frame number that a current task is working on. You can use this metadata to track different pipeline stages in execution, for example to identify an unbalanced pipeline. The following demonstrates how to use the user event tracing interface to enable the Flow Graph Analyzer
Highlighted in bold is code that enables the Flow Graph Analyzer to add a unique ID (frame ID) to group tasks.
#include "tbb/flow_graph.h"
#include "tbb/tbb_profiling.h"
#include <string> #include <vector> int main() { tbb::flow::graph g; const int max_frames = 20;
std::vector<tbb::profiling::event*> e;
for(int i=0; i<nbr_of_frames;++i)
e.push_back(new tbb::profiling::event(std::to_string(i)));
tbb::flow::source_node<int> source( g, [&]( int &v) -> bool { static int i = 0; if( i < max_frames ) {
v = i++;
return true; } return false; }, false); tbb::flow::function_node<int> foo( g, tbb::flow::unlimited, []( const int &input1) -> int {
return input1; }); tbb::flow::function_node<int> bar( g, tbb::flow::unlimited,TBB []( const int &input1) -> int {
return input1; }); make_edge(source, foo); make_edge(source, bar); source.activate(); g.wait_for_all(); return 0; }
Compilation of the above code differs based on the TBB version you use:
  • For TBB version 2019 or higher, compile the code with the
    macro and link against the
  • For TBB version 2018 Update 5, compile the code with the
    macros and link against the
To enable the Flow Graph Analyzer
  1. Assign IDs to events doing one of the following:
    • Option 1:
      1. Create an event object or a collection of events upfront, where the only argument is a string (
        data ID
        ) that identifies the event.
      2. Call the emit function of the object to tag a task with a data ID.
    • Option 2: Call a static function inline (inside a task body).
  2. In the
    Execution Trace Views
    tab in the bottom pane, choose
    Color By Data
    from the drop-down list.
Result: The Flow Graph Analyzer groups tasks that share the same data ID and displays them in a common color:
tasks that share the same data id are displayed in a common color

Product and Performance Information


Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804