git: e2de08bf70f4 - stable/13 - Merge commit 73bb8d9d92f6 from llvm-project (by Jonathan Peyton):

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sat, 11 May 2024 08:57:04 UTC
The branch stable/13 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=e2de08bf70f4343ebcb455dedf1b77ac0d67f5ca

commit e2de08bf70f4343ebcb455dedf1b77ac0d67f5ca
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-05-08 18:44:28 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-05-11 08:56:35 +0000

    Merge commit 73bb8d9d92f6 from llvm-project (by Jonathan Peyton):
    
      [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
    
    This should fix OpenMP processes sometimes getting stuck on a single CPU
    core.
    
    PR:             278845
    Reported by:    Cassidy B. Larson <cbl@cbl.us>
    MFC after:      3 days
    
    (cherry picked from commit 22b3e7898ecdf90887a9536fab5b9a6f7a291723)
---
 contrib/llvm-project/openmp/runtime/src/kmp_settings.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/contrib/llvm-project/openmp/runtime/src/kmp_settings.cpp b/contrib/llvm-project/openmp/runtime/src/kmp_settings.cpp
index ec86ee07472c..58f19ea5b8ab 100644
--- a/contrib/llvm-project/openmp/runtime/src/kmp_settings.cpp
+++ b/contrib/llvm-project/openmp/runtime/src/kmp_settings.cpp
@@ -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;