[Openmp-commits] [PATCH] D38292: KMP_HW_SUBSET vs KMP_PLACE_THREADS rival envirables fix

Jonathan Peyton via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Sep 26 15:31:32 PDT 2017


jlpeyton created this revision.

if both KMP_HW_SUBSET and KMP_PLACE_THREADS are set and KMP_PLACE_THREADS gets
parsed first, then the current environment variable parser rejects both and
neither get used.  This patch uses the rivals mechanism that is used for other
environment variable groups (e.g., KMP_STACKSIZE, GOMP_STACKSIZE, OMP_STACKSIZE).
If both are set, then it tells the user that it is ignoring KMP_PLACE_THREADS in
favor of KMP_HW_SUBSET.  The message about deprecating KMP_PLACE_THREADS when it
is set is still printed regardless.


Repository:
  rL LLVM

https://reviews.llvm.org/D38292

Files:
  runtime/src/kmp_settings.cpp


Index: runtime/src/kmp_settings.cpp
===================================================================
--- runtime/src/kmp_settings.cpp
+++ runtime/src/kmp_settings.cpp
@@ -4116,14 +4116,13 @@
                                       void *data) {
   // Value example: 1s,5c at 3,2T
   // Which means "use 1 socket, 5 cores with offset 3, 2 threads per core"
-  static int parsed = 0;
+  kmp_setting_t **rivals = (kmp_setting_t **)data;
   if (strcmp(name, "KMP_PLACE_THREADS") == 0) {
     KMP_INFORM(EnvVarDeprecated, name, "KMP_HW_SUBSET");
-    if (parsed == 1) {
-      return; // already parsed KMP_HW_SUBSET
-    }
   }
-  parsed = 1;
+  if (__kmp_stg_check_rivals(name, value, rivals)) {
+    return;
+  }
 
   char *components[MAX_T_LEVEL];
   char const *digits = "0123456789";
@@ -4733,6 +4732,24 @@
       kmp_all_threads->data = CCAST(kmp_setting_t **, rivals);
     }
 
+    { // Initialize KMP_HW_SUBSET and KMP_PLACE_THREADS
+      // 1st priority
+      kmp_setting_t *kmp_hw_subset = __kmp_stg_find("KMP_HW_SUBSET");
+      // 2nd priority
+      kmp_setting_t *kmp_place_threads = __kmp_stg_find("KMP_PLACE_THREADS");
+
+      // !!! volatile keyword is Intel (R) C Compiler bug CQ49908 workaround.
+      static kmp_setting_t *volatile rivals[3];
+      int i = 0;
+
+      rivals[i++] = kmp_hw_subset;
+      rivals[i++] = kmp_place_threads;
+      rivals[i++] = NULL;
+
+      kmp_hw_subset->data = (void *)&rivals;
+      kmp_place_threads->data = (void *)&rivals;
+    }
+
 #if KMP_AFFINITY_SUPPORTED
     { // Initialize KMP_AFFINITY, GOMP_CPU_AFFINITY, and OMP_PROC_BIND data.
       kmp_setting_t *kmp_affinity =


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38292.116703.patch
Type: text/x-patch
Size: 1636 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20170926/6eb547e9/attachment.bin>


More information about the Openmp-commits mailing list