diff options
author | Andrey Churbanov <Andrey.Churbanov@intel.com> | 2015-01-27 16:50:31 +0000 |
---|---|---|
committer | Andrey Churbanov <Andrey.Churbanov@intel.com> | 2015-01-27 16:50:31 +0000 |
commit | 42a79217a85cbd0c968ff80123e9202dc1849a01 (patch) | |
tree | 874a6796161eff318b2f55fd86590f5fd95dd4c5 /openmp/runtime/src | |
parent | 086cbc37ad6603458040c2d28af122cf6c52b818 (diff) | |
download | bcm5719-llvm-42a79217a85cbd0c968ff80123e9202dc1849a01.tar.gz bcm5719-llvm-42a79217a85cbd0c968ff80123e9202dc1849a01.zip |
Fixed implementation of the teams construct in case it contains parallel regions with different number of threads.
llvm-svn: 227198
Diffstat (limited to 'openmp/runtime/src')
-rw-r--r-- | openmp/runtime/src/kmp_barrier.cpp | 20 | ||||
-rw-r--r-- | openmp/runtime/src/kmp_runtime.c | 5 |
2 files changed, 19 insertions, 6 deletions
diff --git a/openmp/runtime/src/kmp_barrier.cpp b/openmp/runtime/src/kmp_barrier.cpp index dc1d0ec8760..d300af05db3 100644 --- a/openmp/runtime/src/kmp_barrier.cpp +++ b/openmp/runtime/src/kmp_barrier.cpp @@ -734,7 +734,11 @@ __kmp_hierarchical_barrier_gather(enum barrier_type bt, kmp_info_t *this_thr, register kmp_info_t **other_threads = team->t.t_threads; register kmp_uint64 new_state; - if (this_thr->th.th_team->t.t_level == 1) thr_bar->use_oncore_barrier = 1; + int level = team->t.t_level; + if (other_threads[0]->th.th_teams_microtask) // are we inside the teams construct? + if (this_thr->th.th_teams_size.nteams > 1) + ++level; // level was not increased in teams construct for team_of_masters + if (level == 1) thr_bar->use_oncore_barrier = 1; else thr_bar->use_oncore_barrier = 0; // Do not use oncore barrier when nested KA_TRACE(20, ("__kmp_hierarchical_barrier_gather: T#%d(%d:%d) enter for barrier type %d\n", @@ -834,9 +838,6 @@ __kmp_hierarchical_barrier_gather(enum barrier_type bt, kmp_info_t *this_thr, KA_TRACE(20, ("__kmp_hierarchical_barrier_gather: T#%d(%d:%d) set team %d arrived(%p) = %u\n", gtid, team->t.t_id, tid, team->t.t_id, &team->t.t_bar[bt].b_arrived, team->t.t_bar[bt].b_arrived)); } - // If nested, but outer level is top-level, resume use of oncore optimization - if (this_thr->th.th_team->t.t_level <=2) thr_bar->use_oncore_barrier = 1; - else thr_bar->use_oncore_barrier = 0; // Is the team access below unsafe or just technically invalid? KA_TRACE(20, ("__kmp_hierarchical_barrier_gather: T#%d(%d:%d) exit for barrier type %d\n", gtid, team->t.t_id, tid, bt)); @@ -899,8 +900,15 @@ __kmp_hierarchical_barrier_release(enum barrier_type bt, kmp_info_t *this_thr, i KMP_MB(); // Flush all pending memory write invalidates. } - if (this_thr->th.th_team->t.t_level <= 1) thr_bar->use_oncore_barrier = 1; - else thr_bar->use_oncore_barrier = 0; + int level = team->t.t_level; + if (team->t.t_threads[0]->th.th_teams_microtask ) { // are we inside the teams construct? + if (team->t.t_pkfn != (microtask_t)__kmp_teams_master && this_thr->th.th_teams_level == level) + ++level; // level was not increased in teams construct for team_of_workers + if( this_thr->th.th_teams_size.nteams > 1 ) + ++level; // level was not increased in teams construct for team_of_masters + } + if (level == 1) thr_bar->use_oncore_barrier = 1; + else thr_bar->use_oncore_barrier = 0; // Do not use oncore barrier when nested nproc = this_thr->th.th_team_nproc; // If the team size has increased, we still communicate with old leaves via oncore barrier. diff --git a/openmp/runtime/src/kmp_runtime.c b/openmp/runtime/src/kmp_runtime.c index 7d8554ed2e3..dd53dcd19b8 100644 --- a/openmp/runtime/src/kmp_runtime.c +++ b/openmp/runtime/src/kmp_runtime.c @@ -2046,7 +2046,12 @@ __kmp_join_call(ident_t *loc, int gtid int old_num = master_th->th.th_team_nproc; int new_num = master_th->th.th_teams_size.nth; kmp_info_t **other_threads = team->t.t_threads; + kmp_task_team_t * task_team = master_th->th.th_task_team; team->t.t_nproc = new_num; + if ( task_team ) { // task team might have lesser value of counters + task_team->tt.tt_ref_ct = new_num - 1; + task_team->tt.tt_unfinished_threads = new_num; + } for ( i = 0; i < old_num; ++i ) { other_threads[i]->th.th_team_nproc = new_num; } |