Skip to content

Commit

Permalink
[OpenMP] Synchronization hint constants added to headers
Browse files Browse the repository at this point in the history
ident flags reserved for atomic hints.
This patch adds omp_sync_hint_t to omp.h and omp_sync_hint_kind to omp_lib.h.
For better maintainability the list of macros for ident flags was replaced with
a enum. The new KMP_IDENT_ATOMIC_HINT_MASK was added to the enum to
support possible future atomic hints.

Also fix omp_lib.h.var to be under 72 chars again after 5.0 OpenMP Memory commit

Patch by Olga Malysheva

Differential Revision: https://reviews.llvm.org/D51233

llvm-svn: 341693
  • Loading branch information
jpeyton52 committed Sep 7, 2018
1 parent 0665094 commit 2ff302d
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 56 deletions.
24 changes: 16 additions & 8 deletions openmp/runtime/src/include/50/omp.h.var
Expand Up @@ -92,17 +92,25 @@
extern void __KAI_KMPC_CONVENTION omp_destroy_nest_lock (omp_nest_lock_t *);
extern int __KAI_KMPC_CONVENTION omp_test_nest_lock (omp_nest_lock_t *);

/* lock hint type for dynamic user lock */
typedef enum omp_lock_hint_t {
omp_lock_hint_none = 0,
omp_lock_hint_uncontended = 1,
omp_lock_hint_contended = (1<<1 ),
omp_lock_hint_nonspeculative = (1<<2 ),
omp_lock_hint_speculative = (1<<3 ),
/* OpenMP 5.0 Synchronization hints*/
typedef enum omp_sync_hint_t {
omp_sync_hint_none = 0,
omp_lock_hint_none = omp_sync_hint_none,
omp_sync_hint_uncontended = 1,
omp_lock_hint_uncontended = omp_sync_hint_uncontended,
omp_sync_hint_contended = (1<<1),
omp_lock_hint_contended = omp_sync_hint_contended,
omp_sync_hint_nonspeculative = (1<<2),
omp_lock_hint_nonspeculative = omp_sync_hint_nonspeculative,
omp_sync_hint_speculative = (1<<3),
omp_lock_hint_speculative = omp_sync_hint_speculative,
kmp_lock_hint_hle = (1<<16),
kmp_lock_hint_rtm = (1<<17),
kmp_lock_hint_adaptive = (1<<18)
} omp_lock_hint_t;
} omp_sync_hint_t;

/* lock hint type for dynamic user lock */
typedef omp_sync_hint_t omp_lock_hint_t;

/* hinted lock initializers */
extern void __KAI_KMPC_CONVENTION omp_init_lock_with_hint(omp_lock_t *, omp_lock_hint_t);
Expand Down
24 changes: 15 additions & 9 deletions openmp/runtime/src/include/50/omp_lib.f90.var
Expand Up @@ -27,7 +27,8 @@
integer, parameter :: kmp_size_t_kind = c_size_t
integer, parameter :: kmp_affinity_mask_kind = c_intptr_t
integer, parameter :: kmp_cancel_kind = omp_integer_kind
integer, parameter :: omp_lock_hint_kind = omp_integer_kind
integer, parameter :: omp_sync_hint_kind = omp_integer_kind
integer, parameter :: omp_lock_hint_kind = omp_sync_hint_kind
integer, parameter :: omp_control_tool_kind = omp_integer_kind
integer, parameter :: omp_control_tool_result_kind = omp_integer_kind
integer, parameter :: omp_allocator_kind = c_intptr_t
Expand Down Expand Up @@ -62,14 +63,19 @@
integer (kind=kmp_cancel_kind), parameter :: kmp_cancel_sections = 3
integer (kind=kmp_cancel_kind), parameter :: kmp_cancel_taskgroup = 4

integer (kind=omp_lock_hint_kind), parameter :: omp_lock_hint_none = 0
integer (kind=omp_lock_hint_kind), parameter :: omp_lock_hint_uncontended = 1
integer (kind=omp_lock_hint_kind), parameter :: omp_lock_hint_contended = 2
integer (kind=omp_lock_hint_kind), parameter :: omp_lock_hint_nonspeculative = 4
integer (kind=omp_lock_hint_kind), parameter :: omp_lock_hint_speculative = 8
integer (kind=omp_lock_hint_kind), parameter :: kmp_lock_hint_hle = 65536
integer (kind=omp_lock_hint_kind), parameter :: kmp_lock_hint_rtm = 131072
integer (kind=omp_lock_hint_kind), parameter :: kmp_lock_hint_adaptive = 262144
integer (kind=omp_sync_hint_kind), parameter :: omp_sync_hint_none = 0
integer (kind=omp_sync_hint_kind), parameter :: omp_sync_hint_uncontended = 1
integer (kind=omp_sync_hint_kind), parameter :: omp_sync_hint_contended = 2
integer (kind=omp_sync_hint_kind), parameter :: omp_sync_hint_nonspeculative = 4
integer (kind=omp_sync_hint_kind), parameter :: omp_sync_hint_speculative = 8
integer (kind=omp_lock_hint_kind), parameter :: omp_lock_hint_none = omp_sync_hint_none
integer (kind=omp_lock_hint_kind), parameter :: omp_lock_hint_uncontended = omp_sync_hint_uncontended
integer (kind=omp_lock_hint_kind), parameter :: omp_lock_hint_contended = omp_sync_hint_contended
integer (kind=omp_lock_hint_kind), parameter :: omp_lock_hint_nonspeculative = omp_sync_hint_nonspeculative
integer (kind=omp_lock_hint_kind), parameter :: omp_lock_hint_speculative = omp_sync_hint_speculative
integer (kind=omp_lock_hint_kind), parameter :: kmp_lock_hint_hle = 65536
integer (kind=omp_lock_hint_kind), parameter :: kmp_lock_hint_rtm = 131072
integer (kind=omp_lock_hint_kind), parameter :: kmp_lock_hint_adaptive = 262144

