Skip to content

Commit

Permalink
[OpenMP] Fix child processes to use affinity_none (llvm#91391)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jpeyton52 authored May 8, 2024
1 parent 27a062e commit 73bb8d9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions openmp/runtime/src/kmp_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6420,6 +6420,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;
Expand Down
1 change: 1 addition & 0 deletions openmp/runtime/test/affinity/redetect.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %libomp-compile
// RUN: %libomp-run
// RUN: env KMP_AFFINITY=none %libomp-run
// REQUIRES: linux

Expand Down

0 comments on commit 73bb8d9

Please sign in to comment.