Examine the Task's Static and Dynamic
Extent
Consider the example of incidental sharing from the
help topic
Incidental
Sharing:
extern int x; ANNOTATE_SITE_BEGIN(site1); for (i = 0; i != n; ++i) { ANNOTATE_ITERATION_TASK(task1); x = a[i]; b[i] = x * b[i]; } ANNOTATE_SITE_END();
Examining the Static Extent of the
Task
If you define a substitute variable inside the
static extent, then each task will get its own private storage for it:
extern int x; // ... ANNOTATE_SITE_BEGIN(site2); for (i = 0; i != n; ++i) { ANNOTATE_ITERATION_TASK(task2); int x_sub; x_sub = a[i]; b[i] = x_sub * b[i]; } ANNOTATE_SITE_END();
Examining the Dynamic Extent of the
Task
In the simplest cases, like the example above, the
task's dynamic extent is the same as its static extent - it does not contain
any function calls. When it does contain function calls, all the functions that
might be called while the task is executing are part of its dynamic extent, and
you need to consider all reads and writes of the memory location in all of
those functions.
So, you need to examine not only the static extent,
but also the dynamic extent of a task.