HOME
| OPENMP API Specification: Version 5.1 November 2020

2.10.1  sections Construct

Summary The sections construct is a non-iterative worksharing construct that contains a set of structured blocks that are to be distributed among and executed by the threads in a team. Each structured block is executed once by one of the threads in the team in the context of its implicit task.

Syntax

SVG-Viewer needed.

The syntax of the sections construct is as follows:  

 
#pragma omp sections [clause[ [,] clause] ... ] new-line 
   { 
   [#pragma omp section new-line] 
      structured-block-sequence 
   [#pragma omp section new-line 
      structured-block-sequence] 
   ... 
   }  

where clause is one of the following:  

 
private(list) 
firstprivate(list) 
lastprivate([ lastprivate-modifier:] list) 
reduction([reduction-modifier ,] reduction-identifier : list) 
allocate([allocator :] list) 
nowait  

SVG-Viewer needed.

SVG-Viewer needed.

The syntax of the sections construct is as follows:  

 
!$omp sections [clause[ [,] clause] ... ] 
   [!$omp section] 
      structured-block-sequence 
   [!$omp section 
      structured-block-sequence] 
   ... 
!$omp end sections [nowait]  

where clause is one of the following:  

 
private(list) 
firstprivate(list) 
lastprivate([ lastprivate-modifier:] list) 
reduction([reduction-modifier ,] reduction-identifier : list) 
allocate([allocator :] list)  

SVG-Viewer needed.

Binding The binding thread set for a sections region is the current team. A sections 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 sequences and the implied barrier of the sections region if the barrier is not eliminated by a nowait clause.

Description Each structured block sequence in the sections construct is preceded by a section directive except possibly the first sequence, for which a preceding section directive is optional.

The method of scheduling the structured block sequences among the threads in the team is implementation defined.

An implicit barrier occurs at the end of a sections region if the nowait clause is not specified.

Execution Model Events The section-begin event occurs after an implicit task encounters a sections construct but before the task executes any structured block sequences of the sections region.

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

The section-begin event occurs before an implicit task starts to execute a structured block sequence in the sections construct for each of those structured block sequences that the task executes.

Tool Callbacks A thread dispatches a registered ompt_callback_work callback with ompt_scope_begin as its endpoint argument and ompt_work_sections as its wstype argument for each occurrence of a section-begin event in that thread. Similarly, a thread dispatches a registered ompt_callback_work callback with ompt_scope_end as its endpoint argument and ompt_work_sections as its wstype argument for each occurrence of a sections-end event in that thread. The callbacks occur in the context of the implicit task. The callbacks have type signature ompt_callback_work_t.

A thread dispatches a registered ompt_callback_dispatch callback for each occurrence of a section-begin event in that thread. The callback occurs in the context of the implicit task. The callback has type signature ompt_callback_dispatch_t.

Restrictions Restrictions to the sections construct are as follows:

Cross References