aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXing Xue <xingxue@outlook.com>2024-02-16 15:12:41 -0500
committerTom Stellard <tstellar@redhat.com>2024-02-19 16:14:44 -0800
commitae276000164a41a8fc814bf1d4eccf31347c88f5 (patch)
tree080f2185d710f75314f6d33a1fff6a97a32a9003
parentb27f0b4fae68fea5c2468bc080e31bcecfb7faa7 (diff)
downloadllvm-ae276000164a41a8fc814bf1d4eccf31347c88f5.zip
llvm-ae276000164a41a8fc814bf1d4eccf31347c88f5.tar.gz
llvm-ae276000164a41a8fc814bf1d4eccf31347c88f5.tar.bz2
[OpenMP][AIX] Set worker stack size to 2 x KMP_DEFAULT_STKSIZE if system stack size is too big (#81996)
This patch sets the stack size of worker threads to `2 x KMP_DEFAULT_STKSIZE` (2 x 4MB) for AIX if the system stack size is too big. Also defines maximum stack size for 32-bit AIX. (cherry picked from commit 2de269a641e4ffbb7a44e559c4c0a91bb66df823)
-rw-r--r--openmp/runtime/src/kmp.h4
-rw-r--r--openmp/runtime/src/kmp_settings.cpp5
2 files changed, 9 insertions, 0 deletions
diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index b147063..259c57b 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -1181,7 +1181,11 @@ extern void __kmp_init_target_task();
#define KMP_MIN_STKSIZE ((size_t)(32 * 1024))
#endif
+#if KMP_OS_AIX && KMP_ARCH_PPC
+#define KMP_MAX_STKSIZE 0x10000000 /* 256Mb max size on 32-bit AIX */
+#else
#define KMP_MAX_STKSIZE (~((size_t)1 << ((sizeof(size_t) * (1 << 3)) - 1)))
+#endif
#if KMP_ARCH_X86
#define KMP_DEFAULT_STKSIZE ((size_t)(2 * 1024 * 1024))
diff --git a/openmp/runtime/src/kmp_settings.cpp b/openmp/runtime/src/kmp_settings.cpp
index d2157b1..ec86ee0 100644
--- a/openmp/runtime/src/kmp_settings.cpp
+++ b/openmp/runtime/src/kmp_settings.cpp
@@ -255,8 +255,13 @@ static void __kmp_stg_parse_bool(char const *name, char const *value,
// placed here in order to use __kmp_round4k static function
void __kmp_check_stksize(size_t *val) {
// if system stack size is too big then limit the size for worker threads
+#if KMP_OS_AIX
+ if (*val > KMP_DEFAULT_STKSIZE * 2) // Use 2 times, 16 is too large for AIX.
+ *val = KMP_DEFAULT_STKSIZE * 2;
+#else
if (*val > KMP_DEFAULT_STKSIZE * 16) // just a heuristics...
*val = KMP_DEFAULT_STKSIZE * 16;
+#endif
if (*val < __kmp_sys_min_stksize)
*val = __kmp_sys_min_stksize;
if (*val > KMP_MAX_STKSIZE)