[Openmp-commits] [PATCH] D33208: Fix for KMP_AFFINITY=disabled and KMP_TOPOLOGY_METHOD=hwloc

Jonathan Peyton via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed May 31 13:35:51 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL304344: Fix for KMP_AFFINITY=disabled and KMP_TOPOLOGY_METHOD=hwloc (authored by jlpeyton).

Changed prior to commit:
  https://reviews.llvm.org/D33208?vs=99040&id=100915#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33208

Files:
  openmp/trunk/runtime/src/kmp_affinity.cpp
  openmp/trunk/runtime/src/kmp_settings.cpp
  openmp/trunk/runtime/test/env/kmp_aff_disable_hwloc.c
  openmp/trunk/runtime/test/lit.cfg


Index: openmp/trunk/runtime/test/env/kmp_aff_disable_hwloc.c
===================================================================
--- openmp/trunk/runtime/test/env/kmp_aff_disable_hwloc.c
+++ openmp/trunk/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;
+}
Index: openmp/trunk/runtime/test/lit.cfg
===================================================================
--- openmp/trunk/runtime/test/lit.cfg
+++ openmp/trunk/runtime/test/lit.cfg
@@ -64,6 +64,7 @@
 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':
Index: openmp/trunk/runtime/src/kmp_settings.cpp
===================================================================
--- openmp/trunk/runtime/src/kmp_settings.cpp
+++ openmp/trunk/runtime/src/kmp_settings.cpp
@@ -5033,6 +5033,16 @@
     // 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()) {
Index: openmp/trunk/runtime/src/kmp_affinity.cpp
===================================================================
--- openmp/trunk/runtime/src/kmp_affinity.cpp
+++ openmp/trunk/runtime/src/kmp_affinity.cpp
@@ -61,7 +61,10 @@
   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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33208.100915.patch
Type: text/x-patch
Size: 2706 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20170531/e9bb3512/attachment.bin>


More information about the Openmp-commits mailing list