integer (kind=omp_control_tool_kind), parameter :: omp_control_tool_start = 1
integer (kind=omp_control_tool_kind), parameter :: omp_control_tool_pause = 2
Expand Down
49 changes: 35 additions & 14 deletions openmp/runtime/src/include/50/omp_lib.h.var
Expand Up @@ -31,8 +31,10 @@
parameter(kmp_size_t_kind=int_ptr_kind())
integer kmp_affinity_mask_kind
parameter(kmp_affinity_mask_kind=int_ptr_kind())
integer omp_sync_hint_kind
parameter(omp_sync_hint_kind=omp_integer_kind)
integer omp_lock_hint_kind
parameter(omp_lock_hint_kind=omp_integer_kind)
parameter(omp_lock_hint_kind=omp_sync_hint_kind)
integer omp_control_tool_kind
parameter(omp_control_tool_kind=omp_integer_kind)
integer omp_control_tool_result_kind
Expand Down Expand Up @@ -71,16 +73,26 @@
integer(kind=omp_proc_bind_kind)omp_proc_bind_spread
parameter(omp_proc_bind_spread=4)

integer(kind=omp_sync_hint_kind)omp_sync_hint_none
parameter(omp_sync_hint_none=0)
integer(kind=omp_sync_hint_kind)omp_sync_hint_uncontended
parameter(omp_sync_hint_uncontended=1)
integer(kind=omp_sync_hint_kind)omp_sync_hint_contended
parameter(omp_sync_hint_contended=2)
integer(kind=omp_sync_hint_kind)omp_sync_hint_nonspeculative
parameter(omp_sync_hint_nonspeculative=4)
integer(kind=omp_sync_hint_kind)omp_sync_hint_speculative
parameter(omp_sync_hint_speculative=8)
integer(kind=omp_lock_hint_kind)omp_lock_hint_none
parameter(omp_lock_hint_none=0)
parameter(omp_lock_hint_none=omp_sync_hint_none)
integer(kind=omp_lock_hint_kind)omp_lock_hint_uncontended
parameter(omp_lock_hint_uncontended=1)
parameter(omp_lock_hint_uncontended=omp_sync_hint_uncontended)
integer(kind=omp_lock_hint_kind)omp_lock_hint_contended
parameter(omp_lock_hint_contended=2)
parameter(omp_lock_hint_contended=omp_sync_hint_contended)
integer(kind=omp_lock_hint_kind)omp_lock_hint_nonspeculative
parameter(omp_lock_hint_nonspeculative=4)
integer(kind=omp_lock_hint_kind)omp_lock_hint_speculative
parameter(omp_lock_hint_speculative=8)
parameter(omp_lock_hint_speculative=omp_sync_hint_speculative)
integer(kind=omp_lock_hint_kind)kmp_lock_hint_hle
parameter(kmp_lock_hint_hle=65536)
integer(kind=omp_lock_hint_kind)kmp_lock_hint_rtm
Expand All @@ -106,15 +118,24 @@
integer(kind=omp_control_tool_result_kind)omp_control_tool_ignored
parameter(omp_control_tool_ignored=1)

