Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpenMP][VE] Limit the number of threads to create #66729

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions openmp/runtime/src/kmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1153,8 +1153,15 @@ extern void __kmp_init_target_task();
#if defined(PTHREAD_THREADS_MAX) && PTHREAD_THREADS_MAX < INT_MAX
#define KMP_MAX_NTH PTHREAD_THREADS_MAX
#else
#ifdef __ve__
// VE's pthread supports only up to 64 threads per a VE process.
// Please check p. 14 of following documentation for more details.
// https://sxauroratsubasa.sakura.ne.jp/documents/veos/en/VEOS_high_level_design.pdf
#define KMP_MAX_NTH 64
#else
#define KMP_MAX_NTH INT_MAX
#endif
#endif
#endif /* KMP_MAX_NTH */

#ifdef PTHREAD_STACK_MIN
Expand Down
8 changes: 8 additions & 0 deletions openmp/runtime/src/z_Linux_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1894,13 +1894,21 @@ 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;
} else if (__kmp_sys_max_nth <= 1) {
/* 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);
Expand Down