diff options
author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2022-11-01 12:29:17 -0500 |
---|---|---|
committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2022-11-02 15:37:41 -0500 |
commit | 96696b882bdbeb219fbdd42cad1c091fc86b83d7 (patch) | |
tree | e4070fdb50095a10b4c194b33213d8d0b83afb7f /openmp/runtime/src/kmp_affinity.cpp | |
parent | 117d792f35e6f84f2f29183408284c7e1cc838e7 (diff) | |
download | llvm-96696b882bdbeb219fbdd42cad1c091fc86b83d7.zip llvm-96696b882bdbeb219fbdd42cad1c091fc86b83d7.tar.gz llvm-96696b882bdbeb219fbdd42cad1c091fc86b83d7.tar.bz2 |
[OpenMP][libomp] Fix disabled affinity
Fix setting affinity type and topology method when affinity is disabled
and fix places that were not taking into account that affinity can be
explicitly disabled by putting proper KMP_AFFINITY_CAPABLE() check.
Differential Revision: https://reviews.llvm.org/D137176
Diffstat (limited to 'openmp/runtime/src/kmp_affinity.cpp')
-rw-r--r-- | openmp/runtime/src/kmp_affinity.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/openmp/runtime/src/kmp_affinity.cpp b/openmp/runtime/src/kmp_affinity.cpp index e9d0b99..43bf794 100644 --- a/openmp/runtime/src/kmp_affinity.cpp +++ b/openmp/runtime/src/kmp_affinity.cpp @@ -675,7 +675,11 @@ void kmp_topology_t::print(const char *env_var) const { kmp_hw_t print_types[KMP_HW_LAST + 2]; // Num Available Threads - KMP_INFORM(AvailableOSProc, env_var, num_hw_threads); + if (num_hw_threads) { + KMP_INFORM(AvailableOSProc, env_var, num_hw_threads); + } else { + KMP_INFORM(AvailableOSProc, env_var, __kmp_xproc); + } // Uniform or not if (is_uniform()) { @@ -3062,7 +3066,8 @@ static bool __kmp_affinity_create_cpuinfo_map(int *line, } // Skip this proc if it is not included in the machine model. - if (!KMP_CPU_ISSET(threadInfo[num_avail][osIdIndex], + if (KMP_AFFINITY_CAPABLE() && + !KMP_CPU_ISSET(threadInfo[num_avail][osIdIndex], __kmp_affin_fullMask)) { INIT_PROC_INFO(threadInfo[num_avail]); continue; @@ -4525,6 +4530,9 @@ void __kmp_affinity_uninitialize(void) { *affinity = KMP_AFFINITY_INIT(affinity->env_var); } if (__kmp_affin_origMask != NULL) { + if (KMP_AFFINITY_CAPABLE()) { + __kmp_set_system_affinity(__kmp_affin_origMask, FALSE); + } KMP_CPU_FREE(__kmp_affin_origMask); __kmp_affin_origMask = NULL; } |