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.
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, as described in the help topic Site and Task Annotations for Simple Loops With One Task. 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:
A parallel site begins when execution reaches the begin-site annotation.
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.
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.
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
throw statements must not bypass the end of the static extent of a task or parallel site! With Fortran code, such statements include
return. You may need to insert 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 insert 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 as described in the help topic Annotating Parallel Sites and Tasks.