where hint-expression is a constant expression that evaluates to a scalar value with kind
omp_sync_hint_kind and a value that is a valid synchronization hint (as described in Section 2.17.12
on page 746).
BindingThe binding thread set for a critical region is all threads in the contention group.
DescriptionThe region that corresponds to a critical construct is executed as if only a single thread at a
time among all threads in the contention group enters the region for execution, without regard to the
team(s) to which the threads belong. An optional name may be used to identify the critical
construct. All critical constructs without a name are considered to have the same unspecified
name.
Identifiers used to identify a critical construct have external linkage and are in a name space that is
separate from the name spaces used by labels, tags, members, and ordinary identifiers.
The names of critical constructs are global entities of the program. If a name conflicts with any other
entity, the behavior of the program is unspecified.
The threads of a contention group execute the critical region as if only one thread of the contention
group executes the critical region at a time. The critical construct enforces these execution
semantics with respect to all critical constructs with the same name in all threads in the contention
group.
If present, the hint clause gives the implementation additional information about the expected runtime
properties of the critical region that can optionally be used to optimize the implementation. The
presence of a hint clause does not affect the isolation guarantees provided by the critical construct. If
no hint clause is specified, the effect is as if hint(omp_sync_hint_none) had been
specified.
Execution Model EventsThe critical-acquiring event occurs in a thread that encounters the
critical construct on entry to the critical region before initiating synchronization for the
region.
The critical-acquired event occurs in a thread that encounters the critical construct after it enters the
region, but before it executes the structured block of the critical region.
The critical-released event occurs in a thread that encounters the critical construct after it completes
any synchronization on exit from the critical region.
Tool CallbacksA thread dispatches a registered ompt_callback_mutex_acquire callback for each
occurrence of a critical-acquiring event in that thread. This callback has the type signature
ompt_callback_mutex_acquire_t.
A thread dispatches a registered ompt_callback_mutex_acquired callback for each occurrence of a
critical-acquired event in that thread. This callback has the type signature ompt_callback_mutex_t.
A thread dispatches a registered ompt_callback_mutex_released callback for each occurrence of a
critical-released event in that thread. This callback has the type signature ompt_callback_mutex_t.
The callbacks occur in the task that encounters the critical construct. The callbacks should receive
ompt_mutex_critical as their kind argument if practical, but a less specific kind is acceptable.
RestrictionsThe following restrictions apply to the critical construct:
Unless
the
effect
is
as
if
hint(omp_sync_hint_none)
was
specified,
the
critical
construct
must
specify
a
name.
If
the
hint
clause
is
specified,
each
of
the
critical
constructs
with
the
same
name
must
have
a
hint
clause
for
which
the
hint-expression
evaluates
to
the
same
value.
A
throw
executed
inside
a
critical
region
must
cause
execution
to
resume
within
the
same
critical
region,
and
the
same
thread
that
threw
the
exception
must
catch
it.
If
a
name
is
specified
on
a
critical
directive,
the
same
name
must
also
be
specified
on
the
endcritical
directive.
If
no
name
appears
on
the
critical
directive,
no
name
can
appear
on
the
endcritical
directive.
Cross References
Synchronization
Hints,
see
Section 2.17.12
on
page 746.
ompt_mutex_critical,
see
Section 4.4.4.16
on
page 1293.
ompt_callback_mutex_acquire_t,
see
Section 4.5.2.14
on
page 1354.
ompt_callback_mutex_t,
see
Section 4.5.2.15
on
page 1357.