[Openmp-commits] [openmp] r341693 - [OpenMP] Synchronization hint constants added to headers

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Fri Sep 7 11:45:13 PDT 2018


Author: jlpeyton
Date: Fri Sep  7 11:45:13 2018
New Revision: 341693

URL: http://llvm.org/viewvc/llvm-project?rev=341693&view=rev
Log:
[OpenMP] Synchronization hint constants added to headers

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

Modified:
    openmp/trunk/runtime/src/include/50/omp.h.var
    openmp/trunk/runtime/src/include/50/omp_lib.f90.var
    openmp/trunk/runtime/src/include/50/omp_lib.h.var
    openmp/trunk/runtime/src/kmp.h

Modified: openmp/trunk/runtime/src/include/50/omp.h.var
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/include/50/omp.h.var?rev=341693&r1=341692&r2=341693&view=diff
==============================================================================
--- openmp/trunk/runtime/src/include/50/omp.h.var (original)
+++ openmp/trunk/runtime/src/include/50/omp.h.var Fri Sep  7 11:45:13 2018
@@ -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);

Modified: openmp/trunk/runtime/src/include/50/omp_lib.f90.var
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/include/50/omp_lib.f90.var?rev=341693&r1=341692&r2=341693&view=diff
==============================================================================
--- openmp/trunk/runtime/src/include/50/omp_lib.f90.var (original)
+++ openmp/trunk/runtime/src/include/50/omp_lib.f90.var Fri Sep  7 11:45:13 2018
@@ -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
@@ -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

Modified: openmp/trunk/runtime/src/include/50/omp_lib.h.var
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/include/50/omp_lib.h.var?rev=341693&r1=341692&r2=341693&view=diff
==============================================================================
--- openmp/trunk/runtime/src/include/50/omp_lib.h.var (original)
+++ openmp/trunk/runtime/src/include/50/omp_lib.h.var Fri Sep  7 11:45:13 2018
@@ -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
@@ -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
@@ -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
 

Modified: openmp/trunk/runtime/src/kmp.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp.h?rev=341693&r1=341692&r2=341693&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp.h (original)
+++ openmp/trunk/runtime/src/kmp.h Fri Sep  7 11:45:13 2018
@@ -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
+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,
 
-#define KMP_IDENT_BARRIER_IMPL_SINGLE 0x0140
-#define KMP_IDENT_BARRIER_IMPL_WORKSHARE 0x01C0
+  KMP_IDENT_BARRIER_IMPL_SINGLE = 0x0140,
+  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
+  /*! 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.




More information about the Openmp-commits mailing list