[Openmp-commits] [openmp] r227198 - Fixed implementation of the teams construct in case it contains parallel regions with different number of threads.
Andrey Churbanov
Andrey.Churbanov at intel.com
Tue Jan 27 08:50:31 PST 2015
Author: achurbanov
Date: Tue Jan 27 10:50:31 2015
New Revision: 227198
URL: http://llvm.org/viewvc/llvm-project?rev=227198&view=rev
Log:
Fixed implementation of the teams construct in case it contains parallel regions with different number of threads.
Modified:
openmp/trunk/runtime/src/kmp_barrier.cpp
openmp/trunk/runtime/src/kmp_runtime.c
Modified: openmp/trunk/runtime/src/kmp_barrier.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_barrier.cpp?rev=227198&r1=227197&r2=227198&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_barrier.cpp (original)
+++ openmp/trunk/runtime/src/kmp_barrier.cpp Tue Jan 27 10:50:31 2015
@@ -734,7 +734,11 @@ __kmp_hierarchical_barrier_gather(enum b
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 b
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
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.
Modified: openmp/trunk/runtime/src/kmp_runtime.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_runtime.c?rev=227198&r1=227197&r2=227198&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_runtime.c (original)
+++ openmp/trunk/runtime/src/kmp_runtime.c Tue Jan 27 10:50:31 2015
@@ -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;
}
More information about the Openmp-commits
mailing list