Skip to content

Commit 09615ce

Browse files
jpeyton52tstellar
authored andcommitted
[OpenMP] Fix child processes to use affinity_none (#91391)
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 73bb8d9)
1 parent 5c77c1d commit 09615ce

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

openmp/runtime/src/kmp_settings.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6426,6 +6426,8 @@ void __kmp_env_initialize(char const *string) {
64266426
}
64276427
if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
64286428
(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
6429+
if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)
6430+
__kmp_affinity.type = affinity_none;
64296431
if (__kmp_affinity.type == affinity_default) {
64306432
__kmp_affinity.type = affinity_compact;
64316433
__kmp_affinity.flags.dups = FALSE;

openmp/runtime/test/affinity/redetect.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %libomp-compile
2+
// RUN: %libomp-run
23
// RUN: env KMP_AFFINITY=none %libomp-run
34
// REQUIRES: linux
45

0 commit comments

Comments
 (0)