00001 #include "charm++.h"
00002 #include "trace-simple.h"
00003 #include "trace-simpleBOC.h"
00004
00005
00006 CkpvStaticDeclare(TraceSimple*, _trace);
00007
00008
00009
00010 CkGroupID traceSimpleGID;
00011
00016 void _createTracesimple(char **argv)
00017 {
00018 CkpvInitialize(TraceSimple*, _trace);
00019 CkpvAccess(_trace) = new TraceSimple(argv);
00020 CkpvAccess(_traces)->addTrace(CkpvAccess(_trace));
00021 }
00022
00023 TraceSimple::TraceSimple(char **argv)
00024 {
00025 if (CkpvAccess(traceOnPe) == 0) return;
00026
00027
00028 CmiGetArgIntDesc(argv,"+SimplePar0", &par0, "Fake integer parameter 0");
00029 CmiGetArgDoubleDesc(argv,"+SimplePar1", &par1, "Fake double parameter 1");
00030 }
00031
00032 void TraceSimple::userEvent(int eventID)
00033 {
00034 CkPrintf("[%d] User Point Event id %d encountered\n", CkMyPe(), eventID);
00035 }
00036
00037 void TraceSimple::userBracketEvent(int eventID, double bt, double et) {
00038 CkPrintf("[%d] User Bracket Event id %d encountered\n", CkMyPe(), eventID);
00039 }
00040
00041 void TraceSimple::creation(envelope *, int epIdx, int num) {
00042 CkPrintf("[%d] Point-to-Point Message for Entry Method id %d sent\n",
00043 CkMyPe(), epIdx);
00044 }
00045
00046 void TraceSimple::creationMulticast(envelope *, int epIdx, int num,
00047 const int *pelist) {
00048 CkPrintf("[%d] Multicast Message for Entry Method id %d sent to %d pes\n",
00049 CkMyPe(), epIdx, num);
00050 }
00051
00052 void TraceSimple::creationDone(int num) {
00053 CkPrintf("[%d] Last initiated send completes\n", CkMyPe());
00054 }
00055
00056 void TraceSimple::messageRecv(char *env, int pe) {
00057 CkPrintf("[%d] Message from pe %d received by scheduler\n",
00058 CkMyPe(), pe);
00059 }
00060
00061 void TraceSimple::beginExecute(CmiObjId *tid)
00062 {
00063
00064
00065
00066 CkPrintf("[%d] Entry Method invoked using object id\n", CkMyPe());
00067 }
00068
00069 void TraceSimple::beginExecute(envelope *e, void *obj)
00070 {
00071
00072 if (e == NULL) {
00073 CkPrintf("[%d] Entry Method invoked via thread id %d\n", CkMyPe(),
00074 _threadEP);
00075
00076
00077 } else {
00078 CkPrintf("[%d] Entry Method %d invoked via message envelope\n",
00079 CkMyPe(), e->getEpIdx());
00080
00081
00082 }
00083 }
00084
00085 void TraceSimple::beginExecute(int event,int msgType,int ep,int srcPe,
00086 int mlen, CmiObjId *idx, void *obj)
00087 {
00088 CkPrintf("[%d] Entry Method %d invoked by parameters\n", CkMyPe(),
00089 ep);
00090 }
00091
00092 void TraceSimple::endExecute(void)
00093 {
00094 CkPrintf("[%d] Previously executing Entry Method completes\n", CkMyPe());
00095 }
00096
00097 void TraceSimple::beginIdle(double curWallTime) {
00098 CkPrintf("[%d] Scheduler has no useful user-work\n", CkMyPe());
00099 }
00100
00101 void TraceSimple::endIdle(double curWallTime) {
00102 CkPrintf("[%d] Scheduler now has useful user-work\n", CkMyPe());
00103 }
00104
00105 void TraceSimple::beginComputation(void)
00106 {
00107 CkPrintf("[%d] Computation Begins\n", CkMyPe());
00108
00109
00110
00111 }
00112
00113 void TraceSimple::endComputation(void)
00114 {
00115 CkPrintf("[%d] Computation Ends\n", CkMyPe());
00116 }
00117
00118 void TraceSimple::malloc(void *where, int size, void **stack, int stackSize)
00119 {
00120 CkPrintf("[%d] Memory allocation of size %d occurred\n", CkMyPe(), size);
00121 }
00122
00123 void TraceSimple::free(void *where, int size) {
00124 CkPrintf("[%d] %d-byte Memory block freed\n", CkMyPe(), size);
00125 }
00126
00127 void TraceSimple::traceClose(void)
00128 {
00129 CkpvAccess(_trace)->endComputation();
00130
00131 CkpvAccess(_traces)->removeTrace(this);
00132 }
00133
00134 extern "C" void traceSimpleExitFunction() {
00135 CkContinueExit();
00136 }
00137
00138
00139 void initTraceSimpleBOC() {
00140 #ifdef __BIGSIM__
00141 if (BgNodeRank()==0) {
00142 #else
00143 if (CkMyRank() == 0) {
00144 #endif
00145 registerExitFn(traceSimpleExitFunction);
00146 }
00147 }
00148
00149 #include "TraceSimple.def.h"
00150
00151