00001 #include "charm++.h"
00002 #include "trace-controlPoints.h"
00003 #include "trace-controlPointsBOC.h"
00004
00005
00012
00013 CkpvStaticDeclare(TraceControlPoints*, _trace);
00014
00015
00016
00017
00018 CkGroupID traceControlPointsGID;
00019
00027 void _createTracecontrolPoints(char **argv)
00028 {
00029 CkpvInitialize(TraceControlPoints*, _trace);
00030 CkpvAccess(_trace) = new TraceControlPoints(argv);
00031 CkpvAccess(_traces)->addTrace(CkpvAccess(_trace));
00032 }
00033
00034 TraceControlPoints::TraceControlPoints(char **argv)
00035 {
00036 resetTimings();
00037
00038 nesting_level = 0;
00039
00040 whenStoppedTracing = 0;
00041
00042 b1=0;
00043 b2=0;
00044 b3=0;
00045
00046 if (CkpvAccess(traceOnPe) == 0) return;
00047
00048
00049
00050 }
00051
00052
00053 void TraceControlPoints::traceBegin(void){
00054 if(whenStoppedTracing != 0)
00055 totalUntracedTime += CmiWallTimer() - whenStoppedTracing;
00056 whenStoppedTracing = 0;
00057 CkPrintf("[%d] TraceControlPoints::traceBegin() totalUntracedTime=%f\n", CkMyPe(), totalUntracedTime);
00058 }
00059
00060
00061 void TraceControlPoints::traceEnd(void){
00062 CkPrintf("[%d] TraceControlPoints::traceEnd()\n", CkMyPe());
00063 CkAssert(whenStoppedTracing == 0);
00064 whenStoppedTracing = CmiWallTimer();
00065 }
00066
00067
00068
00069 void TraceControlPoints::userEvent(int eventID)
00070 {
00071
00072 }
00073
00074 void TraceControlPoints::userBracketEvent(int eventID, double bt, double et) {
00075
00076 }
00077
00078 void TraceControlPoints::creation(envelope *, int epIdx, int num) {
00079
00080 }
00081
00082 void TraceControlPoints::creationMulticast(envelope *, int epIdx, int num,
00083 const int *pelist) {
00084
00085 }
00086
00087 void TraceControlPoints::creationDone(int num) {
00088
00089 }
00090
00091 void TraceControlPoints::messageRecv(char *env, int pe) {
00092
00093 }
00094
00095 void TraceControlPoints::beginExecute(CmiObjId *tid)
00096 {
00097 nesting_level++;
00098 if(nesting_level == 1){
00099
00100
00101
00102 b1++;
00103 lastBeginExecuteTime = CmiWallTimer();
00104 lastbeginMessageSize = -1;
00105 }
00106 }
00107
00108
00109
00110 void TraceControlPoints::beginExecute(envelope *e)
00111 {
00112 nesting_level++;
00113 if(nesting_level == 1){
00114 lastBeginExecuteTime = CmiWallTimer();
00115 lastbeginMessageSize = e->getTotalsize();
00116 b2++;
00117 b2mlen += lastbeginMessageSize;
00118 }
00119 }
00120
00121 void TraceControlPoints::beginExecute(int event,int msgType,int ep,int srcPe,
00122 int mlen, CmiObjId *idx)
00123 {
00124 nesting_level++;
00125 if(nesting_level == 1){
00126 b3++;
00127 b3mlen += mlen;
00128 lastBeginExecuteTime = CmiWallTimer();
00129 lastbeginMessageSize = mlen;
00130 }
00131 }
00132
00133 void TraceControlPoints::endExecute(void)
00134 {
00135
00136 nesting_level--;
00137 if(nesting_level == 0){
00138
00139 double executionTime = CmiWallTimer() - lastBeginExecuteTime;
00140 totalEntryMethodTime += executionTime;
00141 totalEntryMethodInvocations ++;
00142
00143 double m = (double)CmiMemoryUsage();
00144 if(memUsage < m){
00145 memUsage = m;
00146 }
00147 }
00148 }
00149
00150 void TraceControlPoints::beginIdle(double curWallTime) {
00151 lastBeginIdle = CmiWallTimer();
00152
00153
00154 double m = (double)CmiMemoryUsage();
00155 if(memUsage < m){
00156 memUsage = m;
00157 }
00158 }
00159
00160 void TraceControlPoints::endIdle(double curWallTime) {
00161 totalIdleTime += CmiWallTimer() - lastBeginIdle;
00162
00163 }
00164
00165 void TraceControlPoints::beginComputation(void)
00166 {
00167 CkPrintf("[%d] TraceControlPoints::beginComputation\n", CkMyPe());
00168
00169
00170
00171 }
00172
00173 void TraceControlPoints::endComputation(void)
00174 {
00175 CkPrintf("[%d] TraceControlPoints::endComputationn", CkMyPe());
00176 }
00177
00178 void TraceControlPoints::malloc(void *where, int size, void **stack, int stackSize)
00179 {
00180
00181 double m = (double)CmiMemoryUsage();
00182 if(memUsage < m){
00183 memUsage = m;
00184 }
00185 }
00186
00187 void TraceControlPoints::free(void *where, int size) {
00188
00189 }
00190
00191 void TraceControlPoints::traceClose(void)
00192 {
00193
00194 CProxy_TraceControlPointsBOC myProxy(traceControlPointsGID);
00195
00196
00197 CkpvAccess(_trace)->endComputation();
00198
00199 CkpvAccess(_traces)->removeTrace(this);
00200 }
00201
00202
00203
00204
00205 void TraceControlPoints::resetTimings(){
00206 totalIdleTime = 0.0;
00207 totalEntryMethodTime = 0.0;
00208 totalEntryMethodInvocations = 0;
00209 lastResetTime = CmiWallTimer();
00210 totalUntracedTime = 0;
00211 if(whenStoppedTracing !=0){
00212 whenStoppedTracing = CmiWallTimer();
00213 }
00214 }
00215
00216 void TraceControlPoints::resetAll(){
00217 totalIdleTime = 0.0;
00218 totalEntryMethodTime = 0.0;
00219 memUsage = 0;
00220 totalEntryMethodInvocations = 0;
00221 b2mlen=0;
00222 b3mlen=0;
00223 b2=0;
00224 b3=0;
00225 lastResetTime = CmiWallTimer();
00226 totalUntracedTime = 0;
00227 if(whenStoppedTracing !=0){
00228 whenStoppedTracing = CmiWallTimer();
00229 }
00230 }
00231
00232
00233
00234
00235
00236
00237 TraceControlPoints *localControlPointTracingInstance(){
00238 return CkpvAccess(_trace);
00239 }
00240
00241
00242
00243 extern "C" void traceControlPointsExitFunction() {
00244 CkContinueExit();
00245 }
00246
00247
00248 void initTraceControlPointsBOC() {
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258 }
00259
00260
00261
00262 #include "TraceControlPoints.def.h"
00263
00264