HOME
| OPENMP API Specification: Version 5.0 November 2018

2.8.2  single Construct

SummaryThe single construct specifies that the associated structured block is executed by only one of the threads in the team (not necessarily the master thread), in the context of its implicit task. The other threads in the team, which do not execute the block, wait at an implicit barrier at the end of the single construct unless a nowait clause is specified.

Syntax

SVG-Viewer needed.

The syntax of the single construct is as follows:  

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

where clause is one of the following:  

 
private(list) 
firstprivate(list) 
copyprivate(list) 
allocate([allocator :] list) 
nowait  

SVG-Viewer needed.

SVG-Viewer needed.

The syntax of the single construct is as follows:  

 
!$omp single [clause[ [,] clause] ... ] 
   structured-block 
!$omp end single [end_clause[ [,] end_clause] ... ]  

where clause is one of the following:  

 
private(list) 
firstprivate(list) 
allocate([allocator :] list)  

and end_clause is one of the following:  

 
copyprivate(list) 
nowait  

SVG-Viewer needed.

BindingThe binding thread set for a single region is the current team. A single region binds to the innermost enclosing parallel region. Only the threads of the team that executes the binding parallel region participate in the execution of the structured block and the implied barrier of the single region if the barrier is not eliminated by a nowait clause.

DescriptionOnly one of the encountering threads will execute the structured block associated with the single construct. The method of choosing a thread to execute the structured block each time the team encounters the construct is implementation defined. There is an implicit barrier at the end of the single construct unless a nowait clause is specified.

Execution Model Events The single-begin event occurs after an implicit task encounters a single construct but before the task starts to execute the structured block of the single region.

The single-end event occurs after an implicit task finishes execution of a single region but before it resumes execution of the enclosing region.

Tool Callbacks A thread dispatches a registered ompt_callback_work callback with ompt_scope_begin as its endpoint argument for each occurrence of a single-begin event in that thread. Similarly, a thread dispatches a registered ompt_callback_work callback with ompt_scope_begin as its endpoint argument for each occurrence of a single-end event in that thread. For each of these callbacks, the wstype argument is ompt_work_single_executor if the thread executes the structured block associated with the single region; otherwise, the wstype argument is ompt_work_single_other. The callback has type signature ompt_callback_work_t.

RestrictionsRestrictions to the single construct are as follows:

Cross References

SVG-Viewer needed.