From 4720bb4a5c0459489f6db99e4f4ba5eee84d5404 Mon Sep 17 00:00:00 2001 From: Jonathan Peyton <jonathan.l.peyton@intel.com> Date: Fri, 1 Jul 2016 17:37:49 +0000 Subject: [PATCH] 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 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@274369 91177308-0d34-0410-b5e6-96231b3b80d8 --- runtime/src/kmp_runtime.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/runtime/src/kmp_runtime.c b/runtime/src/kmp_runtime.c index 55d080b..71c80c3 100644 --- a/runtime/src/kmp_runtime.c +++ b/runtime/src/kmp_runtime.c @@ -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 -- GitLab