diff options
author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2016-05-26 19:09:46 +0000 |
---|---|---|
committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2016-05-26 19:09:46 +0000 |
commit | 7ba9baef6ddaa537de83da4e85bf3efc588fb1d7 (patch) | |
tree | 4fe49c09b8e272c3c6863d17fc4080f8257b25c1 | |
parent | 30c080a0854ea37c78b017167f78860b10bf5073 (diff) | |
download | bcm5719-llvm-7ba9baef6ddaa537de83da4e85bf3efc588fb1d7.tar.gz bcm5719-llvm-7ba9baef6ddaa537de83da4e85bf3efc588fb1d7.zip |
Fix for OMP_PROC_BIND=spread strategy
The OMP_PROC_BIND=spread strategy fails to assign the master thread the
correct place partition after the first parallel region. Other threads in the
hot team will remember their place_partition, but the master's place partition
is restored to what it was before entering the parallel region. So when the hot
team is used for subsequent parallel regions, the master has lost this info.
This fix calls __kmp_partition_places to update only the master thread's place
partition in the spread case when there are no other changes to the hot team.
Patch by Terry Wilmarth
Differential Revision: http://reviews.llvm.org/D20539
llvm-svn: 270890
-rw-r--r-- | openmp/runtime/src/kmp_runtime.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/openmp/runtime/src/kmp_runtime.c b/openmp/runtime/src/kmp_runtime.c index 72ecd7ee6ec..48aaea419b4 100644 --- a/openmp/runtime/src/kmp_runtime.c +++ b/openmp/runtime/src/kmp_runtime.c @@ -70,7 +70,7 @@ void __kmp_cleanup( void ); static void __kmp_initialize_info( kmp_info_t *, kmp_team_t *, int tid, int gtid ); static void __kmp_initialize_team( kmp_team_t * team, int new_nproc, kmp_internal_control_t * new_icvs, ident_t * loc ); #if OMP_40_ENABLED && KMP_AFFINITY_SUPPORTED -static void __kmp_partition_places( kmp_team_t *team ); +static void __kmp_partition_places( kmp_team_t *team, int update_master_only=0 ); #endif static void __kmp_do_serial_initialize( void ); void __kmp_fork_barrier( int gtid, int tid ); @@ -4438,7 +4438,7 @@ __kmp_set_thread_affinity_mask_full_tmp( kmp_affin_mask_t *old_mask ) // The master thread's partition should already include its current binding. // static void -__kmp_partition_places( kmp_team_t *team ) +__kmp_partition_places( kmp_team_t *team, int update_master_only ) { // // Copy the master thread's place partion to the team struct @@ -4584,6 +4584,7 @@ __kmp_partition_places( kmp_team_t *team ) int f; int n_th = team->t.t_nproc; int n_places; + int thidx; if ( first_place <= last_place ) { n_places = last_place - first_place + 1; } @@ -4597,7 +4598,10 @@ __kmp_partition_places( kmp_team_t *team ) rem = n_places - n_th*S; gap = rem ? n_th/rem : 1; gap_ct = gap; - for ( f = 0; f < n_th; f++ ) { + thidx = n_th; + if (update_master_only == 1) + thidx = 1; + for ( f = 0; f < thidx; f++ ) { kmp_info_t *th = team->t.t_threads[f]; KMP_DEBUG_ASSERT( th != NULL ); @@ -4657,7 +4661,10 @@ __kmp_partition_places( kmp_team_t *team ) gap = rem > 0 ? n_places/rem : n_places; int place = masters_place; int gap_ct = gap; - for ( f = 0; f < n_th; f++ ) { + thidx = n_th; + if (update_master_only == 1) + thidx = 1; + for ( f = 0; f < thidx; f++ ) { kmp_info_t *th = team->t.t_threads[f]; KMP_DEBUG_ASSERT( th != NULL ); @@ -4804,6 +4811,9 @@ __kmp_allocate_team( kmp_root_t *root, int new_nproc, int max_nproc, # if KMP_AFFINITY_SUPPORTED if ( ( team->t.t_size_changed == 0 ) && ( team->t.t_proc_bind == new_proc_bind ) ) { + if (new_proc_bind == proc_bind_spread) { + __kmp_partition_places(team, 1); // add flag to update only master for spread + } KA_TRACE( 200, ("__kmp_allocate_team: reusing hot team #%d bindings: proc_bind = %d, partition = [%d,%d]\n", team->t.t_id, new_proc_bind, team->t.t_first_place, team->t.t_last_place ) ); |