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
The syntax of the sections construct is as follows:
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:
Orphaned
section
directives
are
prohibited.
That
is,
the
section
directives
must
appear
within
the
sections
construct
and
must
not
be
encountered
elsewhere
in
the
sections
region.
The
code
enclosed
in
a
sections
construct
must
be
a
structured
block
sequence.
Only
a
single
nowait
clause
can
appear
on
a
sections
directive.
∙ A throw executed inside a sections region must cause execution to resume within the same
section of the sections region, and the same thread that threw the exception must catch
it.