Hints about the expected dynamic behavior or suggested implementation can be provided by the programmer to
locks (by using the omp_init_lock_with_hint or omp_init_nest_lock_with_hint
functions to initialize the lock), and to atomic and critical directives by using the hint clause. The
effect of a hint does not change the semantics of the associated construct; if ignoring the hint changes the
program semantics, the result is unspecified.
The C/C++ header file (omp.h) and the Fortran include file (omp_lib.h) and/or Fortran module file
(omp_lib) define the valid hint constants. The valid constants must include the following, which can be
extended with implementation-defined values:
The hints can be combined by using the + or | operators in C/C++ or the + operator in Fortran.
Combining omp_sync_hint_none with any other hint is equivalent to specifying the other
hint.
The intended meaning of each hint is:
omp_sync_hint_uncontended:
low
contention
is
expected
in
this
operation,
that
is,
few
threads
are
expected
to
perform
the
operation
simultaneously
in
a
manner
that
requires
synchronization;
omp_sync_hint_contended:
high
contention
is
expected
in
this
operation,
that
is,
many
threads
are
expected
to
perform
the
operation
simultaneously
in
a
manner
that
requires
synchronization;
omp_sync_hint_speculative:
the
programmer
suggests
that
the
operation
should
be
implemented
using
speculative
techniques
such
as
transactional
memory;
and
omp_sync_hint_nonspeculative:
the
programmer
suggests
that
the
operation
should
not
be
implemented
using
speculative
techniques
such
as
transactional
memory.
Note – Future OpenMP specifications may add additional hints to the omp_sync_hint_t type and the
omp_sync_hint_kind kind. Implementers are advised to add implementation-defined hints starting from the
most significant bit of the omp_sync_hint_t type and omp_sync_hint_kind kind and to include the name
of the implementation in the name of the added hint to avoid name conflicts with other OpenMP implementations.
The omp_sync_hint_t and omp_lock_hint_t enumeration types and the equivalent types in
Fortran are synonyms for each other. The type omp_lock_hint_t has been deprecated.
Restrictions
Restrictions to the synchronization hints are as follows:
The
hints
omp_sync_hint_uncontended
and
omp_sync_hint_contended
cannot
be
combined.
The
hints
omp_sync_hint_nonspeculative
and
omp_sync_hint_speculative
cannot
be
combined.
The restrictions for combining multiple values of omp_sync_hint apply equally to the corresponding
values of omp_lock_hint, and expressions that mix the two types.