Task Organization and Annotations
You will choose a region of code to execute as a task. This region is the
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
.
static extent
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
. 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.
parallel sites
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
works like this:
Intel® Advisor
- 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.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.Intel® Advisor
- When execution reaches the end-site annotation for the parallel site,predicts that execution suspends (waits) until all tasks that were created within it have terminated, after which execution exits the parallel site.Intel® Advisor
With C/C++ code, note that
tools will correctly model the end of a site or task.
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
You may need to add extra
goto
and
return
.end
annotations before these operations so the
Intel® Advisor
Because you will later add parallel framework code after you no longer need the
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
to help you predict the proposed parallel behavior and make decisions about the best locations for your tasks.
Intel® Advisor
Intel® Advisor
After you decide where the parallel sites and tasks are in your program, add source annotations.