[Openmp-commits] [PATCH] D95170: [OpenMP] Fix misleading warning for OMP_PLACES

Jonathan Peyton via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Jan 21 13:49:59 PST 2021


jlpeyton created this revision.
jlpeyton added reviewers: AndreyChurbanov, tlwilmar.
jlpeyton added a project: OpenMP.
Herald added subscribers: guansong, yaxunl.
jlpeyton requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

When OMP_PLACES contains an invalid value, the warning informs the user
that the fallback is OMP_PLACES=threads, but the actual internal setting
is OMP_PLACES=cores and is detected as such with KMP_SETTINGS=1.
This patch correctly sets OMP_PLACES=threads internally like the warning states.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95170

Files:
  openmp/runtime/src/kmp_settings.cpp
  openmp/runtime/test/affinity/omp-places-invalid-syntax.c


Index: openmp/runtime/test/affinity/omp-places-invalid-syntax.c
===================================================================
--- /dev/null
+++ openmp/runtime/test/affinity/omp-places-invalid-syntax.c
@@ -0,0 +1,11 @@
+// RUN: %libomp-compile && env KMP_SETTINGS=1 OMP_PLACES=invalid %libomp-run 2>&1 | FileCheck %s
+// CHECK-DAG: Effective settings
+// CHECK: OMP_PLACES=
+// CHECK-SAME: threads
+// REQUIRES: affinity
+
+int main() {
+  #pragma omp parallel
+  {}
+  return 0;
+}
Index: openmp/runtime/src/kmp_settings.cpp
===================================================================
--- openmp/runtime/src/kmp_settings.cpp
+++ openmp/runtime/src/kmp_settings.cpp
@@ -2790,14 +2790,6 @@
     return;
   }
 
-  // If OMP_PROC_BIND is not specified but OMP_PLACES is,
-  // then let OMP_PROC_BIND default to true.
-  if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
-    __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
-  }
-
-  //__kmp_affinity_num_places = 0;
-
   if (__kmp_match_str("threads", scan, &next)) {
     scan = next;
     __kmp_affinity_type = affinity_compact;
@@ -2833,9 +2825,14 @@
       __kmp_affinity_type = affinity_explicit;
       __kmp_affinity_gran = affinity_gran_fine;
       __kmp_affinity_dups = FALSE;
-      if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
-        __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
-      }
+    } else {
+      // Syntax error fallback
+      __kmp_affinity_type = affinity_compact;
+      __kmp_affinity_gran = affinity_gran_thread;
+      __kmp_affinity_dups = FALSE;
+    }
+    if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) {
+      __kmp_nested_proc_bind.bind_types[0] = proc_bind_true;
     }
     return;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95170.318308.patch
Type: text/x-patch
Size: 1758 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210121/ae6e1fd6/attachment.bin>


More information about the Openmp-commits mailing list