aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/kmp.h
diff options
context:
space:
mode:
authorJonathan Peyton <jonathan.l.peyton@intel.com>2018-08-09 22:04:30 +0000
committerJonathan Peyton <jonathan.l.peyton@intel.com>2018-08-09 22:04:30 +0000
commit2b9968a2f9b9ef9887769168407b4687e861e3b6 (patch)
tree177d33520d8e99a8a7f07b970bf13b56f9684ee1 /runtime/src/kmp.h
parentd97a5dfc16407bf9b934445dc5f1a223e3208436 (diff)
[OpenMP] Cleanup code
This patch cleans up unused functions, variables, sign compare issues, and addresses some -Warning flags which are now enabled including -Wcast-qual. Not all the warning flags in LibompHandleFlags.cmake are enabled, but some are with this patch. Some __kmp_gtid_from_* macros in kmp.h are switched to static inline functions which allows us to remove the awkward definition of KMP_DEBUG_ASSERT() and KMP_ASSERT() macros which used the comma operator. This had to be done for the innumerable -Wunused-value warnings related to KMP_DEBUG_ASSERT() Differential Revision: https://reviews.llvm.org/D49105 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@339393 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtime/src/kmp.h')
-rw-r--r--runtime/src/kmp.h87
1 files changed, 49 insertions, 38 deletions
diff --git a/runtime/src/kmp.h b/runtime/src/kmp.h
index 29d09e6..c6afb5e 100644
--- a/runtime/src/kmp.h
+++ b/runtime/src/kmp.h
@@ -586,7 +586,7 @@ extern size_t __kmp_affin_mask_size;
#define KMP_AFFINITY_DISABLE() (__kmp_affin_mask_size = 0)
#define KMP_AFFINITY_ENABLE(mask_size) (__kmp_affin_mask_size = mask_size)
#define KMP_CPU_SET_ITERATE(i, mask) \
- for (i = (mask)->begin(); i != (mask)->end(); i = (mask)->next(i))
+ for (i = (mask)->begin(); (int)i != (mask)->end(); i = (mask)->next(i))
#define KMP_CPU_SET(i, mask) (mask)->set(i)
#define KMP_CPU_ISSET(i, mask) (mask)->is_set(i)
#define KMP_CPU_CLR(i, mask) (mask)->clear(i)
@@ -830,36 +830,6 @@ extern int __kmp_hws_abs_flag; // absolute or per-item number requested
#define KMP_GTID_UNKNOWN (-5) /* Is not known */
#define KMP_GTID_MIN (-6) /* Minimal gtid for low bound check in DEBUG */
-#define __kmp_get_gtid() __kmp_get_global_thread_id()
-#define __kmp_entry_gtid() __kmp_get_global_thread_id_reg()
-
-#define __kmp_tid_from_gtid(gtid) \
- (KMP_DEBUG_ASSERT((gtid) >= 0), __kmp_threads[(gtid)]->th.th_info.ds.ds_tid)
-
-#define __kmp_get_tid() (__kmp_tid_from_gtid(__kmp_get_gtid()))
-#define __kmp_gtid_from_tid(tid, team) \
- (KMP_DEBUG_ASSERT((tid) >= 0 && (team) != NULL), \
- team->t.t_threads[(tid)]->th.th_info.ds.ds_gtid)
-
-#define __kmp_get_team() (__kmp_threads[(__kmp_get_gtid())]->th.th_team)
-#define __kmp_team_from_gtid(gtid) \
- (KMP_DEBUG_ASSERT((gtid) >= 0), __kmp_threads[(gtid)]->th.th_team)
-
-#define __kmp_thread_from_gtid(gtid) \
- (KMP_DEBUG_ASSERT((gtid) >= 0), __kmp_threads[(gtid)])
-#define __kmp_get_thread() (__kmp_thread_from_gtid(__kmp_get_gtid()))
-
-// Returns current thread (pointer to kmp_info_t). In contrast to
-// __kmp_get_thread(), it works with registered and not-yet-registered threads.
-#define __kmp_gtid_from_thread(thr) \
- (KMP_DEBUG_ASSERT((thr) != NULL), (thr)->th.th_info.ds.ds_gtid)
-
-// AT: Which way is correct?
-// AT: 1. nproc = __kmp_threads[ ( gtid ) ] -> th.th_team -> t.t_nproc;
-// AT: 2. nproc = __kmp_threads[ ( gtid ) ] -> th.th_team_nproc;
-#define __kmp_get_team_num_threads(gtid) \
- (__kmp_threads[(gtid)]->th.th_team->t.t_nproc)
-
/* ------------------------------------------------------------------------ */
#define KMP_UINT64_MAX \
@@ -1013,11 +983,6 @@ extern kmp_uint64 __kmp_now_nsec();
#define KMP_MASTER_GTID(gtid) (__kmp_tid_from_gtid((gtid)) == 0)
#define KMP_WORKER_GTID(gtid) (__kmp_tid_from_gtid((gtid)) != 0)
-#define KMP_UBER_GTID(gtid) \
- (KMP_DEBUG_ASSERT((gtid) >= KMP_GTID_MIN), \
- KMP_DEBUG_ASSERT((gtid) < __kmp_threads_capacity), \
- (gtid) >= 0 && __kmp_root[(gtid)] && __kmp_threads[(gtid)] && \
- (__kmp_threads[(gtid)] == __kmp_root[(gtid)]->r.r_uber_thread))
#define KMP_INITIAL_GTID(gtid) ((gtid) == 0)
#ifndef TRUE
@@ -1065,9 +1030,9 @@ extern void __kmp_x86_pause(void);
// regression after removal of extra PAUSE from KMP_YIELD_SPIN(). Changing
// the delay from 100 to 300 showed even better performance than double PAUSE
// on Spec OMP2001 and LCPC tasking tests, no regressions on EPCC.
-static void __kmp_x86_pause(void) { _mm_delay_32(300); }
+static inline void __kmp_x86_pause(void) { _mm_delay_32(300); }
#else
-static void __kmp_x86_pause(void) { _mm_pause(); }
+static inline void __kmp_x86_pause(void) { _mm_pause(); }
#endif
#define KMP_CPU_PAUSE() __kmp_x86_pause()
#elif KMP_ARCH_PPC64
@@ -3050,6 +3015,52 @@ extern kmp_root_t **__kmp_root; /* root of thread hierarchy */
/* end data protected by fork/join lock */
/* ------------------------------------------------------------------------- */
+#define __kmp_get_gtid() __kmp_get_global_thread_id()
+#define __kmp_entry_gtid() __kmp_get_global_thread_id_reg()
+#define __kmp_get_tid() (__kmp_tid_from_gtid(__kmp_get_gtid()))
+#define __kmp_get_team() (__kmp_threads[(__kmp_get_gtid())]->th.th_team)
+#define __kmp_get_thread() (__kmp_thread_from_gtid(__kmp_get_gtid()))
+
+// AT: Which way is correct?
+// AT: 1. nproc = __kmp_threads[ ( gtid ) ] -> th.th_team -> t.t_nproc;
+// AT: 2. nproc = __kmp_threads[ ( gtid ) ] -> th.th_team_nproc;
+#define __kmp_get_team_num_threads(gtid) \
+ (__kmp_threads[(gtid)]->th.th_team->t.t_nproc)
+
+static inline bool KMP_UBER_GTID(int gtid) {
+ KMP_DEBUG_ASSERT(gtid >= KMP_GTID_MIN);
+ KMP_DEBUG_ASSERT(gtid < __kmp_threads_capacity);
+ return (gtid >= 0 && __kmp_root[gtid] && __kmp_threads[gtid] &&
+ __kmp_threads[gtid] == __kmp_root[gtid]->r.r_uber_thread);
+}
+
+static inline int __kmp_tid_from_gtid(int gtid) {
+ KMP_DEBUG_ASSERT(gtid >= 0);
+ return __kmp_threads[gtid]->th.th_info.ds.ds_tid;
+}
+
+static inline int __kmp_gtid_from_tid(int tid, const kmp_team_t *team) {
+ KMP_DEBUG_ASSERT(tid >= 0 && team);
+ return team->t.t_threads[tid]->th.th_info.ds.ds_gtid;
+}
+
+static inline int __kmp_gtid_from_thread(const kmp_info_t *thr) {
+ KMP_DEBUG_ASSERT(thr);
+ return thr->th.th_info.ds.ds_gtid;
+}
+
+static inline kmp_info_t *__kmp_thread_from_gtid(int gtid) {
+ KMP_DEBUG_ASSERT(gtid >= 0);
+ return __kmp_threads[gtid];
+}
+
+static inline kmp_team_t *__kmp_team_from_gtid(int gtid) {
+ KMP_DEBUG_ASSERT(gtid >= 0);
+ return __kmp_threads[gtid]->th.th_team;
+}
+
+/* ------------------------------------------------------------------------- */
+
extern kmp_global_t __kmp_global; /* global status */
extern kmp_info_t __kmp_monitor;