[OpenMP] Fix child processes to use affinity_none (#91391)
authorJonathan Peyton <jonathan.l.peyton@intel.com>
Wed, 8 May 2024 14:23:50 +0000 (09:23 -0500)
committerTom Stellard <tstellar@redhat.com>
Fri, 10 May 2024 20:56:18 +0000 (13:56 -0700)
When a child process is forked with OpenMP already initialized, the
child process resets its affinity mask and sets proc-bind-var to false
so that the entire original affinity mask is used. This patch corrects
an issue with the affinity initialization code setting affinity to
compact instead of none for this special case of forked children.

The test trying to catch this only testing explicit setting of
KMP_AFFINITY=none. Add test run for no KMP_AFFINITY setting.

Fixes: #91098
(cherry picked from commit 73bb8d9d92f689863c94d48517e89d35dae0ebcf)

openmp/runtime/src/kmp_settings.cpp
openmp/runtime/test/affinity/redetect.c

index ec86ee07472c1e3aca605fd296b7e30703c33398..58f19ea5b8ab71ce1983c0ccf6f1612c687f3c2b 100644 (file)
@@ -6426,6 +6426,8 @@ void __kmp_env_initialize(char const *string) {
         }
         if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
             (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
+          if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)
+            __kmp_affinity.type = affinity_none;
           if (__kmp_affinity.type == affinity_default) {
             __kmp_affinity.type = affinity_compact;
             __kmp_affinity.flags.dups = FALSE;
index dba83b72cc42e50552071574a9744cafe3622d49..4b96d1bd92ee7695e93d00b0241e302b07616a8b 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: %libomp-compile
+// RUN: %libomp-run
 // RUN: env KMP_AFFINITY=none %libomp-run
 // REQUIRES: linux