From 79390ad7096899c51863b823d8d76c85aa30af51 Mon Sep 17 00:00:00 2001 From: Jonathan Peyton Date: Wed, 10 Jan 2018 18:31:49 +0000 Subject: [PATCH] Force HWLOC topology method for NUMA-specific topology If user requested affinity with granularity=tile we need to either use HWLOC or ignore the request. The change allows user to not specify KMP_TOPOLOGY_METHOD=hwloc and choose it automatically instead. Patch by Andrey Churbanov Differential Revision: https://reviews.llvm.org/D40905 llvm-svn: 322205 --- openmp/runtime/src/kmp_settings.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/openmp/runtime/src/kmp_settings.cpp b/openmp/runtime/src/kmp_settings.cpp index 1f2fae9a69d8..0a05e7c6b75b 100644 --- a/openmp/runtime/src/kmp_settings.cpp +++ b/openmp/runtime/src/kmp_settings.cpp @@ -5126,6 +5126,15 @@ void __kmp_env_initialize(char const *string) { #if KMP_AFFINITY_SUPPORTED if (!TCR_4(__kmp_init_middle)) { +#if KMP_USE_HWLOC + // Force using hwloc when either tiles or numa nodes requested within + // KMP_HW_SUBSET and no other topology method is requested + if ((__kmp_hws_node.num > 0 || __kmp_hws_tile.num > 0 || + __kmp_affinity_gran == affinity_gran_tile) && + (__kmp_affinity_top_method == affinity_top_method_default)) { + __kmp_affinity_top_method = affinity_top_method_hwloc; + } +#endif // Determine if the machine/OS is actually capable of supporting // affinity. const char *var = "KMP_AFFINITY";