Skip to content

Commit 73bb8d9

Browse files
authored
[OpenMP] Fix child processes to use affinity_none (llvm#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: llvm#91098
1 parent 27a062e commit 73bb8d9

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
@@ -6420,6 +6420,8 @@ void __kmp_env_initialize(char const *string) {
64206420
}
64216421
if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) &&
64226422
(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) {
6423+
if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)
6424+
__kmp_affinity.type = affinity_none;
64236425
if (__kmp_affinity.type == affinity_default) {
64246426
__kmp_affinity.type = affinity_compact;
64256427
__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)