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

Exit Print View

Updated: July 2016
 
 

4.2 OpenMP Data Environment

The task directive takes the following data-sharing attribute clauses that define the data environment of the task:

  • default (private | firstprivate | shared | none)

  • private (list)

  • firstprivate (list)

  • shared (list)

All references within a task to a variable listed in the shared clause refer to the variable with that same name known at the point when the task construct is encountered.

For each private and firstprivate variable, new storage is created and all references to the original variable in the lexical extent of the task construct are replaced by references to the new storage. A firstprivate variable is initialized with the value of the original variable at the point when the task construct is encountered.

The OpenMP specification describes how the data-sharing attributes of variables referenced in parallel, task, or work-sharing constructs are determined.

The data-sharing attributes of variables referenced in a construct may be predetermined, explicitly determined, or implicitly determined. Certain variables have predetermined data-sharing attributes; for example, the loop iteration variable in a parallel for/do construct is private. Variables with explicitly determined data-sharing attributes are those that are referenced in a given construct and are listed in a data-sharing attribute clause on the construct. Variables with implicitly determined data-sharing attributes are those that are referenced in a given construct, do not have predetermined data-sharing attributes, and are not listed in a data-sharing attribute clause on the construct.


Note -  The rules for how the data-sharing attributes of variables are implicitly determined might not always be obvious. To avoid any surprises, be sure to explicitly scope all variables that are referenced in a task construct using the data-sharing attribute clauses rather than relying on the OpenMP implicit scoping rules.