diff options
| author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2017-05-31 20:35:22 +0000 |
|---|---|---|
| committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2017-05-31 20:35:22 +0000 |
| commit | e3e2aaf68d991321c881e5b2ce002849988eeb42 (patch) | |
| tree | 6f0e388d01bc625a73070875504ba04113d67d66 | |
| parent | 9f5df8b02e27703b2f1febd51dac3450d6431345 (diff) | |
| download | bcm5719-llvm-e3e2aaf68d991321c881e5b2ce002849988eeb42.tar.gz bcm5719-llvm-e3e2aaf68d991321c881e5b2ce002849988eeb42.zip | |
Fix for KMP_AFFINITY=disabled and KMP_TOPOLOGY_METHOD=hwloc
With these settings, the create_hwloc_map() method was being called causing an
assert(). After some consideration, it was determined that disabling affinity
explicitly should just disable hwloc as well. i.e., KMP_AFFINITY overrides
KMP_TOPOLOGY_METHOD. This lets the user know that the Hwloc mechanism is being
ignored when KMP_AFFINITY=disabled.
Differential Revision: https://reviews.llvm.org/D33208
llvm-svn: 304344
| -rw-r--r-- | openmp/runtime/src/kmp_affinity.cpp | 5 | ||||
| -rw-r--r-- | openmp/runtime/src/kmp_settings.cpp | 10 | ||||
| -rw-r--r-- | openmp/runtime/test/env/kmp_aff_disable_hwloc.c | 21 | ||||
| -rw-r--r-- | openmp/runtime/test/lit.cfg | 1 |
4 files changed, 36 insertions, 1 deletions
diff --git a/openmp/runtime/src/kmp_affinity.cpp b/openmp/runtime/src/kmp_affinity.cpp index b58a3d6e461..038542526d4 100644 --- a/openmp/runtime/src/kmp_affinity.cpp +++ b/openmp/runtime/src/kmp_affinity.cpp @@ -61,7 +61,10 @@ void KMPAffinity::pick_api() { if (picked_api) return; #if KMP_USE_HWLOC - if (__kmp_affinity_top_method == affinity_top_method_hwloc) { + // Only use Hwloc if affinity isn't explicitly disabled and + // user requests Hwloc topology method + if (__kmp_affinity_top_method == affinity_top_method_hwloc && + __kmp_affinity_type != affinity_disabled) { affinity_dispatch = new KMPHwlocAffinity(); } else #endif diff --git a/openmp/runtime/src/kmp_settings.cpp b/openmp/runtime/src/kmp_settings.cpp index b282ffe4921..ed61a670081 100644 --- a/openmp/runtime/src/kmp_settings.cpp +++ b/openmp/runtime/src/kmp_settings.cpp @@ -5033,6 +5033,16 @@ void __kmp_env_initialize(char const *string) { // affinity. const char *var = "KMP_AFFINITY"; KMPAffinity::pick_api(); +#if KMP_USE_HWLOC + // If Hwloc topology discovery was requested but affinity was also disabled, + // then tell user that Hwloc request is being ignored and use default + // topology discovery method. + if (__kmp_affinity_top_method == affinity_top_method_hwloc && + __kmp_affinity_dispatch->get_api_type() != KMPAffinity::HWLOC) { + KMP_WARNING(AffIgnoringHwloc, var); + __kmp_affinity_top_method = affinity_top_method_all; + } +#endif if (__kmp_affinity_type == affinity_disabled) { KMP_AFFINITY_DISABLE(); } else if (!KMP_AFFINITY_CAPABLE()) { diff --git a/openmp/runtime/test/env/kmp_aff_disable_hwloc.c b/openmp/runtime/test/env/kmp_aff_disable_hwloc.c new file mode 100644 index 00000000000..5f848ac4049 --- /dev/null +++ b/openmp/runtime/test/env/kmp_aff_disable_hwloc.c @@ -0,0 +1,21 @@ +// RUN: %libomp-compile && env KMP_AFFINITY=disabled KMP_TOPOLOGY_METHOD=hwloc %libomp-run +// REQUIRES: hwloc +#include <stdio.h> +#include <stdlib.h> + +// Test will assert() without fix +int test_affinity_disabled_plus_hwloc() { + #pragma omp parallel + {} + return 1; +} + +int main(int argc, char **argv) { + int i, j; + int failed = 0; + + if (!test_affinity_disabled_plus_hwloc()) { + failed = 1; + } + return failed; +} diff --git a/openmp/runtime/test/lit.cfg b/openmp/runtime/test/lit.cfg index bef61d444da..e9eeae8518c 100644 --- a/openmp/runtime/test/lit.cfg +++ b/openmp/runtime/test/lit.cfg @@ -64,6 +64,7 @@ if re.search('gcc', config.test_compiler) is not None: append_dynamic_library_path(config.library_dir) if config.using_hwloc: append_dynamic_library_path(config.hwloc_library_dir) + config.available_features.add('hwloc') # Rpath modifications for Darwin if config.operating_system == 'Darwin': |

