HOME
| OPENMP API Specification: Version 5.0 November 2018

2.3.4  Metadirectives

SummaryA metadirective is a directive that can specify multiple directive variants of which one may be conditionally selected to replace the metadirective based on the enclosing OpenMP context.

Syntax

SVG-Viewer needed.

The syntax of a metadirective takes one of the following forms:  

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

or  

 
#pragma omp begin metadirective [clause[ [,] clause] ... ] new-line 
    stmt(s) 
#pragma omp end metadirective  

where clause is one of the following:  

 
when(context-selector-specification: [directive-variant]) 
default(directive-variant)  

SVG-Viewer needed.

SVG-Viewer needed.

The syntax of a metadirective takes one of the following forms:  

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

or  

 
!$omp begin metadirective [clause[ [,] clause] ... ] 
    stmt(s) 
!$omp end metadirective  

where clause is one of the following:  

 
when(context-selector-specification: [directive-variant]) 
default(directive-variant)  

SVG-Viewer needed.

In the when clause, context-selector-specification specifies a context selector (see Section 2.3.2).

In the when and default clauses, directive-variant has the following form and specifies a directive variant that specifies an OpenMP directive with clauses that apply to it.  

 
 directive-name [clause[ [,] clause] ... ]  

DescriptionA metadirective is a directive that behaves as if it is either ignored or replaced by the directive variant specified in one of the when or default clauses that appears on the metadirective. The OpenMP context for a given metadirective is defined according to Section 2.3.1. For each when clause that appears on a metadirective, the specified directive variant, if present, is a candidate to replace the metadirective if the corresponding context selector is compatible with the OpenMP context according to the matching rules defined in Section 2.3.3. If only one compatible context selector specified by a when clause has the highest score and it specifies a directive variant, the directive variant will replace the metadirective. If more than one when clause specifies a compatible context selector that has the highest computed score and at least one specifies a directive variant, the first directive variant specified in the lexical order of those when clauses will replace the metadirective.

If no context selector from any when clause is compatible with the OpenMP context and a default clause is present, the directive variant specified in the default clause will replace the metadirective.

If a directive variant is not selected to replace a metadirective according to the above rules, the metadirective has no effect on the execution of the program.

The begin metadirective directive behaves identically to the metadirective directive, except that the directive syntax for the specified directive variants must accept a paired end directive. For any directive variant that is selected to replace the begin metadirective directive, the end metadirective directive will be implicitly replaced by its paired end directive to demarcate the statements that are affected by or are associated with the directive variant. If no directive variant is selected to replace the begin metadirective directive, its paired end metadirective directive is ignored.

RestrictionsRestrictions to metadirectives are as follows: