[PATCH] D41831: Minor code cleanup

Jonathan Peyton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 10 10:25:33 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL322203: Minor code cleanup (authored by jlpeyton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41831?vs=128968&id=129303#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41831

Files:
  openmp/trunk/runtime/src/kmp_lock.h
  openmp/trunk/runtime/src/kmp_runtime.cpp
  openmp/trunk/runtime/src/kmp_tasking.cpp


Index: openmp/trunk/runtime/src/kmp_lock.h
===================================================================
--- openmp/trunk/runtime/src/kmp_lock.h
+++ openmp/trunk/runtime/src/kmp_lock.h
@@ -158,11 +158,11 @@
 #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
 
 // ----------------------------------------------------------------------------
Index: openmp/trunk/runtime/src/kmp_tasking.cpp
===================================================================
--- openmp/trunk/runtime/src/kmp_tasking.cpp
+++ openmp/trunk/runtime/src/kmp_tasking.cpp
@@ -984,9 +984,10 @@
 // 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
Index: openmp/trunk/runtime/src/kmp_runtime.cpp
===================================================================
--- openmp/trunk/runtime/src/kmp_runtime.cpp
+++ openmp/trunk/runtime/src/kmp_runtime.cpp
@@ -5528,6 +5528,14 @@
   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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41831.129303.patch
Type: text/x-patch
Size: 2271 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180110/77a3802e/attachment.bin>


More information about the llvm-commits mailing list