[Openmp-commits] [PATCH] D52379: Fix balanced affinity so thread's private affinity mask is updated

Jonathan Peyton via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Sep 26 13:45:13 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL343142: [OpenMP] Fix balanced affinity so thread's private affinity mask is updated (authored by jlpeyton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52379?vs=166547&id=167192#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52379

Files:
  openmp/trunk/runtime/src/kmp.h
  openmp/trunk/runtime/src/kmp_affinity.cpp
  openmp/trunk/runtime/src/kmp_barrier.cpp


Index: openmp/trunk/runtime/src/kmp_affinity.cpp
===================================================================
--- openmp/trunk/runtime/src/kmp_affinity.cpp
+++ openmp/trunk/runtime/src/kmp_affinity.cpp
@@ -5012,8 +5012,10 @@
 }
 
 // Dynamic affinity settings - Affinity balanced
-void __kmp_balanced_affinity(int tid, int nthreads) {
+void __kmp_balanced_affinity(kmp_info_t *th, int nthreads) {
+  KMP_DEBUG_ASSERT(th);
   bool fine_gran = true;
+  int tid = th->th.th_info.ds.ds_tid;
 
   switch (__kmp_affinity_gran) {
   case affinity_gran_fine:
@@ -5061,8 +5063,7 @@
     KMP_DEBUG_ASSERT2(KMP_AFFINITY_CAPABLE(),
                       "Illegal set affinity operation when not capable");
 
-    kmp_affin_mask_t *mask;
-    KMP_CPU_ALLOC_ON_STACK(mask);
+    kmp_affin_mask_t *mask = th->th.th_affin_mask;
     KMP_CPU_ZERO(mask);
 
     if (fine_gran) {
@@ -5082,11 +5083,9 @@
                  __kmp_gettid(), tid, buf);
     }
     __kmp_set_system_affinity(mask, TRUE);
-    KMP_CPU_FREE_FROM_STACK(mask);
   } else { // Non-uniform topology
 
-    kmp_affin_mask_t *mask;
-    KMP_CPU_ALLOC_ON_STACK(mask);
+    kmp_affin_mask_t *mask = th->th.th_affin_mask;
     KMP_CPU_ZERO(mask);
 
     int core_level = __kmp_affinity_find_core_level(
@@ -5250,7 +5249,6 @@
                  __kmp_gettid(), tid, buf);
     }
     __kmp_set_system_affinity(mask, TRUE);
-    KMP_CPU_FREE_FROM_STACK(mask);
   }
 }
 
Index: openmp/trunk/runtime/src/kmp_barrier.cpp
===================================================================
--- openmp/trunk/runtime/src/kmp_barrier.cpp
+++ openmp/trunk/runtime/src/kmp_barrier.cpp
@@ -1970,7 +1970,7 @@
 #if KMP_AFFINITY_SUPPORTED
     // Call dynamic affinity settings
     if (__kmp_affinity_type == affinity_balanced && team->t.t_size_changed) {
-      __kmp_balanced_affinity(tid, team->t.t_nproc);
+      __kmp_balanced_affinity(this_thr, team->t.t_nproc);
     }
 #endif // KMP_AFFINITY_SUPPORTED
 #if OMP_40_ENABLED && KMP_AFFINITY_SUPPORTED
Index: openmp/trunk/runtime/src/kmp.h
===================================================================
--- openmp/trunk/runtime/src/kmp.h
+++ openmp/trunk/runtime/src/kmp.h
@@ -3362,7 +3362,7 @@
 extern int __kmp_aux_set_affinity_mask_proc(int proc, void **mask);
 extern int __kmp_aux_unset_affinity_mask_proc(int proc, void **mask);
 extern int __kmp_aux_get_affinity_mask_proc(int proc, void **mask);
-extern void __kmp_balanced_affinity(int tid, int team_size);
+extern void __kmp_balanced_affinity(kmp_info_t *th, int team_size);
 #if KMP_OS_LINUX
 extern int kmp_set_thread_affinity_mask_initial(void);
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52379.167192.patch
Type: text/x-patch
Size: 2617 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20180926/39f44559/attachment.bin>


More information about the Openmp-commits mailing list