Go to main content
Oracle® Developer Studio 12.5: OpenMP API User's Guide

Exit Print View

Updated: July 2016
 
 

6.4 Scoping Rules for Scalar Variables in a task Construct

When doing automatic scoping, the compiler applies the rules described in this section to determine the scope of a scalar variable in a task construct.


Note -  In this release of Oracle Developer Studio, autoscoping for tasks does not handle arrays.

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 rules TS1 - TS5 in the numeric order. These rules do not apply to variables scoped implicitly by the OpenMP specification, such as loop index variables of parallel for/do loops.

  • 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 construct 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, 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 construct, and some read in the task might get the value assigned outside the task, and the value assigned to the variable inside the task is not used outside the task, then the variable is autoscoped as firstprivate.