Annotate Code for Deeper Analysis
Annotate Code for Deeper Analysis
Before you can
annotations, you need to
mark
the best parallel opportunities by adding
Intel® Advisor
choose
likely places to add parallelism. This section provides a series of topics that explain factors to consider as you examine the candidate code regions and their execution and choose candidate places.
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 Advisor
mark-up capabilities, which do not require you to recompile your application.
The operations of a serial program execute one after another in a well-defined order, starting at the beginning, continuing to the end, and then stopping. A parallel program, on the other hand, is made up of
tasks
- portions of the program that may execute independently on separate cores. Tasks can either be implemented in separate functions or in iterations of a loop.
You mark your proposed code regions by adding
annotations that identify the:
Intel® Advisor
- Parallel site: A code region that contains one or more parallel tasks. Execution of a parallel site constrains the time during which the tasks that it contains can execute. Although execution of a parallel site begins when its execution reaches its beginning, tits execution terminates only after all tasks that started within it have completed. In parallel frameworks, this corresponds to thejoinlocation in the code where all tasks have completed.
- Parallel tasks: Task code regions run independently, at the same time as other tasks within the parallel site and the enclosing parallel site itself. Also, each task can have multiple instances of its code executing. As shown in the table below, there are two forms of task annotations:
- For a loop with only a single task, add a single iteration task annotation within the two site annotations.
- For other code, add a task annotation pair to mark the task region's begin and end within the two site annotations.
Characteristics of Parallel Site Code
| Parallel Site and Task Annotations
| Comments and Limitations
|
---|---|---|
A loop that requires only a single task. For simple loops, begin with the type of task annotation, unless the task does not include the entire loop body.
Example code:
nqueens_Advisor C/C++ sample and
nqueens Fortran and C# samples
| Add three annotations to mark:
| Based on the Suitability tool performance predictions, you may want to try using multiple tasks. In this case, remove the single iteration task annotation and replace it with task begin and task end annotations for each task (see the next row).
If the loop structure is complex, you may need to mark the task begin and task end region by using the task annotations in the next row.
|
Complex loop, code that allows multiple tasks, or non-loop code
Example code:
stats C++ sample
| Add four annotations to mark:
|
After you choose several places to add parallelism, view the data displayed in the
Survey Report
window. Use this data and your code editor to add annotations to mark the candidate parallel sites and their task(s). Make sure that these annotations are executed by the selected target executable.
The site and task annotations enable the
Suitability and Dependencies tools to predict your serial program's execution as a parallel program. These tools perform extensive analysis of your running serial program to provide data needed to help you decide the best place(s) to add parallelism.
Intel® Advisor
To take advantage of the
parallel design capabilities, experiment with different possible parallel code regions by modifying the site and task annotations and their locations, rebuilding your application's target, and running the Suitability and Dependencies tools again.
Intel® Advisor
The following figure illustrates the
nqueens_Advisor
C/C++ sample code to show the task (blue background) and its enclosing parallel site (orange background).

Before you convert your serial program into a parallel program, you need to:
- Understand where your program is spending its time.
- Decide how to divide that work up into tasks that can execute in parallel.