[Openmp-commits] [openmp] r309875 - Move lock acquire/release functions in task deque cleanup code

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Wed Aug 2 13:06:32 PDT 2017

Author: jlpeyton
Date: Wed Aug  2 13:06:32 2017
New Revision: 309875

URL: http://llvm.org/viewvc/llvm-project?rev=309875&view=rev
Move lock acquire/release functions in task deque cleanup code

The original locations can be reached without initializing the lock variable
(td_deque_lock), so it is potentially unsafe.  It is guaranteed that the lock
is initialized if the deque (td_deque) is not NULL, and lock functions can be
safely called.

Patch by Hansang Bae

Differential Revision: https://reviews.llvm.org/D36017


Modified: openmp/trunk/runtime/src/kmp_tasking.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_tasking.cpp?rev=309875&r1=309874&r2=309875&view=diff
--- openmp/trunk/runtime/src/kmp_tasking.cpp (original)
+++ openmp/trunk/runtime/src/kmp_tasking.cpp Wed Aug  2 13:06:32 2017
@@ -2504,14 +2504,13 @@ static void __kmp_realloc_task_deque(kmp
 // Deallocates a task deque for a particular thread. Happens at library
 // deallocation so don't need to reset all thread data fields.
 static void __kmp_free_task_deque(kmp_thread_data_t *thread_data) {
-  __kmp_acquire_bootstrap_lock(&thread_data->td.td_deque_lock);
   if (thread_data->td.td_deque != NULL) {
+    __kmp_acquire_bootstrap_lock(&thread_data->td.td_deque_lock);
     TCW_4(thread_data->td.td_deque_ntasks, 0);
     thread_data->td.td_deque = NULL;
+    __kmp_release_bootstrap_lock(&thread_data->td.td_deque_lock);
-  __kmp_release_bootstrap_lock(&thread_data->td.td_deque_lock);
   // GEH: Figure out what to do here for td_susp_tied_tasks

More information about the Openmp-commits mailing list