SummaryThe 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:
BindingThe 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 blocks
and the implied barrier of the sections region if the barrier is not eliminated by a nowait
clause.
DescriptionEach structured block in the sections construct is preceded by a section directive except
possibly the first block, for which a preceding section directive is optional.
The method of scheduling the structured blocks among the threads in the team is implementation
defined.
There is an implicit barrier at the end of a sections construct unless a nowait clause is
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 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 in the sections
construct for each of those structured blocks 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.
RestrictionsRestrictions 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.
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.