Intel® Advisor User Guide

ID 766448
Date 11/07/2023
Public

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

Document Table of Contents

Experimental Support for OpenMP* Applications

You can now trace, visualize, and analyze OpenMP* parallel regions, tasks, and task dependencies in your application with the Flow Graph Analyzer.

The Flow Graph Analyzer support for OpenMP technology is experimental and currently covers two basic scenarios:

  • OpenMP parallel regions are nested inside a Intel® oneAPI Threading Building Blocks (oneTBB) flow graph. For this case, the Flow Graph Analyzer shows the execution of the parallel regions in the per-thread task execution timelines.

    The sample code below, omp_nested.cpp, is an example of an OpenMP construct nested inside a oneTBB flow graph:

    #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;  
    }
    
  • OpenMP tasks that use depends clauses. In this, the Flow Graph Analyzer shows task execution in the timelines and provides experimental support that lets you see the dependency relationships between OpenMP tasks as a graph in the graph canvas.

    The sample code below, omp_depend.cpp, is a hello-world example of OpenMP task dependencies:

    #include <omp.h>
    #include<iostream>
    
    int main() {
      #pragma omp parallel
       {
        std::string s = "";
        #prgma omp single
        {
          #pragma omp task depend( out: i)
            {      s = "hello";
                   printf("%s", s);
            }
          #pragma omp task depend( out: s )
            {      s = "world";
                   printf("%s",s);
            }
        }
       }
         return 0;
    }