HOME
| OPENMP API Specification: Version 5.1 November 2020

2.19.12  Synchronization Hints

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:

SVG-Viewer needed.

 

 
typedef enum omp_sync_hint_t { 
  omp_sync_hint_none = 0x0, 
  omp_lock_hint_none = omp_sync_hint_none, 
  omp_sync_hint_uncontended = 0x1, 
  omp_lock_hint_uncontended = omp_sync_hint_uncontended, 
  omp_sync_hint_contended = 0x2, 
  omp_lock_hint_contended = omp_sync_hint_contended, 
  omp_sync_hint_nonspeculative = 0x4, 
  omp_lock_hint_nonspeculative = omp_sync_hint_nonspeculative, 
  omp_sync_hint_speculative = 0x8, 
  omp_lock_hint_speculative = omp_sync_hint_speculative 
} omp_sync_hint_t; 
 
typedef omp_sync_hint_t omp_lock_hint_t;  

SVG-Viewer needed.

SVG-Viewer needed.

 

 
integer, parameter :: omp_lock_hint_kind = omp_sync_hint_kind 
 
integer (kind=omp_sync_hint_kind), & 
  parameter :: omp_sync_hint_none = & 
                   int(Z’0’, kind=omp_sync_hint_kind) 
integer (kind=omp_lock_hint_kind), & 
  parameter :: omp_lock_hint_none = omp_sync_hint_none 
integer (kind=omp_sync_hint_kind), & 
  parameter :: omp_sync_hint_uncontended = & 
                   int(Z’1’, kind=omp_sync_hint_kind) 
integer (kind=omp_lock_hint_kind), & 
  parameter :: omp_lock_hint_uncontended = & 
                   omp_sync_hint_uncontended 
integer (kind=omp_sync_hint_kind), & 
  parameter :: omp_sync_hint_contended = & 
                   int(Z’2’, kind=omp_sync_hint_kind) 
integer (kind=omp_lock_hint_kind), & 
  parameter :: omp_lock_hint_contended = & 
                   omp_sync_hint_contended 
integer (kind=omp_sync_hint_kind), & 
  parameter :: omp_sync_hint_nonspeculative = & 
                   int(Z’4’, kind=omp_sync_hint_kind) 
integer (kind=omp_lock_hint_kind), & 
  parameter :: omp_lock_hint_nonspeculative = & 
                   omp_sync_hint_nonspeculative 
integer (kind=omp_sync_hint_kind), & 
  parameter :: omp_sync_hint_speculative = & 
                   int(Z’8’, kind=omp_sync_hint_kind) 
integer (kind=omp_lock_hint_kind), & 
  parameter :: omp_lock_hint_speculative = & 
                   omp_sync_hint_speculative  

SVG-Viewer needed.

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:

SVG-Viewer needed.

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.

SVG-Viewer needed.

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 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.

Cross References