Trace TCharm function calls as bracketed events
authorPhil Miller <mille121@illinois.edu>
Fri, 19 Feb 2010 20:54:22 +0000 (14:54 -0600)
committerPhil Miller <mille121@illinois.edu>
Mon, 22 Feb 2010 21:48:47 +0000 (15:48 -0600)
When not in an optimized build, TCharm calls all store their start
time and the API routine name on the stack. When the call is about to
return, the time span and name are recorded as a bracketed user
event. This supports viewing AMPI calls explicitly in Projections.

src/libs/ck-libs/tcharm/tcharm_impl.h

index 6d299b4cfb5abc9980030a5db407853b83c95613..ba3895c09833f2e7e61ea9256f8a52384360ec53 100644 (file)
@@ -16,6 +16,7 @@ Orion Sky Lawlor, olawlor@acm.org, 11/19/2001
 #include "tcharmc.h"
 #include "cklists.h"
 #include "memory-isomalloc.h"
+#include <string>
 
 class TCharmTraceLibList;
 
@@ -284,10 +285,17 @@ class TCharmAPIRoutine {
        void *callEvent; // The BigSim-level event that called into the library
         int pe;          // in case thread migrates
        #endif
+       #ifndef CMK_OPTIMIZE
+       double startTime;
+       char *name;
+       #endif
 
  public:
        // Entering Charm++ from user code
        TCharmAPIRoutine(const char *routineName, const char *libraryName)
+       #ifndef CMK_OPTIMIZE
+           : startTime(CmiWallTimer()), name(strdup(routineName))
+       #endif
        {
                #ifdef CMK_BLUEGENE_CHARM
                // Start a new event, so we can distinguish between client 
@@ -349,6 +357,11 @@ class TCharmAPIRoutine {
                _TRACE_BG_BEGIN_EXECUTE_NOMSG("user_code", &log, 0);
                if (CmiMyPe() == pe) _TRACE_BG_ADD_BACKWARD_DEP(callEvent);
                #endif
+               #ifndef CMK_OPTIMIZE
+               traceUserSuppliedBracketedNote(name, 0, startTime,
+                                              CmiWallTimer());
+               free(name);
+               #endif
        }
 };