[OpenMP][libomp] Fix stats-gathering for new MSVC sections API
authorJonathan Peyton <jonathan.l.peyton@intel.com>
Mon, 12 Dec 2022 19:25:51 +0000 (13:25 -0600)
committerJonathan Peyton <jonathan.l.peyton@intel.com>
Wed, 18 Jan 2023 17:59:12 +0000 (11:59 -0600)
Differential Revision: https://reviews.llvm.org/D139867

openmp/runtime/src/kmp_dispatch.cpp
openmp/runtime/src/kmp_stats.h

index b9dec59..a6ee844 100644 (file)
@@ -2387,7 +2387,7 @@ thread
 kmp_int32 __kmpc_next_section(ident_t *loc, kmp_int32 gtid,
                               kmp_int32 numberOfSections) {
 
-  KMP_TIME_PARTITIONED_BLOCK(OMP_sections);
+  KMP_TIME_PARTITIONED_BLOCK(OMP_sections_overhead);
 
   kmp_info_t *th = __kmp_threads[gtid];
 #ifdef KMP_DEBUG
@@ -2460,7 +2460,6 @@ kmp_int32 __kmpc_next_section(ident_t *loc, kmp_int32 gtid,
           ompt_dispatch_section, instance);
     }
 #endif
-    KMP_POP_PARTITIONED_TIMER();
   }
 
   return sectionIndex;
@@ -2492,9 +2491,9 @@ void __kmpc_end_sections(ident_t *loc, kmp_int32 gtid) {
           &(task_info->task_data), 0, OMPT_GET_RETURN_ADDRESS(0));
     }
 #endif
-    KMP_POP_PARTITIONED_TIMER();
   }
 
+  KMP_POP_PARTITIONED_TIMER();
   KD_TRACE(100, ("__kmpc_end_sections: T#%d returned\n", gtid));
 }
 
index 113221c..f7f8f5f 100644 (file)
@@ -102,6 +102,7 @@ enum stats_state_e {
   macro(OMP_BARRIER, 0, arg)                                                   \
   macro(OMP_CRITICAL, 0, arg)                                                  \
   macro(OMP_SINGLE, 0, arg)                                                    \
+  macro(OMP_SECTIONS, 0, arg)                                                  \
   macro(OMP_MASTER, 0, arg)                                                    \
   macro(OMP_MASKED, 0, arg)                                                    \
   macro(OMP_TEAMS, 0, arg)                                                     \
@@ -150,6 +151,8 @@ enum stats_state_e {
   macro (OMP_critical, 0, arg)                                                 \
   macro (OMP_critical_wait, 0, arg)                                            \
   macro (OMP_single, 0, arg)                                                   \
+  macro (OMP_sections, 0, arg)                                                 \
+  macro (OMP_sections_overhead, 0, arg)                                        \
   macro (OMP_master, 0, arg)                                                   \
   macro (OMP_masked, 0, arg)                                                   \
   macro (OMP_task_immediate, 0, arg)                                           \