Intel® Advisor Help

OpenMP* Constructs in the Graph Canvas

To map OpenMP* parallel regions and task constructs to a graph, run the fgt2xml converter with the --omp_experimental flag. In such graph, nodes represent parallel regions and tasks, and edges represent task dependencies

Parallel Regions

All OpenMP-related parallelism is contained within OpenMP parallel regions. In the Flow Graph Analyzer, a parallel region is mapped to a subgraph node in the graph canvas. Inside the subgraph node are at least two nodes:

For example, for an empty parallel region like the following, the Flow Graph Analyzer creates a subgraph node, such as omp0::n0, in the graph canvas.

#pragma omp parallel
{
}

subgraph node shown in the graph canvas

When you double-click the subgraph node, you see the following, where omp0::n0::n1 is the start of the parallel region and omp0::n0::n2 is the implicit barrier at the end of the node.


result of double-clicking the subgraph node

OpenMP* Tasks

An OpenMP* task is a block of code contained in a parallel region that can be executed simultaneously with other tasks in the same region. In the Flow Graph Analyzer, an OpenMP task is mapped to a generic node. For example, in the code below, there are two tasks: one prints hello and the other prints world. The order in which these tasks execute is not specified, so they can execute in any order. However, the two tasks always start after the enclosing parallel region begins, and they complete before the enclosing parallel region ends.

#pragma omp parallel
{
  #pragma omp task
    {  printf("hello "); }
  #pragma omp task
    {  printf("world "); }
}

When you visualize this program in the Flow Graph Analyzer, it looks like this:


visualize the example program in the flow graph analyzer

When you double-click this subgraph, you see the following, where omp0::n0::n1 is the start of the parallel region, omp0::n0::n4 is the implicit barrier at the end of the region, omp0::n0::n2 is the "hello" task and omp0::n0::n3 is the "world" task.



OpenMP* Task Dependencies

In the OpenMP* specification, a partial ordering of tasks can be expressed with depend clauses. The task dependence is fulfilled when the predecessor task completes. There are three dependency types supported by the OpenMP API: in, out, and in-out:

In the Flow Graph Analyzer, task dependencies are represented by edges between the nodes that represent OpenMP tasks.

It is important to understand what dependencies are visualized in the Flow Graph Analyzer.

Note

If there are parallel edges between two nodes and at least one of them can be omitted due to transitivity, they all can be omitted without changing the partial order. The Flow Graph Analyzer includes edges like a <y d in the graph topology because including edges to satisfy all required data dependencies is the most natural representation.

For example:

#pragma omp parallel
  {
    std::string s = "";
    #prgma omp single
    {
      #pragma omp task depend( out: s)
        {      s = "hello";
               printf("%s", s);
        }
      #pragma omp task depend( out: s )
        {      s = "world";
               printf("%s",s);
        }
    }
}

This application, when visualized with the Flow Graph Analyzer, has a single top-level subgraph node representing the OpenMP parallel region.


single top-level subgraph node

When you double-click this subgraph, you see the following:



The edge between omp0::n0::n2 and omp0::n0::n3 represents task dependency due to the variable s.

The main components of the Flow Graph Analyzer include the treemap view, the graph-topology canvas, the timeline and concurrency histogram view, and the critical-path report. OpenMP task traces map naturally to these views:

For more examples, see https://link.springer.com/chapter/10.1007/978-3-319-98521-3_12.

OpenMP* Nodes to Source Code Mapping:

In addition to the graphical view of OpenMP* task dependency graphs, the Flow Graph Analyzer also shows nodes mapping to corresponding source code. To get this information, you must build an OpenMP application with the -g flag.

For example, source code mapping with subgraph nodes in a parallel region looks as follows:


source code mapping with subgraph nodes