Intel® Advisor User Guide

ID 766448
Date 6/24/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Nested Parallelism in Flow Graph Analyzer

The Flow Graph Analyzer supports visualization of applications that contain multiple levels of parallelism, such as nested Intel® oneAPI Threading Building Blocks (oneTBB) algorithms and OpenMP* parallel regions. This feature requires additional support from the parallel runtime libraries and can be used in combination with a oneTBB flow graph.

The sample code below is an example of nested parallelism that combines a oneTBB flow graph, a oneTBBparallel_for algorithm, and an OpenMP* parallel region.

#include "tbb/tbb.h"
#include "tbb/flow_graph.h"
#include <omp.h>
#include <iostream>

using namespace tbb;
using namespace tbb::flow;
int main() {
  graph g;
  const int size = 20;
  continue_node< continue_msg> hello( g,
    []( const continue_msg &) {
      std::cout << "Hello\n";
      tbb::parallel_for(0, size, 1, [=](int k) {
        std::cout << k << "\n";  });
      });
  continue_node< continue_msg> world( g,
    []( const continue_msg &) 
      std::cout << " World\n";
      #pragma omp parallel for 
        for (int i=0; i<20; i++) {
          std::cout << i <<"\n"; } }
  );
  make_edge(hello, world);
  hello.try_put(continue_msg());
  g.wait_for_all();
  return 0;  
}   
    

Tracing Nested Intel® oneAPI Threading Building Blocks (oneTBB) Algorithms

oneTBB enables general tracing of parallel algorithms, which is enabled by default and activated by the Flow Graph Analyzer trace collector.

As a result, Flow Graph Analyzer can display oneTBB library activity in nested and non-nested algorithms. Therefore, task context switches are captured and can be visualized in the Flow Graph Analyzer GUI. This work is similar to tasks in the timeline and is named according to its algorithm (for example, parallel_for).

NOTE:

This information might not be available for user-defined task groups.

Tracing Nested OpenMP* Algorithms

For detailed information on Flow Graph Analyzer support for OpenMP* technology, see Experimental Support for OpenMP* Applications.