aboutsummaryrefslogtreecommitdiff
path: root/openmp/runtime/src/z_Linux_util.cpp
diff options
context:
space:
mode:
authorJohannes Doerfert <johannes@jdoerfert.de>2021-06-29 09:34:53 -0500
committerJohannes Doerfert <johannes@jdoerfert.de>2021-06-29 09:38:27 -0500
commit4eb90e893f82314def571f7129dfd88bd098208b (patch)
tree6d1a9ad5cdc91874c23654b3c3e2661ed341bee9 /openmp/runtime/src/z_Linux_util.cpp
parentbc8bb3df35223afeea62170b32f8ce9bd04255d4 (diff)
downloadllvm-4eb90e893f82314def571f7129dfd88bd098208b.zip
llvm-4eb90e893f82314def571f7129dfd88bd098208b.tar.gz
llvm-4eb90e893f82314def571f7129dfd88bd098208b.tar.bz2
Revert "[OpenMP] Add Two-level Distributed Barrier"
This reverts commit 25073a4ecfc9b2e3cb76776185e63bfdb094cd98. This breaks non-x86 OpenMP builds for a while now. Until a solution is ready to be upstreamed we revert the feature and unblock those builds. See: https://reviews.llvm.org/rG25073a4ecfc9b2e3cb76776185e63bfdb094cd98#1005821 and https://reviews.llvm.org/rG25073a4ecfc9b2e3cb76776185e63bfdb094cd98#1005821 The currently proposed fix (D104788) seems not to be ready yet: https://reviews.llvm.org/D104788#2841928
Diffstat (limited to 'openmp/runtime/src/z_Linux_util.cpp')
-rw-r--r--openmp/runtime/src/z_Linux_util.cpp90
1 files changed, 16 insertions, 74 deletions
diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index 920de69..bd50987 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -1409,13 +1409,9 @@ static inline void __kmp_suspend_template(int th_gtid, C *flag) {
/* TODO: shouldn't this use release semantics to ensure that
__kmp_suspend_initialize_thread gets called first? */
old_spin = flag->set_sleeping();
- TCW_PTR(th->th.th_sleep_loc, (void *)flag);
- th->th.th_sleep_loc_type = flag->get_type();
if (__kmp_dflt_blocktime == KMP_MAX_BLOCKTIME &&
__kmp_pause_status != kmp_soft_paused) {
flag->unset_sleeping();
- TCW_PTR(th->th.th_sleep_loc, NULL);
- th->th.th_sleep_loc_type = flag_unset;
__kmp_unlock_suspend_mx(th);
return;
}
@@ -1423,10 +1419,8 @@ static inline void __kmp_suspend_template(int th_gtid, C *flag) {
" was %x\n",
th_gtid, flag->get(), flag->load(), old_spin));
- if (flag->done_check_val(old_spin) || flag->done_check()) {
- flag->unset_sleeping();
- TCW_PTR(th->th.th_sleep_loc, NULL);
- th->th.th_sleep_loc_type = flag_unset;
+ if (flag->done_check_val(old_spin)) {
+ old_spin = flag->unset_sleeping();
KF_TRACE(5, ("__kmp_suspend_template: T#%d false alarm, reset sleep bit "
"for spin(%p)\n",
th_gtid, flag->get()));
@@ -1435,6 +1429,7 @@ static inline void __kmp_suspend_template(int th_gtid, C *flag) {
"with low probability" return when the condition variable has
not been signaled or broadcast */
int deactivated = FALSE;
+ TCW_PTR(th->th.th_sleep_loc, (void *)flag);
while (flag->is_sleeping()) {
#ifdef DEBUG_SUSPEND
@@ -1456,9 +1451,6 @@ static inline void __kmp_suspend_template(int th_gtid, C *flag) {
deactivated = TRUE;
}
- KMP_DEBUG_ASSERT(th->th.th_sleep_loc);
- KMP_DEBUG_ASSERT(flag->get_type() == th->th.th_sleep_loc_type);
-
#if USE_SUSPEND_TIMEOUT
struct timespec now;
struct timeval tval;
@@ -1488,18 +1480,6 @@ static inline void __kmp_suspend_template(int th_gtid, C *flag) {
if ((status != 0) && (status != EINTR) && (status != ETIMEDOUT)) {
KMP_SYSFAIL("pthread_cond_wait", status);
}
-
- KMP_DEBUG_ASSERT(flag->get_type() == flag->get_ptr_type());
-
- if (!flag->is_sleeping() &&
- ((status == EINTR) || (status == ETIMEDOUT))) {
- // if interrupt or timeout, and thread is no longer sleeping, we need to
- // make sure sleep_loc gets reset; however, this shouldn't be needed if
- // we woke up with resume
- flag->unset_sleeping();
- TCW_PTR(th->th.th_sleep_loc, NULL);
- th->th.th_sleep_loc_type = flag_unset;
- }
#ifdef KMP_DEBUG
if (status == ETIMEDOUT) {
if (flag->is_sleeping()) {
@@ -1509,8 +1489,6 @@ static inline void __kmp_suspend_template(int th_gtid, C *flag) {
KF_TRACE(2, ("__kmp_suspend_template: T#%d timeout wakeup, sleep bit "
"not set!\n",
th_gtid));
- TCW_PTR(th->th.th_sleep_loc, NULL);
- th->th.th_sleep_loc_type = flag_unset;
}
} else if (flag->is_sleeping()) {
KF_TRACE(100,
@@ -1528,13 +1506,6 @@ static inline void __kmp_suspend_template(int th_gtid, C *flag) {
}
}
}
- // We may have had the loop variable set before entering the loop body;
- // so we need to reset sleep_loc.
- TCW_PTR(th->th.th_sleep_loc, NULL);
- th->th.th_sleep_loc_type = flag_unset;
-
- KMP_DEBUG_ASSERT(!flag->is_sleeping());
- KMP_DEBUG_ASSERT(!th->th.th_sleep_loc);
#ifdef DEBUG_SUSPEND
{
char buffer[128];
@@ -1556,10 +1527,6 @@ template <bool C, bool S>
void __kmp_suspend_64(int th_gtid, kmp_flag_64<C, S> *flag) {
__kmp_suspend_template(th_gtid, flag);
}
-template <bool C, bool S>
-void __kmp_atomic_suspend_64(int th_gtid, kmp_atomic_flag_64<C, S> *flag) {
- __kmp_suspend_template(th_gtid, flag);
-}
void __kmp_suspend_oncore(int th_gtid, kmp_flag_oncore *flag) {
__kmp_suspend_template(th_gtid, flag);
}
@@ -1567,10 +1534,6 @@ void __kmp_suspend_oncore(int th_gtid, kmp_flag_oncore *flag) {
template void __kmp_suspend_32<false, false>(int, kmp_flag_32<false, false> *);
template void __kmp_suspend_64<false, true>(int, kmp_flag_64<false, true> *);
template void __kmp_suspend_64<true, false>(int, kmp_flag_64<true, false> *);
-template void
-__kmp_atomic_suspend_64<false, true>(int, kmp_atomic_flag_64<false, true> *);
-template void
-__kmp_atomic_suspend_64<true, false>(int, kmp_atomic_flag_64<true, false> *);
/* This routine signals the thread specified by target_gtid to wake up
after setting the sleep bit indicated by the flag argument to FALSE.
@@ -1593,50 +1556,36 @@ static inline void __kmp_resume_template(int target_gtid, C *flag) {
__kmp_lock_suspend_mx(th);
- if (!flag || flag != th->th.th_sleep_loc) {
- // coming from __kmp_null_resume_wrapper, or thread is now sleeping on a
- // different location; wake up at new location
+ if (!flag) { // coming from __kmp_null_resume_wrapper
flag = (C *)CCAST(void *, th->th.th_sleep_loc);
}
// First, check if the flag is null or its type has changed. If so, someone
// else woke it up.
- if (!flag) { // Thread doesn't appear to be sleeping on anything
+ if (!flag || flag->get_type() != flag->get_ptr_type()) { // get_ptr_type
+ // simply shows what flag was cast to
KF_TRACE(5, ("__kmp_resume_template: T#%d exiting, thread T#%d already "
"awake: flag(%p)\n",
- gtid, target_gtid, (void *)NULL));
- __kmp_unlock_suspend_mx(th);
- return;
- } else if (flag->get_type() != th->th.th_sleep_loc_type) {
- // Flag type does not appear to match this function template; possibly the
- // thread is sleeping on something else. Try null resume again.
- KF_TRACE(
- 5,
- ("__kmp_resume_template: T#%d retrying, thread T#%d Mismatch flag(%p), "
- "spin(%p) type=%d ptr_type=%d\n",
- gtid, target_gtid, flag, flag->get(), flag->get_type(),
- th->th.th_sleep_loc_type));
+ gtid, target_gtid, NULL));
__kmp_unlock_suspend_mx(th);
- __kmp_null_resume_wrapper(th);
return;
} else { // if multiple threads are sleeping, flag should be internally
// referring to a specific thread here
- if (!flag->is_sleeping()) {
+ typename C::flag_t old_spin = flag->unset_sleeping();
+ if (!flag->is_sleeping_val(old_spin)) {
KF_TRACE(5, ("__kmp_resume_template: T#%d exiting, thread T#%d already "
- "awake: flag(%p): %u\n",
- gtid, target_gtid, flag->get(), (unsigned int)flag->load()));
+ "awake: flag(%p): "
+ "%u => %u\n",
+ gtid, target_gtid, flag->get(), old_spin, flag->load()));
__kmp_unlock_suspend_mx(th);
return;
}
+ KF_TRACE(5, ("__kmp_resume_template: T#%d about to wakeup T#%d, reset "
+ "sleep bit for flag's loc(%p): "
+ "%u => %u\n",
+ gtid, target_gtid, flag->get(), old_spin, flag->load()));
}
- KMP_DEBUG_ASSERT(flag);
- flag->unset_sleeping();
TCW_PTR(th->th.th_sleep_loc, NULL);
- th->th.th_sleep_loc_type = flag_unset;
-
- KF_TRACE(5, ("__kmp_resume_template: T#%d about to wakeup T#%d, reset "
- "sleep bit for flag's loc(%p): %u\n",
- gtid, target_gtid, flag->get(), (unsigned int)flag->load()));
#ifdef DEBUG_SUSPEND
{
@@ -1662,19 +1611,12 @@ template <bool C, bool S>
void __kmp_resume_64(int target_gtid, kmp_flag_64<C, S> *flag) {
__kmp_resume_template(target_gtid, flag);
}
-template <bool C, bool S>
-void __kmp_atomic_resume_64(int target_gtid, kmp_atomic_flag_64<C, S> *flag) {
- __kmp_resume_template(target_gtid, flag);
-}
void __kmp_resume_oncore(int target_gtid, kmp_flag_oncore *flag) {
__kmp_resume_template(target_gtid, flag);
}
template void __kmp_resume_32<false, true>(int, kmp_flag_32<false, true> *);
-template void __kmp_resume_32<false, false>(int, kmp_flag_32<false, false> *);
template void __kmp_resume_64<false, true>(int, kmp_flag_64<false, true> *);
-template void
-__kmp_atomic_resume_64<false, true>(int, kmp_atomic_flag_64<false, true> *);
#if KMP_USE_MONITOR
void __kmp_resume_monitor() {