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

Document Information

Preface

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 The 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

B.  Converting to OpenMP

Index

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 section 2.9.3 of the OpenMP 3.0 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 section 2.9.1 of the OpenMP 3.0 specification.

Most users will 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 may 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 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 Solaris Studio compilers extend the autoscoping feature to variables referenced in a task construct as well.