Skip to content

Commit ae27600

Browse files
xingxue-ibmtstellar
authored andcommitted
[OpenMP][AIX] Set worker stack size to 2 x KMP_DEFAULT_STKSIZE if system stack size is too big (llvm#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 2de269a)
1 parent b27f0b4 commit ae27600

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

openmp/runtime/src/kmp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,11 @@ extern void __kmp_init_target_task();
11811181
#define KMP_MIN_STKSIZE ((size_t)(32 * 1024))
11821182
#endif
11831183

1184+
#if KMP_OS_AIX && KMP_ARCH_PPC
1185+
#define KMP_MAX_STKSIZE 0x10000000 /* 256Mb max size on 32-bit AIX */
1186+
#else
11841187
#define KMP_MAX_STKSIZE (~((size_t)1 << ((sizeof(size_t) * (1 << 3)) - 1)))
1188+
#endif
11851189

11861190
#if KMP_ARCH_X86
11871191
#define KMP_DEFAULT_STKSIZE ((size_t)(2 * 1024 * 1024))

openmp/runtime/src/kmp_settings.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,13 @@ static void __kmp_stg_parse_bool(char const *name, char const *value,
255255
// placed here in order to use __kmp_round4k static function
256256
void __kmp_check_stksize(size_t *val) {
257257
// if system stack size is too big then limit the size for worker threads
258+
#if KMP_OS_AIX
259+
if (*val > KMP_DEFAULT_STKSIZE * 2) // Use 2 times, 16 is too large for AIX.
260+
*val = KMP_DEFAULT_STKSIZE * 2;
261+
#else
258262
if (*val > KMP_DEFAULT_STKSIZE * 16) // just a heuristics...
259263
*val = KMP_DEFAULT_STKSIZE * 16;
264+
#endif
260265
if (*val < __kmp_sys_min_stksize)
261266
*val = __kmp_sys_min_stksize;
262267
if (*val > KMP_MAX_STKSIZE)

0 commit comments

Comments
 (0)