Skip Navigation Links | |
Exit Print View | |
Oracle Solaris Studio 12.3: OpenMP API User's Guide Oracle Solaris Studio 12.3 Information Library |
2. Compiling and Running OpenMP Programs
3. Implementation-Defined Behaviors
6. Automatic Scoping of Variables
6.1 Autoscoping Data Scope Clause
6.2 Scoping Rules for a Parallel Construct
6.2.1 Scoping Rules for Scalar Variables
6.2.2 Scoping Rules for Arrays
6.4 General Comments About Autoscoping
6.6 Checking the Results of Autoscoping
Under automatic scoping, the compiler applies the rules described in this section to determine the scope of a variable in a task construct.
These rules do not apply to variables scoped implicitly by the OpenMP specification, such as loop index variables of PARALLEL DO/for loops.
When autoscoping a scalar variable that is referenced in a task construct and that does not have predetermined or implicitly determined scope, the compiler checks the use of the variable against the following rules TS1-TS5 in the given order.
TS1: If the use of the variable is read-only in the task construct and read-only in the parallel construct in which the task construct is enclosed, then the variable is autoscoped as FIRSTPRIVATE.
TS2: If the use of the variable is free of data race and the variable will be accessible while the task is executing, then the variable is autoscoped as SHARED.
TS3: If the use of the variable is free of data race, is read-only in the task construct, and the variable may not be accessible while the task is executing, then the variable is autoscoped as FIRSTPRIVATE.
TS4: If the use of the variable is not free of data race, and in each thread executing the task region the variable is always written before being read by the same thread, and the value assigned to the variable in the task is not used outside the task region, then the variable is autoscoped as PRIVATE.
TS5: If the use of the variable is not free of data race, and the variable is not read-only in the task region, and some read in the task region might get the value defined outside the task, and the value assigned to the variable inside the task is not used outside the task region, then the variable is autoscoped as FIRSTPRIVATE.
Autoscoping for tasks does not handle arrays.