Improve performance of #pragma omp single

EPCC Performance of single is considerably worse than plain barrier.
Adding a read-only check to the code before the atomic compare-and-store
helps considerably.

Patch by Terry Wilmarth.

Differential Revision: http://reviews.llvm.org/D21893

llvm-svn: 274369
This commit is contained in:
Jonathan Peyton 2016-07-01 17:37:49 +00:00
parent 7b2c997736
commit c1666960f9
1 changed files with 4 additions and 2 deletions

View File

@ -777,8 +777,10 @@ __kmp_enter_single( int gtid, ident_t *id_ref, int push_ws )
single block
*/
/* TODO: Should this be acquire or release? */
status = KMP_COMPARE_AND_STORE_ACQ32(&team->t.t_construct, old_this,
th->th.th_local.this_construct);
if (team->t.t_construct == old_this) {
status = KMP_COMPARE_AND_STORE_ACQ32(&team->t.t_construct, old_this,
th->th.th_local.this_construct);
}
#if USE_ITT_BUILD
if ( __itt_metadata_add_ptr && __kmp_forkjoin_frames_mode == 3 && KMP_MASTER_GTID(gtid) &&
#if OMP_40_ENABLED