summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Peyton <jonathan.l.peyton@intel.com>2018-01-10 18:24:09 +0000
committerJonathan Peyton <jonathan.l.peyton@intel.com>2018-01-10 18:24:09 +0000
commitbff8ded906b40506ac81cf81bc980fddc6768dc5 (patch)
tree42f75c6d18ade87455019816704dbdc9c6b53a16
parenteaa9e40c9ae09d3b85e0cbf2035a6ad0cd27cdcd (diff)
downloadbcm5719-llvm-bff8ded906b40506ac81cf81bc980fddc6768dc5.tar.gz
bcm5719-llvm-bff8ded906b40506ac81cf81bc980fddc6768dc5.zip
Minor code cleanup
Patch by Terry Wilmarth Differential Revision: https://reviews.llvm.org/D41831 llvm-svn: 322203
-rw-r--r--openmp/runtime/src/kmp_lock.h4
-rw-r--r--openmp/runtime/src/kmp_runtime.cpp8
-rw-r--r--openmp/runtime/src/kmp_tasking.cpp5
3 files changed, 13 insertions, 4 deletions
diff --git a/openmp/runtime/src/kmp_lock.h b/openmp/runtime/src/kmp_lock.h
index b55df8c89cc..78cf0ccc627 100644
--- a/openmp/runtime/src/kmp_lock.h
+++ b/openmp/runtime/src/kmp_lock.h
@@ -158,11 +158,11 @@ extern void __kmp_destroy_nested_tas_lock(kmp_tas_lock_t *lck);
#define KMP_LOCK_STILL_HELD 0
#define KMP_LOCK_ACQUIRED_FIRST 1
#define KMP_LOCK_ACQUIRED_NEXT 0
-
+#ifndef KMP_USE_FUTEX
#define KMP_USE_FUTEX \
(KMP_OS_LINUX && !KMP_OS_CNK && \
(KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64))
-
+#endif
#if KMP_USE_FUTEX
// ----------------------------------------------------------------------------
diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp
index 04a9ef3eea6..4aadac8cad7 100644
--- a/openmp/runtime/src/kmp_runtime.cpp
+++ b/openmp/runtime/src/kmp_runtime.cpp
@@ -5528,6 +5528,14 @@ void __kmp_free_thread(kmp_info_t *this_th) {
TCW_PTR(this_th->th.th_root, NULL);
TCW_PTR(this_th->th.th_dispatch, NULL); /* NOT NEEDED */
+ /* If the implicit task assigned to this thread can be used by other threads
+ * -> multiple threads can share the data and try to free the task at
+ * __kmp_reap_thread at exit. This duplicate use of the task data can happen
+ * with higher probability when hot team is disabled but can occurs even when
+ * the hot team is enabled */
+ __kmp_free_implicit_task(this_th);
+ this_th->th.th_current_task = NULL;
+
// If the __kmp_thread_pool_insert_pt is already past the new insert
// point, then we need to re-scan the entire list.
gtid = this_th->th.th_info.ds.ds_gtid;
diff --git a/openmp/runtime/src/kmp_tasking.cpp b/openmp/runtime/src/kmp_tasking.cpp
index 97baaf701ed..0eac1130d31 100644
--- a/openmp/runtime/src/kmp_tasking.cpp
+++ b/openmp/runtime/src/kmp_tasking.cpp
@@ -984,9 +984,10 @@ void __kmp_finish_implicit_task(kmp_info_t *thread) {
// thread: thread data structure corresponding to implicit task
void __kmp_free_implicit_task(kmp_info_t *thread) {
kmp_taskdata_t *task = thread->th.th_current_task;
- if (task->td_dephash)
+ if (task && task->td_dephash) {
__kmp_dephash_free(thread, task->td_dephash);
- task->td_dephash = NULL;
+ task->td_dephash = NULL;
+ }
}
// Round up a size to a power of two specified by val: Used to insert padding
OpenPOWER on IntegriCloud