HOME
| OPENMP API Specification: Version 5.1 November 2020

2.5.2  Assume Directive

Summary The assume directive provides invariants to the implementation that may be used for optimization purposes. If the invariants do not hold at runtime, the behavior is unspecified. The assume directive is an informational directive.

Syntax

SVG-Viewer needed.

The syntax of the assume directive is as follows:  

 
#pragma omp assumes clause[ [ [,] clause] ... ] new-line  

or  

 
#pragma omp begin assumes clause[ [ [,] clause] ... ] new-line 
  declaration-definition-seq 
#pragma omp end assumes new-line  

or  

 
#pragma omp assume clause[ [ [,] clause] ... ] new-line 
  structured-block  

where clause is either assumption-clause or a clause of the form ext_implementation-defined-assumption for an implementation-defined assumption clause, and where assumption-clause is one of the following:  

 
  absent(directive-name [[, directive-name]...]) 
  contains(directive-name [[, directive-name]...]) 
  holds(scalar-expression) 
  no_openmp 
  no_openmp_routines 
  no_parallelism  

SVG-Viewer needed.

SVG-Viewer needed.

The syntax of the assume directive is as follows:  

 
!$omp assumes clause[ [ [,] clause] ... ]  

or  

 
!$omp assume clause[ [ [,] clause] ... ] 
    loosely-structured-block 
!$omp end assume  

or  

 
!$omp assume clause[ [ [,] clause] ... ] 
    strictly-structured-block 
[!$omp end assume]  

where clause is either assumption-clause or a clause of the form ext_implementation-defined-assumption for an implementation-defined assumption clause,

where assumption-clause is one of the following:  

 
  absent(directive-name [[, directive-name]...]) 
  contains(directive-name [[, directive-name]...]) 
  holds(scalar-logical-expression) 
  no_openmp 
  no_openmp_routines 
  no_parallelism  

SVG-Viewer needed.

Description The assume directive gives the implementation additional information about the expected properties of the program that can optionally be used to optimize the implementation. An implementation may ignore this information without altering the behavior of the program.

The scope of the assumes directive is the code executed and reached from the current compilation unit. The scope of the assume directive is the code executed in the corresponding region or in any region that is nested in the corresponding region.

SVG-Viewer needed.

The scope of the begin assumes directive is the code that is executed and reached from any of the declared functions in declaration-definition-seq.

SVG-Viewer needed.

The absent and contains clauses accept a list of one or more directive names that may match a construct that is encountered within the scope of the directive. An encountered construct matches the directive name if it has the same name as one of the specified directive names or if it is a combined or composite construct for which a constituent construct has the same name as one of the specified directive names.

When the absent clause appears on an assume directive, the application guarantees that no constructs that match a listed directive name are encountered in the scope of the assume directive.

When the contains clause appears on an assume directive, the application provides a hint that constructs that match the listed directive names are likely to be encountered in the scope of the assume directive.

When the holds clause appears on an assume directive, the application guarantees that the listed expression evaluates to true in the scope of the directive. The effect of the clause does not include an evaluation of the expression that is observable.

The no_openmp clause guarantees that no OpenMP related code is executed in the scope of the directive.

The no_openmp_routines clause guarantees that no explicit OpenMP runtime library calls are executed in the scope of the directive.

The no_parallelism clause guarantees that no OpenMP tasks (explicit or implicit) will be generated and that no SIMD constructs will be executed in the scope of the directive.

Implementers are allowed to include additional implementation-defined assumption clauses. All implementation-defined assumptions should begin with ext_. Assumption names that do not start with ext_ are reserved.

Restrictions The restrictions to the assume directive are as follows: