add API to pass application annotation time to tracing framework
[charm.git] / src / ck-perf / trace-common.C
index aef97798a548b8e396bbb62df6bdf7580e920ec1..94a0ba9ae46007a15773e97b53b34689991d9de3 100644 (file)
@@ -43,6 +43,7 @@ CkpvDeclare(char*, partitionRoot);
 CkpvDeclare(int, traceRootBaseLength);
 CkpvDeclare(char*, selective);
 CkpvDeclare(bool, verbose);
+CkpvDeclare(double, startUsefulWorkTimer);
 
 typedef void (*mTFP)();                   // function pointer for
 CpvStaticDeclare(mTFP, machineTraceFuncPtr);    // machine user event
@@ -62,6 +63,8 @@ static void traceCommonInit(char **argv)
   CkpvAccess(traceInitTime) = CmiStartTimer();
   CkpvInitialize(double, traceInitCpuTime);
   CkpvAccess(traceInitCpuTime) = TRACE_CPUTIMER();
+  CkpvInitialize(double, startUsefulWorkTimer);
+  CkpvAccess(startUsefulWorkTimer) = TRACE_CPUTIMER();
   CpvInitialize(int, traceOn);
   CpvAccess(traceOn) = 0;
   CpvInitialize(int, _traceCoreOn); //projector
@@ -70,7 +73,6 @@ static void traceCommonInit(char **argv)
   CpvAccess(machineTraceFuncPtr) = NULL;
   CkpvInitialize(int, traceOnPe);
   CkpvAccess(traceOnPe) = 1;
-
   CkpvInitialize(bool, verbose);
   if (CmiGetArgFlag(argv, "+traceWarn")) {
     CkpvAccess(verbose) = true;
@@ -475,6 +477,25 @@ void traceUserEvent(int e)
 #endif
 }
 
+extern "C" 
+void traceStartUsefulWork()
+{
+#if CMK_TRACE_ENABLED
+    CkpvAccess(startUsefulWorkTimer) = TraceTimer();
+#endif
+}
+
+extern "C" 
+void traceStopUsefulWork()
+{
+#if CMK_TRACE_ENABLED
+    if (CpvAccess(traceOn) && CkpvAccess(_traces))
+    {
+        CkpvAccess(_traces)->appWork(1, CkpvAccess(startUsefulWorkTimer), TraceTimer());
+    }
+#endif
+}
+
 extern "C"
 void traceUserBracketEvent(int e, double beginT, double endT)
 {