summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/src
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2018-12-15 09:23:39 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2018-12-15 09:23:39 +0000
commit781a0896b0efcb788067a5fa6245d0562aefd1dd (patch)
tree79c6427c4ef5cab72cb43a89dd8f2b322d1ad4aa /openmp/runtime/src
parent7643f42bdd169870df33bfa790d276add0039dcf (diff)
downloadbcm5719-llvm-781a0896b0efcb788067a5fa6245d0562aefd1dd.tar.gz
bcm5719-llvm-781a0896b0efcb788067a5fa6245d0562aefd1dd.zip
[OpenMP] Fixes for LIBOMP_OMP_VERSION=45/40
Summary: I have discovered this because i wanted to experiment with building static libomp (with openmp-4.0 support only) for debugging purposes. There are three kinds of problems here: 1. `__kmp_compare_and_store_acq()` simply does not exist. It was added in D47903 by @jlpeyton. I'm guessing `__kmp_atomic_compare_store_acq()` was meant. 2. In `__kmp_is_ticket_lock_initialized()`, `lck->lk.initialized` is `std::atomic<bool>`, while `lck` is `kmp_ticket_lock_t *`. Naturally, they can't be equality-compared. Either, it should return the value read from `lck->lk.initialized`, or do what `__kmp_is_queuing_lock_initialized()` does, compare the passed pointer with the field in the struct pointed by the pointer. I think the latter is correct-er choice here. 3. Tests were not versioned. They assume that `LIBOMP_OMP_VERSION` is at the latest version. This does not touch LIBOMP_OMP_VERSION=30. That is still broken. Reviewers: jlpeyton, Hahnfeld, AndreyChurbanov Reviewed By: AndreyChurbanov Subscribers: guansong, jfb, openmp-commits, jlpeyton Tags: #openmp Differential Revision: https://reviews.llvm.org/D55496 llvm-svn: 349260
Diffstat (limited to 'openmp/runtime/src')
-rw-r--r--openmp/runtime/src/kmp_lock.cpp2
-rw-r--r--openmp/runtime/src/kmp_lock.h17
-rw-r--r--openmp/runtime/src/kmp_tasking.cpp2
3 files changed, 12 insertions, 9 deletions
diff --git a/openmp/runtime/src/kmp_lock.cpp b/openmp/runtime/src/kmp_lock.cpp
index e045b48c030..c51640bfba3 100644
--- a/openmp/runtime/src/kmp_lock.cpp
+++ b/openmp/runtime/src/kmp_lock.cpp
@@ -3359,7 +3359,7 @@ static void __kmp_init_nested_futex_lock_with_checks(kmp_futex_lock_t *lck) {
#endif
static int __kmp_is_ticket_lock_initialized(kmp_ticket_lock_t *lck) {
- return lck == lck->lk.initialized;
+ return lck == lck->lk.self;
}
static void __kmp_init_ticket_lock_with_checks(kmp_ticket_lock_t *lck) {
diff --git a/openmp/runtime/src/kmp_lock.h b/openmp/runtime/src/kmp_lock.h
index 220236de2f5..6a88d7bc52a 100644
--- a/openmp/runtime/src/kmp_lock.h
+++ b/openmp/runtime/src/kmp_lock.h
@@ -649,7 +649,7 @@ extern int (*__kmp_acquire_user_lock_with_checks_)(kmp_user_lock_p lck,
} \
} \
if (lck->tas.lk.poll != 0 || \
- !__kmp_compare_and_store_acq(&lck->tas.lk.poll, 0, gtid + 1)) { \
+ !__kmp_atomic_compare_store_acq(&lck->tas.lk.poll, 0, gtid + 1)) { \
kmp_uint32 spins; \
KMP_FSYNC_PREPARE(lck); \
KMP_INIT_YIELD(spins); \
@@ -659,8 +659,8 @@ extern int (*__kmp_acquire_user_lock_with_checks_)(kmp_user_lock_p lck,
} else { \
KMP_YIELD_SPIN(spins); \
} \
- while (lck->tas.lk.poll != 0 || \
- !__kmp_compare_and_store_acq(&lck->tas.lk.poll, 0, gtid + 1)) { \
+ while (lck->tas.lk.poll != 0 || !__kmp_atomic_compare_store_acq( \
+ &lck->tas.lk.poll, 0, gtid + 1)) { \
if (TCR_4(__kmp_nth) > \
(__kmp_avail_proc ? __kmp_avail_proc : __kmp_xproc)) { \
KMP_YIELD(TRUE); \
@@ -702,7 +702,7 @@ static inline int __kmp_test_user_lock_with_checks(kmp_user_lock_p lck,
}
}
return ((lck->tas.lk.poll == 0) &&
- __kmp_compare_and_store_acq(&lck->tas.lk.poll, 0, gtid + 1));
+ __kmp_atomic_compare_store_acq(&lck->tas.lk.poll, 0, gtid + 1));
} else {
KMP_DEBUG_ASSERT(__kmp_test_user_lock_with_checks_ != NULL);
return (*__kmp_test_user_lock_with_checks_)(lck, gtid);
@@ -767,7 +767,7 @@ extern int (*__kmp_acquire_nested_user_lock_with_checks_)(kmp_user_lock_p lck,
*depth = KMP_LOCK_ACQUIRED_NEXT; \
} else { \
if ((lck->tas.lk.poll != 0) || \
- !__kmp_compare_and_store_acq(&lck->tas.lk.poll, 0, gtid + 1)) { \
+ !__kmp_atomic_compare_store_acq(&lck->tas.lk.poll, 0, gtid + 1)) { \
kmp_uint32 spins; \
KMP_FSYNC_PREPARE(lck); \
KMP_INIT_YIELD(spins); \
@@ -777,8 +777,9 @@ extern int (*__kmp_acquire_nested_user_lock_with_checks_)(kmp_user_lock_p lck,
} else { \
KMP_YIELD_SPIN(spins); \
} \
- while ((lck->tas.lk.poll != 0) || \
- !__kmp_compare_and_store_acq(&lck->tas.lk.poll, 0, gtid + 1)) { \
+ while ( \
+ (lck->tas.lk.poll != 0) || \
+ !__kmp_atomic_compare_store_acq(&lck->tas.lk.poll, 0, gtid + 1)) { \
if (TCR_4(__kmp_nth) > \
(__kmp_avail_proc ? __kmp_avail_proc : __kmp_xproc)) { \
KMP_YIELD(TRUE); \
@@ -826,7 +827,7 @@ static inline int __kmp_test_nested_user_lock_with_checks(kmp_user_lock_p lck,
return ++lck->tas.lk.depth_locked; /* same owner, depth increased */
}
retval = ((lck->tas.lk.poll == 0) &&
- __kmp_compare_and_store_acq(&lck->tas.lk.poll, 0, gtid + 1));
+ __kmp_atomic_compare_store_acq(&lck->tas.lk.poll, 0, gtid + 1));
if (retval) {
KMP_MB();
lck->tas.lk.depth_locked = 1;
diff --git a/openmp/runtime/src/kmp_tasking.cpp b/openmp/runtime/src/kmp_tasking.cpp
index daf5ad2db1c..4db2113ec69 100644
--- a/openmp/runtime/src/kmp_tasking.cpp
+++ b/openmp/runtime/src/kmp_tasking.cpp
@@ -811,8 +811,10 @@ static void __kmp_task_finish(kmp_int32 gtid, kmp_task_t *task,
kmp_taskdata_t *resumed_task) {
kmp_taskdata_t *taskdata = KMP_TASK_TO_TASKDATA(task);
kmp_info_t *thread = __kmp_threads[gtid];
+#if OMP_45_ENABLED
kmp_task_team_t *task_team =
thread->th.th_task_team; // might be NULL for serial teams...
+#endif // OMP_45_ENABLED
kmp_int32 children = 0;
KA_TRACE(10, ("__kmp_task_finish(enter): T#%d finishing task %p and resuming "
OpenPOWER on IntegriCloud