The beginnings of the new control point framework's tracing module.
authorIsaac Dooley <idooley2@illinois.edu>
Wed, 12 Nov 2008 19:29:40 +0000 (19:29 +0000)
committerIsaac Dooley <idooley2@illinois.edu>
Wed, 12 Nov 2008 19:29:40 +0000 (19:29 +0000)
src/ck-perf/trace-controlPoints.C [new file with mode: 0644]
src/ck-perf/trace-controlPoints.ci [new file with mode: 0644]
src/ck-perf/trace-controlPoints.h [new file with mode: 0644]
src/ck-perf/trace-controlPointsBOC.h [new file with mode: 0644]

diff --git a/src/ck-perf/trace-controlPoints.C b/src/ck-perf/trace-controlPoints.C
new file mode 100644 (file)
index 0000000..daa8f69
--- /dev/null
@@ -0,0 +1,156 @@
+#include "charm++.h"
+#include "trace-controlPoints.h"
+#include "trace-controlPointsBOC.h"
+
+// Charm++ "processor"(user thread)-private global variable
+CkpvStaticDeclare(TraceControlPoints*, _trace);
+
+// This global variable is required for any post-execution 
+// parallel analysis or activities the trace module might wish to perform.
+CkGroupID traceControlPointsGID;
+
+/**
+  For each TraceFoo module, _createTraceFoo() must be defined.
+  This function is called in _createTraces() generated in moduleInit.C
+*/
+void _createTracecontrolPoints(char **argv)
+{
+  CkpvInitialize(TraceControlPoints*, _trace);
+  CkpvAccess(_trace) = new TraceControlPoints(argv);
+  CkpvAccess(_traces)->addTrace(CkpvAccess(_trace));
+}
+
+TraceControlPoints::TraceControlPoints(char **argv)
+{
+  if (CkpvAccess(traceOnPe) == 0) return;
+
+  // Process runtime arguments intended for the module
+  // CmiGetArgIntDesc(argv,"+ControlPointsPar0", &par0, "Fake integer parameter 0");
+}
+
+void TraceControlPoints::userEvent(int eventID) 
+{
+  //  CkPrintf("[%d] User Point Event id %d encountered\n", CkMyPe(), eventID);
+}
+
+void TraceControlPoints::userBracketEvent(int eventID, double bt, double et) {
+  //  CkPrintf("[%d] User Bracket Event id %d encountered\n", CkMyPe(), eventID);
+}
+
+void TraceControlPoints::creation(envelope *, int epIdx, int num) {
+  //  CkPrintf("[%d] Point-to-Point Message for Entry Method id %d sent\n",  CkMyPe(), epIdx);
+}
+
+void TraceControlPoints::creationMulticast(envelope *, int epIdx, int num, 
+                                   int *pelist) {
+  //  CkPrintf("[%d] Multicast Message for Entry Method id %d sent to %d pes\n", CkMyPe(), epIdx, num);
+}
+
+void TraceControlPoints::creationDone(int num) {
+  //  CkPrintf("[%d] Last initiated send completes\n", CkMyPe());
+}
+  
+void TraceControlPoints::messageRecv(char *env, int pe) {
+  // CkPrintf("[%d] Message from pe %d received by scheduler\n", CkMyPe(), pe);
+}
+  
+void TraceControlPoints::beginExecute(CmiObjId *tid)
+{
+  // CmiObjId is a 4-integer tuple uniquely identifying a migratable
+  //   Charm++ object. Note that there are other non-migratable Charm++
+  //   objects that CmiObjId will not identify.
+
+  lastBeginExecuteTime = CmiWallTimer();
+  lastbeginMessageSize = -1;
+
+  CkPrintf("[%d] WARNING ignoring TraceControlPoints::beginExecute(CmiObjId *tid)\n", CkMyPe());
+}
+
+void TraceControlPoints::beginExecute(envelope *e)
+{
+  lastBeginExecuteTime = CmiWallTimer();
+  lastbeginMessageSize = e->getTotalsize();
+
+  CkPrintf("[%d] WARNING ignoring TraceControlPoints::beginExecute(envelope *e)\n", CkMyPe());
+
+  // no message means thread execution
+  //  if (e != NULL) {
+  //  CkPrintf("[%d] TraceControlPoints::beginExecute  Method=%d, type=%d, source pe=%d, size=%d\n", 
+  //        CkMyPe(), e->getEpIdx(), e->getMsgtype(), e->getSrcPe(), e->getTotalsize() );
+  //}  
+
+}
+
+void TraceControlPoints::beginExecute(int event,int msgType,int ep,int srcPe, 
+                              int mlen, CmiObjId *idx)
+{
+  lastBeginExecuteTime = CmiWallTimer();
+  lastbeginMessageSize = mlen;
+  //  CkPrintf("[%d] TraceControlPoints::beginExecute event=%d, msgType=%d, ep=%d, srcPe=%d, mlen=%d CmiObjId is also avaliable\n", CkMyPe(), event, msgType, ep, srcPe, mlen);
+}
+
+void TraceControlPoints::endExecute(void)
+{
+  double executionTime = CmiWallTimer() - lastBeginExecuteTime;
+  CkPrintf("[%d] Previously executing Entry Method completes. lastbeginMessageSize=%d executionTime=%lf\n", CkMyPe(), lastbeginMessageSize, executionTime);
+}
+
+void TraceControlPoints::beginIdle(double curWallTime) {
+  // CkPrintf("[%d] Scheduler has no useful user-work\n", CkMyPe());
+}
+
+void TraceControlPoints::endIdle(double curWallTime) {
+  //  CkPrintf("[%d] Scheduler now has useful user-work\n", CkMyPe());
+}
+  
+void TraceControlPoints::beginComputation(void)
+{
+  CkPrintf("[%d] Computation Begins\n", CkMyPe());
+  // Code Below shows what trace-summary would do.
+  // initialze arrays because now the number of entries is known.
+  // _logPool->initMem();
+}
+
+void TraceControlPoints::endComputation(void)
+{
+  //  CkPrintf("[%d] Computation Ends\n", CkMyPe());
+}
+
+void TraceControlPoints::malloc(void *where, int size, void **stack, int stackSize)
+{
+  // CkPrintf("[%d] Memory allocation of size %d occurred\n", CkMyPe(), size);
+}
+
+void TraceControlPoints::free(void *where, int size) {
+  //  CkPrintf("[%d] %d-byte Memory block freed\n", CkMyPe(), size);
+}
+
+void TraceControlPoints::traceClose(void)
+{
+  CkpvAccess(_trace)->endComputation();
+  // remove myself from traceArray so that no tracing will be called.
+  CkpvAccess(_traces)->removeTrace(this);
+}
+
+extern "C" void traceControlPointsExitFunction() {
+  // The exit function of any Charm++ module must call CkExit() or
+  // the entire exit process will hang if multiple modules are linked.
+  // FIXME: This is NOT a feature. Something needs to be done about this.
+  CkExit();
+}
+
+// Initialization of the parallel trace module.
+void initTraceControlPointsBOC() {
+#ifdef __BLUEGENE__
+  if (BgNodeRank()==0) {
+#else
+    if (CkMyRank() == 0) {
+#endif
+      registerExitFn(traceControlPointsExitFunction);
+    }
+}
+
+#include "TraceControlPoints.def.h"
+
+
+/*@}*/
diff --git a/src/ck-perf/trace-controlPoints.ci b/src/ck-perf/trace-controlPoints.ci
new file mode 100644 (file)
index 0000000..08b364c
--- /dev/null
@@ -0,0 +1,15 @@
+module TraceControlPoints {
+
+  mainchare TraceControlPointsInit {
+    entry TraceControlPointsInit(CkArgMsg *m);
+  };
+
+  initnode void initTraceControlPointsBOC();
+  readonly CkGroupID traceControlPointsGID;
+
+  group [migratable] TraceControlPointsBOC {
+    entry TraceControlPointsBOC(void);
+  };
+
+};
+
diff --git a/src/ck-perf/trace-controlPoints.h b/src/ck-perf/trace-controlPoints.h
new file mode 100644 (file)
index 0000000..c3268c7
--- /dev/null
@@ -0,0 +1,72 @@
+#ifndef _VERBOSE_H
+#define _VERBOSE_H
+
+#include <stdio.h>
+#include <errno.h>
+
+#include "trace.h"
+#include "envelope.h"
+#include "register.h"
+#include "trace-common.h"
+
+/**
+ *  TraceControlPoints is a template for an instrumentation module making use of
+ *    the tracing framework hooks provided in Charm++.
+ *
+ *  Only the more common hooks are listened to in this module.
+ */
+class TraceControlPoints : public Trace {
+ public:
+
+  double lastBeginExecuteTime;
+  int lastbeginMessageSize;
+
+ public:
+  TraceControlPoints(char **argv);
+  
+  // a user event has just occured
+  void userEvent(int eventID);
+  // a pair of begin/end user event has just occured
+  void userBracketEvent(int eventID, double bt, double et);
+  
+  // "creation" of message(s) - message Sends
+  void creation(envelope *, int epIdx, int num=1);
+  void creationMulticast(envelope *, int epIdx, int num=1, int *pelist=NULL);
+  void creationDone(int num=1);
+  
+  void messageRecv(char *env, int pe);
+  
+  // **************************************************************
+  // begin/end execution of a Charm++ entry point
+  // NOTE: begin/endPack and begin/endUnpack can be called in between
+  //       a beginExecute and its corresponding endExecute.
+  void beginExecute(envelope *);
+  void beginExecute(CmiObjId *tid);
+  void beginExecute(
+                   int event,   // event type defined in trace-common.h
+                   int msgType, // message type
+                   int ep,      // Charm++ entry point id
+                   int srcPe,   // Which PE originated the call
+                   int ml,      // message size
+                   CmiObjId* idx);    // index
+  void endExecute(void);
+  
+  // begin/end idle time for this pe
+  void beginIdle(double curWallTime);
+  void endIdle(double curWallTime);
+  
+  // begin/end of execution
+  void beginComputation(void);
+  void endComputation(void);
+  
+  /* Memory tracing */
+  void malloc(void *where, int size, void **stack, int stackSize);
+  void free(void *where, int size);
+  
+  // do any clean-up necessary for tracing
+  void traceClose();
+};
+
+#endif
+
+/*@}*/
diff --git a/src/ck-perf/trace-controlPointsBOC.h b/src/ck-perf/trace-controlPointsBOC.h
new file mode 100644 (file)
index 0000000..4c9335b
--- /dev/null
@@ -0,0 +1,31 @@
+#include "TraceControlPoints.decl.h"
+
+extern CkGroupID traceControlPointsGID;
+
+// We typically declare parallel object classes here for the purposes of
+// performing parallel operations for the trace module after the main
+// application has completed execution (and calls CkExit()).
+//
+// TraceControlPointsInit is an initialization class.
+//
+// TraceControlPointsBOC is a one-per-processor object (defined in the .ci file as
+//    a "group" instead of a "chare") which hosts the methods for the
+//    parallel operations. In this case, there are no methods defined.
+//    Otherwise, one may write any Charm++ code here.
+
+class TraceControlPointsInit : public Chare {
+  public:
+  TraceControlPointsInit(CkArgMsg*) {
+    traceControlPointsGID = CProxy_TraceControlPointsBOC::ckNew();
+    CProxy_TraceControlPointsBOC controlPointsProxy(traceControlPointsGID);
+  }
+  TraceControlPointsInit(CkMigrateMessage *m):Chare(m) {}
+};
+
+class TraceControlPointsBOC : public CBase_TraceControlPointsBOC {
+public:
+  TraceControlPointsBOC(void) {};
+  TraceControlPointsBOC(CkMigrateMessage *m) {};
+};
+
+