JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris Studio 12.3: OpenMP API User's Guide     Oracle Solaris Studio 12.3 Information Library
search filter icon
search icon

Document Information


1.  Introducing the OpenMP API

2.  Compiling and Running OpenMP Programs

3.  Implementation-Defined Behaviors

4.  Nested Parallelism

5.  Tasking

6.  Automatic Scoping of Variables

6.1 Autoscoping Data Scope Clause

6.1.1 __auto Clause

6.1.2 default(__auto) 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.3 Scoping Rules for a task Construct

6.3.1 Scoping Rules for Scalar Variables

6.3.2 Scoping Rules for Arrays

6.4 General Comments About Autoscoping

6.5 Restrictions

6.6 Checking the Results of Autoscoping

6.7 Autoscoping Examples

7.  Scope Checking

8.  Performance Considerations

A.  Placement of Clauses on Directives


Chapter 6

Automatic Scoping of Variables

Declaring the data sharing attributes of variables referenced in an OpenMP construct is called scoping. A description of each of the data sharing attributes can be found in Data-Sharing Attribute Clauses section (Chapter 2) of the OpenMP specification.

In an OpenMP program, every variable referenced in an OpenMP construct is scoped. Generally, a variable referenced in a construct may be scoped in one of two ways. Either the programmer explicitly declares the scope of a variable with a data sharing attribute clause, or the implementation of the OpenMP API in the compiler automatically applies rules for predetermined or implicitly determined scopes according to the Data Environment: Data Scoping Rules section (Chapter 2) of the OpenMP specification.

Most users find scoping to be the hardest part of using the OpenMP paradigm. Explicitly scoping variables can be tedious and error-prone, especially with large and complicated programs. Moreover, the rules for implicitly determined and predetermined scopes of variables specified in the OpenMP 3.0 specification can yield some unexpected results. The task directive, which was introduced in OpenMP Specification 3.0, added to the complexity and difficulty of scoping.

The automatic scoping feature (called autoscoping)supported by the Oracle Solaris Studio compilers can be a very helpful tool, as it relieves the programmer from having to explicitly determine the scopes of variables. With autoscoping, the compiler determines the scopes of variables by using some smart rules in a very simple user model.

Earlier compiler releases limited autoscoping to variables in a parallel construct. Current Oracle Solaris Studio compilers extend the autoscoping feature to variables referenced in a task construct as well.