summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Peyton <jonathan.l.peyton@intel.com>2019-08-20 19:39:17 +0000
committerJonathan Peyton <jonathan.l.peyton@intel.com>2019-08-20 19:39:17 +0000
commit57ae6b8e377c8af41c9a017fe9b7c7f4b2fc04f7 (patch)
treef5b02f00bfed091c60e42f59a2bf7781960e8d89
parentc310e5a7ab6c7606f2c9ef0d7b0efae8a5568efe (diff)
downloadbcm5719-llvm-57ae6b8e377c8af41c9a017fe9b7c7f4b2fc04f7.tar.gz
bcm5719-llvm-57ae6b8e377c8af41c9a017fe9b7c7f4b2fc04f7.zip
Force honoring nthreads-var and thread-limit-var inside teams construct on host
This patch fixes https://bugs.llvm.org/show_bug.cgi?id=42906, via adding adjustment of number of threads on enter to the teams construct on host according to user settings. This allows to pass checks and avoid assertions at time of team of threads creation. Patch by Andrey Churbanov Differential Revision: https://reviews.llvm.org/D66351 llvm-svn: 369430
-rw-r--r--openmp/runtime/src/kmp_runtime.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp
index cf4e23a618b..82d4c26c0e2 100644
--- a/openmp/runtime/src/kmp_runtime.cpp
+++ b/openmp/runtime/src/kmp_runtime.cpp
@@ -7192,19 +7192,32 @@ void __kmp_push_num_teams(ident_t *id, int gtid, int num_teams,
thr->th.th_set_nproc = thr->th.th_teams_size.nteams = num_teams;
// Remember the number of threads for inner parallel regions
+ if (!TCR_4(__kmp_init_middle))
+ __kmp_middle_initialize(); // get internal globals calculated
+ KMP_DEBUG_ASSERT(__kmp_avail_proc);
+ KMP_DEBUG_ASSERT(__kmp_dflt_team_nth);
if (num_threads == 0) {
- if (!TCR_4(__kmp_init_middle))
- __kmp_middle_initialize(); // get __kmp_avail_proc calculated
num_threads = __kmp_avail_proc / num_teams;
+ // adjust num_threads w/o warning as it is not user setting
+ // num_threads = min(num_threads, nthreads-var, thread-limit-var)
+ // no thread_limit clause specified - do not change thread-limit-var ICV
+ if (num_threads > __kmp_dflt_team_nth) {
+ num_threads = __kmp_dflt_team_nth; // honor nthreads-var ICV
+ }
+ if (num_threads > thr->th.th_current_task->td_icvs.thread_limit) {
+ num_threads = thr->th.th_current_task->td_icvs.thread_limit;
+ } // prevent team size to exceed thread-limit-var
if (num_teams * num_threads > __kmp_teams_max_nth) {
- // adjust num_threads w/o warning as it is not user setting
num_threads = __kmp_teams_max_nth / num_teams;
}
} else {
// This thread will be the master of the league masters
// Store new thread limit; old limit is saved in th_cg_roots list
thr->th.th_current_task->td_icvs.thread_limit = num_threads;
-
+ // num_threads = min(num_threads, nthreads-var)
+ if (num_threads > __kmp_dflt_team_nth) {
+ num_threads = __kmp_dflt_team_nth; // honor nthreads-var ICV
+ }
if (num_teams * num_threads > __kmp_teams_max_nth) {
int new_threads = __kmp_teams_max_nth / num_teams;
if (!__kmp_reserve_warn) { // user asked for too many threads
OpenPOWER on IntegriCloud