[Openmp-commits] [openmp] r260615 - Fix incorrect task_team in __kmp_give_task

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Thu Feb 11 15:07:31 PST 2016


Author: jlpeyton
Date: Thu Feb 11 17:07:30 2016
New Revision: 260615

URL: http://llvm.org/viewvc/llvm-project?rev=260615&view=rev
Log:
Fix incorrect task_team in __kmp_give_task

When a target task finishes and it tries to access the th_task_team from the
threads in the team where it was created, th_task_team can be NULL or point to
a different place when that thread started a nested region that is still
running. Finding the exact task_team that the threads were using is difficult
as it would require to unwind the task_state_memo_stack. So a new field was added
in the taskdata structure to point to the active task_team when the task was
created.

Modified:
    openmp/trunk/runtime/src/kmp.h
    openmp/trunk/runtime/src/kmp_tasking.c

Modified: openmp/trunk/runtime/src/kmp.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp.h?rev=260615&r1=260614&r2=260615&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp.h (original)
+++ openmp/trunk/runtime/src/kmp.h Thu Feb 11 17:07:30 2016
@@ -2140,6 +2140,9 @@ struct kmp_taskdata {
 #if OMPT_SUPPORT
     ompt_task_info_t        ompt_task_info;
 #endif
+#if OMP_41_ENABLED
+    kmp_task_team_t *       td_task_team;
+#endif
 #if KMP_HAVE_QUAD
     _Quad                   td_dummy;             // Align structure 16-byte size since allocated just before kmp_task_t
 #else

Modified: openmp/trunk/runtime/src/kmp_tasking.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_tasking.c?rev=260615&r1=260614&r2=260615&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_tasking.c (original)
+++ openmp/trunk/runtime/src/kmp_tasking.c Thu Feb 11 17:07:30 2016
@@ -999,6 +999,7 @@ __kmp_task_alloc( ident_t *loc_ref, kmp_
 #endif // OMP_40_ENABLED
 #if OMP_41_ENABLED
     taskdata->td_flags.proxy           = flags->proxy;
+    taskdata->td_task_team         = thread->th.th_task_team;
 #endif
     taskdata->td_flags.tasktype    = TASK_EXPLICIT;
 
@@ -2711,16 +2712,17 @@ __kmp_tasking_barrier( kmp_team_t *team,
  */
 static bool __kmp_give_task ( kmp_info_t *thread, kmp_int32 tid, kmp_task_t * task )
 {
-    kmp_task_team_t *   task_team = thread->th.th_task_team;
-    kmp_thread_data_t * thread_data = & task_team -> tt.tt_threads_data[ tid ];
     kmp_taskdata_t *    taskdata = KMP_TASK_TO_TASKDATA(task);
-    bool result = false;
+    kmp_task_team_t *	task_team = taskdata->td_task_team;
 
     KA_TRACE(20, ("__kmp_give_task: trying to give task %p to thread %d.\n", taskdata, tid ) );
 
-    // assert tasking is enabled? what if not?
+    // If task_team is NULL something went really bad...
     KMP_DEBUG_ASSERT( task_team != NULL );
 
+    bool result = false;
+    kmp_thread_data_t * thread_data = & task_team -> tt.tt_threads_data[ tid ];
+
     if (thread_data -> td.td_deque == NULL ) {
         // There's no queue in this thread, go find another one
         // We're guaranteed that at least one thread has a queue




More information about the Openmp-commits mailing list