Intel® Advisor Help

Annotations

You add Intel® Advisor annotations to mark the places in serial parts of your program where Intel® Advisor tools should assume your program's parallel execution and synchronization will occur. Later, after you modify your program to prepare it for parallel execution, you replace these annotations with parallel framework code that enables parts of your program to execute in parallel.

Note

In most cases, you do not need source annotations when using Intel® Advisor, except for the Suitability analysis of the Threading perspective. When analyzing your application with other perspectives, such as Vectorization and Code Insights or Offload Modeling, you can analyze all parts of your code automatically or use Intel Advisormark-up capabilities, which do not require you to recompile your application.

Annotations are either subroutine calls or macro uses, depending on which language you are using, so they can be processed by your current compiler. The annotations do not change the computations of your program, so your application runs normally.

The three main types of annotations mark the location of:

In addition, there are:

The three Intel Advisor tools recognize the three main types of annotations and the Stop and Resume Collection annotations. Only the Dependencies tool processes the special-purpose annotations.

Use the parallel site and task annotations to mark the code regions that are candidates for adding parallelism. These annotations enable the Intel® Advisor Suitability and Dependencies tools to predict your serial program's parallel behavior. For example:

One common use of sites and tasks is to enclose an entire loop within a parallel site, and to enclose the body of the loop in a task. For example, the following C/C++ code shows a simple loop that uses two parallel site annotations and one task annotation from the nqueens_Advisor sample. The three added annotations and the line that includes the annotation definitions appear in a bold font below.

 #include "advisor-annotate.h"
 ...
 void solve() {
 int * queens = new int[size]; //array representing queens placed on a chess board...
  ANNOTATE_SITE_BEGIN(solve);
  for(int i=0; i<size; i++) {
	 // try all positions in first row
    ANNOTATE_ITERATION_TASK(setQueen);
    setQueen(queens, 0, i);
  }
  ANNOTATE_SITE_END();
 ...
}

The following code from the Fortran nqueens sample shows the use of parallel site and task Fortran annotations, such as call annotate_site_begin("label"). The three added annotations and the line that references the annotation definitions module (the use statement) appear in a bold font below.

 use advisor_annotate
...
! Main solver routine
subroutine solve (queens)
  implicit none
  integer, intent(inout) :: queens(:)
  integer :: i
  call annotate_site_begin("solve")
  do i=1,size
    ! try all positions in first row
    call annotate_iteration_task("setQueen")
    call SetQueen (queens, 1, i)
  end do
  call annotate_site_end

end subroutine solve

The following code from the C# nqueens sample on Windows* OS systems shows the use of parallel site and task C# annotations, such as Annotate.SiteBegin("label");. The three added annotations and the line that allows use of the annotation definitions (using directive) appear in a bold font below.

Note

C# and .NET support is deprecated starting Intel® Advisor 2021.1.
 using AdvisorAnnotate;
...
 public void Solve()
 {
   int[] queens = new int[size]; //array representing queens on a chess board. Index is row position, value is column.
   Annotate.SiteBegin("solve");
   for (int i = 0; i < size; i++)
   {
     Annotate.IterationTask("setQueen");
     // try all positions in first row
     SetQueen(ref queens, 0, i);
   }
   Annotate.SiteEnd();
 ...
 }

To simplify adding annotations:

If you manually type annotations, you should place each annotation on a separate line and use the correct data type for annotation arguments. With C/C++ code, do not place annotations in macros so that references go to the correct source location.

You can experiment by modifying annotations and running the tools again to locate the best places to add parallelism.

For each source compilation module that contains annotations, in addition to adding the annotations, you need to: