Intel® Advisor User Guide

ID 766448
Date 10/31/2024
Public
Document Table of Contents

Task Organization and Annotations

You will choose a region of code to execute as a task. This region is the static extent of the task. The task includes not just its static extent, but also any other code that is called from the static extent when it executes - this is the dynamic extent.

In addition to choosing tasks, you will also decide which tasks can execute in parallel with one another. To do this, you will choose parallel sites. A parallel site, like a task, has a static extent which is a block of code and a dynamic extent which includes all the code that is called from it.

NOTE:

If you have a loop with a single task and the task includes the entire loop body, you can use the simplified parallel site with one iteration task annotation. The remainder of this topic and this group of topics describe the more complex case where multiple tasks are needed within a parallel site.

The execution of tasks with the serial execution done by Intel® Advisor works like this:

  1. A parallel site begins when execution reaches the begin-site annotation.

  2. A task is created when execution reaches the begin-task annotation. The task executes independently, in parallel with any other tasks that are already executing, including the parallel site itself.

  3. When the execution of a task reaches an end-task annotation, the task terminates. Intel® Advisor end-task annotations do not allow or require an end-task label, so be aware that in some cases the task's execution could reach a task-end annotation for a different task, which can impact the predicted parallel performance.

  4. When execution reaches the end-site annotation for the parallel site, Intel® Advisor predicts that execution suspends (waits) until all tasks that were created within it have terminated, after which execution exits the parallel site.

With C/C++ code, note that goto, break, continue, return, and throw statements must not bypass the end of the static extent of a task or parallel site! With Fortran code, such statements include goto and return. You may need to add extra end annotations before these operations so the Intel® Advisor tools will correctly model the end of a site or task.

Because you will later add parallel framework code after you no longer need the Intel® Advisor annotations, you need to be aware of the requirements of the parallel framework. For example, some parallel frameworks might not allow a branch out of a task, such as a loop task. Whenever possible, plan your tasks to suit the needs of the parallel framework code. The annotations are present only while you need Intel® Advisor to help you predict the proposed parallel behavior and make decisions about the best locations for your tasks.

After you decide where the parallel sites and tasks are in your program, add source annotations.