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

Exit Print View

Updated: July 2016
 
 

6.1 Variable Scoping Overview

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 the variable with a data-sharing attribute clause, or the compiler automatically applies rules for predetermined and implicitly determined scopes according to Section 2.14.1, "Data-Sharing Attribute Rules", in the OpenMP 4.0 specification. For more information about data-sharing attributes, see Section 2.14.3, "Data-Sharing Attribute Clauses", of the OpenMP 4.0 specification.

Explicitly scoping variables can be tedious and error-prone, especially with large and complicated programs. Moreover, the data-sharing attribute rules can yield some unexpected results. The task directive adds to the complexity and difficulty of scoping.

The automatic scoping feature (called autoscoping) supported by the Oracle Developer Studio compilers 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 simple user model.

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