integer (kind=omp_allocator_kind), parameter :: omp_null_allocator = 0
integer (kind=omp_allocator_kind), parameter :: omp_default_mem_alloc = 1
integer (kind=omp_allocator_kind), parameter :: omp_large_cap_mem_alloc = 2
integer (kind=omp_allocator_kind), parameter :: omp_const_mem_alloc = 3
integer (kind=omp_allocator_kind), parameter :: omp_high_bw_mem_alloc = 4
integer (kind=omp_allocator_kind), parameter :: omp_low_lat_mem_alloc = 5
integer (kind=omp_allocator_kind), parameter :: omp_cgroup_mem_alloc = 6
integer (kind=omp_allocator_kind), parameter :: omp_pteam_mem_alloc = 7
integer (kind=omp_allocator_kind), parameter :: omp_thread_mem_alloc = 8
integer(kind=omp_allocator_kind)omp_null_allocator
parameter(omp_null_allocator=0)
integer(kind=omp_allocator_kind)omp_default_mem_alloc
parameter(omp_default_mem_alloc=1)
integer(kind=omp_allocator_kind)omp_large_cap_mem_alloc
parameter(omp_large_cap_mem_alloc=2)
integer(kind=omp_allocator_kind)omp_const_mem_alloc
parameter(omp_const_mem_alloc=3)
integer(kind=omp_allocator_kind)omp_high_bw_mem_alloc
parameter(omp_high_bw_mem_alloc=4)
integer(kind=omp_allocator_kind)omp_low_lat_mem_alloc
parameter(omp_low_lat_mem_alloc=5)
integer(kind=omp_allocator_kind)omp_cgroup_mem_alloc
parameter(omp_cgroup_mem_alloc=6)
integer(kind=omp_allocator_kind)omp_pteam_mem_alloc
parameter(omp_pteam_mem_alloc=7)
integer(kind=omp_allocator_kind)omp_thread_mem_alloc
parameter(omp_thread_mem_alloc=8)

interface

Expand Down
58 changes: 33 additions & 25 deletions openmp/runtime/src/kmp.h
Expand Up @@ -172,34 +172,42 @@ class kmp_stats_list;
@{
*/

// FIXME DOXYGEN... need to group these flags somehow (Making them an anonymous
// enum would do it...)
/*!
Values for bit flags used in the ident_t to describe the fields.
*/
/*! Use trampoline for internal microtasks */
#define KMP_IDENT_IMB 0x01
/*! Use c-style ident structure */
#define KMP_IDENT_KMPC 0x02
/* 0x04 is no longer used */
/*! Entry point generated by auto-parallelization */
#define KMP_IDENT_AUTOPAR 0x08
/*! Compiler generates atomic reduction option for kmpc_reduce* */
#define KMP_IDENT_ATOMIC_REDUCE 0x10
/*! To mark a 'barrier' directive in user code */
#define KMP_IDENT_BARRIER_EXPL 0x20
/*! To Mark implicit barriers. */
#define KMP_IDENT_BARRIER_IMPL 0x0040
#define KMP_IDENT_BARRIER_IMPL_MASK 0x01C0
#define KMP_IDENT_BARRIER_IMPL_FOR 0x0040
#define KMP_IDENT_BARRIER_IMPL_SECTIONS 0x00C0

#define KMP_IDENT_BARRIER_IMPL_SINGLE 0x0140
#define KMP_IDENT_BARRIER_IMPL_WORKSHARE 0x01C0

#define KMP_IDENT_WORK_LOOP 0x200 // static loop
#define KMP_IDENT_WORK_SECTIONS 0x400 // sections
#define KMP_IDENT_WORK_DISTRIBUTE 0x800 // distribute
enum {
/*! Use trampoline for internal microtasks */
KMP_IDENT_IMB = 0x01,
/*! Use c-style ident structure */
KMP_IDENT_KMPC = 0x02,
/* 0x04 is no longer used */
/*! Entry point generated by auto-parallelization */
KMP_IDENT_AUTOPAR = 0x08,
/*! Compiler generates atomic reduction option for kmpc_reduce* */
KMP_IDENT_ATOMIC_REDUCE = 0x10,
/*! To mark a 'barrier' directive in user code */
KMP_IDENT_BARRIER_EXPL = 0x20,
/*! To Mark implicit barriers. */
KMP_IDENT_BARRIER_IMPL = 0x0040,
KMP_IDENT_BARRIER_IMPL_MASK = 0x01C0,
KMP_IDENT_BARRIER_IMPL_FOR = 0x0040,
KMP_IDENT_BARRIER_IMPL_SECTIONS = 0x00C0,

KMP_IDENT_BARRIER_IMPL_SINGLE = 0x0140,
KMP_IDENT_BARRIER_IMPL_WORKSHARE = 0x01C0,

/*! To mark a static loop in OMPT callbacks */
KMP_IDENT_WORK_LOOP = 0x200,
/*! To mark a sections directive in OMPT callbacks */
KMP_IDENT_WORK_SECTIONS = 0x400,
/*! To mark a distirbute construct in OMPT callbacks */
KMP_IDENT_WORK_DISTRIBUTE = 0x800,
/*! Atomic hint; bottom four bits as omp_sync_hint_t. Top four reserved and
not currently used. If one day we need more bits, then we can use
an invalid combination of hints to mean that another, larger field
should be used in a different flag. */
KMP_IDENT_ATOMIC_HINT_MASK = 0xFF0000,
};

/*!
* The ident structure that describes a source location.
Expand Down

0 comments on commit 2ff302d

Please sign in to comment.