[Openmp-commits] [openmp] r262656 - [STATS] fix master and single timers

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Thu Mar 3 13:21:05 PST 2016


Author: jlpeyton
Date: Thu Mar  3 15:21:05 2016
New Revision: 262656

URL: http://llvm.org/viewvc/llvm-project?rev=262656&view=rev
Log:
[STATS] fix master and single timers

Only the thread which executes the single/master section will update its statistics.

Modified:
    openmp/trunk/runtime/src/kmp_csupport.c

Modified: openmp/trunk/runtime/src/kmp_csupport.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_csupport.c?rev=262656&r1=262655&r2=262656&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_csupport.c (original)
+++ openmp/trunk/runtime/src/kmp_csupport.c Thu Mar  3 15:21:05 2016
@@ -732,7 +732,6 @@ __kmpc_barrier(ident_t *loc, kmp_int32 g
 kmp_int32
 __kmpc_master(ident_t *loc, kmp_int32 global_tid)
 {
-    KMP_COUNT_BLOCK(OMP_MASTER);
     int status = 0;
 
     KC_TRACE( 10, ("__kmpc_master: called T#%d\n", global_tid ) );
@@ -741,6 +740,7 @@ __kmpc_master(ident_t *loc, kmp_int32 gl
         __kmp_parallel_initialize();
 
     if( KMP_MASTER_GTID( global_tid )) {
+        KMP_COUNT_BLOCK(OMP_MASTER);
         KMP_START_EXPLICIT_TIMER(OMP_master);
         status = 1;
     }
@@ -1476,9 +1476,11 @@ introduce an explicit barrier if it is r
 kmp_int32
 __kmpc_single(ident_t *loc, kmp_int32 global_tid)
 {
-    KMP_COUNT_BLOCK(OMP_SINGLE);
     kmp_int32 rc = __kmp_enter_single( global_tid, loc, TRUE );
-    if(rc == TRUE) {
+
+    if (rc) {
+        // We are going to execute the single statement, so we should count it.
+        KMP_COUNT_BLOCK(OMP_SINGLE);
         KMP_START_EXPLICIT_TIMER(OMP_single);
     }
 




More information about the Openmp-commits mailing list