Oracle® Solaris Studio 12.4: OpenMP API User's Guide

Exit Print View

Updated: December 2014
 
 

6.3.1 Scoping Rules for Scalar Variables in a parallel Construct

When autoscoping a scalar variable that is referenced in a parallel construct and that does not have predetermined or implicitly determined scope, the compiler checks the use of the variable against the following rules PS1 - PS3 in the given order.

  • PS1: If the use of the variable in the parallel construct is free of data race conditions for the threads in the team executing the construct, then the variable is scoped as shared.

  • PS2: If in each thread executing the parallel construct the variable is always written before being read by the same thread, then the variable is scoped as private. The variable is scoped as lastprivate if it can be scoped private and it is read before it is written after the parallel construct, and the construct is either a parallel for/do or a parallel sections.

  • PS3: If the variable is used in a reduction operation that can be recognized by the compiler, then the variable is scoped as reduction with that particular operation type.