diff options
author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2018-09-26 20:43:23 +0000 |
---|---|---|
committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2018-09-26 20:43:23 +0000 |
commit | 71f9b0e1ed868a1f6b8a2cb7658537027452931a (patch) | |
tree | 347c9e4551a1c96f72d70f9f1195bbbd737ab307 /runtime/src/kmp_affinity.cpp | |
parent | 56b88ef57287ab7ae4b46a901091a18a3155cf50 (diff) |
[OpenMP] Fix balanced affinity so thread's private affinity mask is updated
Balanced affinity only updated the thread's affinity with the operating system.
This change also has the thread's private mask reflect that change as well so
that any API that probes the thread's affinity mask will report the correct
mask value.
Differential Revision: https://reviews.llvm.org/D52379
git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@343142 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtime/src/kmp_affinity.cpp')
-rw-r--r-- | runtime/src/kmp_affinity.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/runtime/src/kmp_affinity.cpp b/runtime/src/kmp_affinity.cpp index bda80ea..a9a21cf 100644 --- a/runtime/src/kmp_affinity.cpp +++ b/runtime/src/kmp_affinity.cpp @@ -5012,8 +5012,10 @@ int __kmp_aux_get_affinity_mask_proc(int proc, void **mask) { } // 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 @@ void __kmp_balanced_affinity(int tid, int nthreads) { 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 @@ void __kmp_balanced_affinity(int tid, int nthreads) { __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 @@ void __kmp_balanced_affinity(int tid, int nthreads) { __kmp_gettid(), tid, buf); } __kmp_set_system_affinity(mask, TRUE); - KMP_CPU_FREE_FROM_STACK(mask); } } |