aboutsummaryrefslogtreecommitdiff
path: root/openmp/runtime/src/z_Linux_util.cpp
diff options
context:
space:
mode:
authorKazushi Marukawa <marukawa@nec.com>2023-09-20 17:44:24 +0900
committerGitHub <noreply@github.com>2023-09-20 17:44:24 +0900
commit7b8130c2c38b54e93af6c9aeacd954f2085abd33 (patch)
treea7f73853882861c430dddf5a7d039999dc9664e7 /openmp/runtime/src/z_Linux_util.cpp
parent1446e3cf7605f0988b914fac0a34d63045394ff3 (diff)
downloadllvm-7b8130c2c38b54e93af6c9aeacd954f2085abd33.zip
llvm-7b8130c2c38b54e93af6c9aeacd954f2085abd33.tar.gz
llvm-7b8130c2c38b54e93af6c9aeacd954f2085abd33.tar.bz2
[OpenMP][VE] Limit the number of threads to create (#66729)
VE supports up to 64 threads per a VE process. So, we limit the number of threads defined by KMP_MAX_NTH. We also modify the __kmp_sys_max_nth initialization to use KMP_MAX_NTH as a limit.
Diffstat (limited to 'openmp/runtime/src/z_Linux_util.cpp')
-rw-r--r--openmp/runtime/src/z_Linux_util.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index 42488eb..478c09b 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -1894,6 +1894,13 @@ void __kmp_runtime_initialize(void) {
/* Query the maximum number of threads */
__kmp_type_convert(sysconf(_SC_THREAD_THREADS_MAX), &(__kmp_sys_max_nth));
+#ifdef __ve__
+ if (__kmp_sys_max_nth == -1) {
+ // VE's pthread supports only up to 64 threads per a VE process.
+ // So we use that KMP_MAX_NTH (predefined as 64) here.
+ __kmp_sys_max_nth = KMP_MAX_NTH;
+ }
+#else
if (__kmp_sys_max_nth == -1) {
/* Unlimited threads for NPTL */
__kmp_sys_max_nth = INT_MAX;
@@ -1901,6 +1908,7 @@ void __kmp_runtime_initialize(void) {
/* Can't tell, just use PTHREAD_THREADS_MAX */
__kmp_sys_max_nth = KMP_MAX_NTH;
}
+#endif
/* Query the minimum stack size */
__kmp_sys_min_stksize = sysconf(_SC_THREAD_STACK_MIN);