HOME
| OPENMP API Specification: Version 5.1 November 2020

2.8  masked Construct

Summary The masked construct specifies a structured block that is executed by a subset of the threads of the current team.

Syntax

SVG-Viewer needed.

The syntax of the masked construct is as follows:  

 
#pragma omp masked [ filter(integer-expression)  ] new-line 
   structured-block  

SVG-Viewer needed.

SVG-Viewer needed.

The syntax of the masked construct is as follows:  

 
!$omp masked [ filter(scalar-integer-expression)  ] 
   loosely-structured-block 
!$omp end masked  

or  

 
!$omp masked [ filter(scalar-integer-expression)  ] 
   strictly-structured-block 
[!$omp end masked]  

SVG-Viewer needed.

The master construct, which has been deprecated, has the same syntax as the masked construct other than the use of master as the directive name and that the filter clause may not be specified for the master construct.

Binding The binding thread set for a masked region is the current team. A masked region binds to the innermost enclosing parallel region.

Description Only the threads of the team that executes the binding parallel region that the filter clause selects participate in the execution of the structured block of a masked region. Other threads in the team do not execute the associated structured block. No implied barrier occurs either on entry to, or exit from, the masked construct.

If a filter clause is present on the construct and the parameter specifies the thread number of the current thread in the current team then the current thread executes the associated structured block. If the filter clause is not present, the construct behaves as if the parameter is a constant integer expression that evaluates to zero, so that only the primary thread executes the associated structured block. The use of a variable in a filter clause expression causes an implicit reference to the variable in all enclosing constructs. The result of evaluating the parameter of the filter clause may vary across threads.

If more than one thread in the team executes the structured block of a masked region, the structured block must include any synchronization required to ensure that data races do not occur.

The master construct, which has been deprecated, has identical semantics to the masked construct with no filter clause present.

Execution Model Events The masked-begin event occurs in any thread of a team that executes the masked region on entry to the region.

The masked-end event occurs in any thread of a team that executes the masked region on exit from the region.

Tool Callbacks A thread dispatches a registered ompt_callback_masked callback with ompt_scope_begin as its endpoint argument for each occurrence of a masked-begin event in that thread. Similarly, a thread dispatches a registered ompt_callback_masked callback with ompt_scope_end as its endpoint argument for each occurrence of a masked-end event in that thread. These callbacks occur in the context of the task executed by the current thread and have the type signature ompt_callback_masked_t.

Restrictions Restrictions to the masked construct are as follows:

SVG-Viewer needed.

SVG-Viewer needed.

Cross References