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.
!$omp single [clause[ [,] clause] ... ]
!$omp end single [end_clause[ [,] end_clause] ... ]
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:
∙ A throw executed inside a single region must cause execution to resume within the same single region, and the same thread that threw the exception must catch it.