/home/runner/work/charm/charm/src/ck-perf/trace-controlPoints.C
Line | Count | Source (jump to first uncovered line) |
1 | | #include "charm++.h" |
2 | | #include "trace-controlPoints.h" |
3 | | #include "trace-controlPointsBOC.h" |
4 | | |
5 | | |
6 | | /** |
7 | | * \addtogroup ControlPointFramework |
8 | | * @{ |
9 | | */ |
10 | | |
11 | | |
12 | | // Charm++ "processor"(user thread)-private global variable |
13 | | CkpvStaticDeclare(TraceControlPoints*, _trace); |
14 | | |
15 | | // This global variable is required for any post-execution |
16 | | // parallel analysis or parallel activities the trace module |
17 | | // might wish to perform. |
18 | | CkGroupID traceControlPointsGID; |
19 | | |
20 | | /** |
21 | | For each TraceFoo module, _createTraceFoo() must be defined. |
22 | | This function is called in _createTraces() generated in moduleInit.C |
23 | | |
24 | | This module is special in that it is always included in charm, but sometimes it does nothing. |
25 | | This is called on all processors in SMP version. |
26 | | */ |
27 | | void _createTracecontrolPoints(char **argv) |
28 | 0 | { |
29 | 0 | CkpvInitialize(TraceControlPoints*, _trace); |
30 | 0 | CkpvAccess(_trace) = new TraceControlPoints(argv); |
31 | 0 | CkpvAccess(_traces)->addTrace(CkpvAccess(_trace)); |
32 | 0 | } |
33 | | |
34 | | TraceControlPoints::TraceControlPoints(char **argv) |
35 | 0 | { |
36 | 0 | resetTimings(); |
37 | |
|
38 | 0 | nesting_level = 0; |
39 | |
|
40 | 0 | whenStoppedTracing = 0; |
41 | |
|
42 | 0 | b1=0; |
43 | 0 | b2=0; |
44 | 0 | b3=0; |
45 | |
|
46 | 0 | if (CkpvAccess(traceOnPe) == 0) return; |
47 | | |
48 | | // Process runtime arguments intended for the module |
49 | | // CmiGetArgIntDesc(argv,"+ControlPointsPar0", &par0, "Fake integer parameter 0"); |
50 | 0 | } |
51 | | |
52 | | |
53 | 0 | void TraceControlPoints::traceBegin(void){ |
54 | 0 | if(whenStoppedTracing != 0) |
55 | 0 | totalUntracedTime += CmiWallTimer() - whenStoppedTracing; |
56 | 0 | whenStoppedTracing = 0; |
57 | 0 | CkPrintf("[%d] TraceControlPoints::traceBegin() totalUntracedTime=%f\n", CkMyPe(), totalUntracedTime); |
58 | 0 | } |
59 | | |
60 | | |
61 | 0 | void TraceControlPoints::traceEnd(void){ |
62 | 0 | CkPrintf("[%d] TraceControlPoints::traceEnd()\n", CkMyPe()); |
63 | 0 | CkAssert(whenStoppedTracing == 0); // can't support nested traceEnds on one processor yet... |
64 | 0 | whenStoppedTracing = CmiWallTimer(); |
65 | 0 | } |
66 | | |
67 | | |
68 | | |
69 | | void TraceControlPoints::userEvent(int eventID) |
70 | 0 | { |
71 | | // CkPrintf("[%d] User Point Event id %d encountered\n", CkMyPe(), eventID); |
72 | 0 | } |
73 | | |
74 | 0 | void TraceControlPoints::userBracketEvent(int eventID, double bt, double et) { |
75 | | // CkPrintf("[%d] User Bracket Event id %d encountered\n", CkMyPe(), eventID); |
76 | 0 | } |
77 | | |
78 | 0 | void TraceControlPoints::creation(envelope *, int epIdx, int num) { |
79 | | // CkPrintf("[%d] Point-to-Point Message for Entry Method id %d sent\n", CkMyPe(), epIdx); |
80 | 0 | } |
81 | | |
82 | | void TraceControlPoints::creationMulticast(envelope *, int epIdx, int num, |
83 | 0 | const int *pelist) { |
84 | | // CkPrintf("[%d] Multicast Message for Entry Method id %d sent to %d pes\n", CkMyPe(), epIdx, num); |
85 | 0 | } |
86 | | |
87 | 0 | void TraceControlPoints::creationDone(int num) { |
88 | | // CkPrintf("[%d] Last initiated send completes\n", CkMyPe()); |
89 | 0 | } |
90 | | |
91 | 0 | void TraceControlPoints::messageRecv(char *env, int pe) { |
92 | | // CkPrintf("[%d] Message from pe %d received by scheduler\n", CkMyPe(), pe); |
93 | 0 | } |
94 | | |
95 | | void TraceControlPoints::beginExecute(CmiObjId *tid) |
96 | 0 | { |
97 | 0 | nesting_level++; |
98 | 0 | if(nesting_level == 1){ |
99 | | // CmiObjId is a 4-integer tuple uniquely identifying a migratable |
100 | | // Charm++ object. Note that there are other non-migratable Charm++ |
101 | | // objects that CmiObjId will not identify. |
102 | 0 | b1++; |
103 | 0 | lastBeginExecuteTime = CmiWallTimer(); |
104 | 0 | lastbeginMessageSize = -1; |
105 | 0 | } |
106 | 0 | } |
107 | | |
108 | | |
109 | | |
110 | | void TraceControlPoints::beginExecute(envelope *e) |
111 | 0 | { |
112 | 0 | nesting_level++; |
113 | 0 | if(nesting_level == 1){ |
114 | 0 | lastBeginExecuteTime = CmiWallTimer(); |
115 | 0 | lastbeginMessageSize = e->getTotalsize(); |
116 | 0 | b2++; |
117 | 0 | b2mlen += lastbeginMessageSize; |
118 | 0 | } |
119 | 0 | } |
120 | | |
121 | | void TraceControlPoints::beginExecute(int event,int msgType,int ep,int srcPe, |
122 | | int mlen, CmiObjId *idx) |
123 | 0 | { |
124 | 0 | nesting_level++; |
125 | 0 | if(nesting_level == 1){ |
126 | 0 | b3++; |
127 | 0 | b3mlen += mlen; |
128 | 0 | lastBeginExecuteTime = CmiWallTimer(); |
129 | 0 | lastbeginMessageSize = mlen; |
130 | 0 | } |
131 | 0 | } |
132 | | |
133 | | void TraceControlPoints::endExecute(void) |
134 | 0 | { |
135 | | // CkPrintf("TraceControlPoints::endExecute\n"); |
136 | 0 | nesting_level--; |
137 | 0 | if(nesting_level == 0){ |
138 | | |
139 | 0 | double executionTime = CmiWallTimer() - lastBeginExecuteTime; |
140 | 0 | totalEntryMethodTime += executionTime; |
141 | 0 | totalEntryMethodInvocations ++; |
142 | | |
143 | 0 | double m = (double)CmiMemoryUsage(); |
144 | 0 | if(memUsage < m){ |
145 | 0 | memUsage = m; |
146 | 0 | } |
147 | 0 | } |
148 | 0 | } |
149 | | |
150 | 0 | void TraceControlPoints::beginIdle(double curWallTime) { |
151 | 0 | lastBeginIdle = CmiWallTimer(); |
152 | | // CkPrintf("[%d] Scheduler has no useful user-work\n", CkMyPe()); |
153 | |
|
154 | 0 | double m = (double)CmiMemoryUsage(); |
155 | 0 | if(memUsage < m){ |
156 | 0 | memUsage = m; |
157 | 0 | } |
158 | 0 | } |
159 | | |
160 | 0 | void TraceControlPoints::endIdle(double curWallTime) { |
161 | 0 | totalIdleTime += CmiWallTimer() - lastBeginIdle; |
162 | | // CkPrintf("[%d] Scheduler now has useful user-work\n", CkMyPe()); |
163 | 0 | } |
164 | | |
165 | | void TraceControlPoints::beginComputation(void) |
166 | 0 | { |
167 | 0 | CkPrintf("[%d] TraceControlPoints::beginComputation\n", CkMyPe()); |
168 | | // Code Below shows what trace-summary would do. |
169 | | // initialze arrays because now the number of entries is known. |
170 | | // _logPool->initMem(); |
171 | 0 | } |
172 | | |
173 | | void TraceControlPoints::endComputation(void) |
174 | 0 | { |
175 | 0 | CkPrintf("[%d] TraceControlPoints::endComputationn", CkMyPe()); |
176 | 0 | } |
177 | | |
178 | | void TraceControlPoints::malloc(void *where, int size, void **stack, int stackSize) |
179 | 0 | { |
180 | | // CkPrintf("[%d] Memory allocation of size %d occurred\n", CkMyPe(), size); |
181 | 0 | double m = (double)CmiMemoryUsage(); |
182 | 0 | if(memUsage < m){ |
183 | 0 | memUsage = m; |
184 | 0 | } |
185 | 0 | } |
186 | | |
187 | 0 | void TraceControlPoints::free(void *where, int size) { |
188 | | // CkPrintf("[%d] %d-byte Memory block freed\n", CkMyPe(), size); |
189 | 0 | } |
190 | | |
191 | | void TraceControlPoints::traceClose(void) |
192 | 0 | { |
193 | | // Print out some performance counters where available |
194 | 0 | CProxy_TraceControlPointsBOC myProxy(traceControlPointsGID); |
195 | | |
196 | | |
197 | 0 | CkpvAccess(_trace)->endComputation(); |
198 | | // remove myself from traceArray so that no tracing will be called. |
199 | 0 | CkpvAccess(_traces)->removeTrace(this); |
200 | 0 | } |
201 | | |
202 | | |
203 | | |
204 | | |
205 | 0 | void TraceControlPoints::resetTimings(){ |
206 | 0 | totalIdleTime = 0.0; |
207 | 0 | totalEntryMethodTime = 0.0; |
208 | 0 | totalEntryMethodInvocations = 0; |
209 | 0 | lastResetTime = CmiWallTimer(); |
210 | 0 | totalUntracedTime = 0; |
211 | 0 | if(whenStoppedTracing !=0){ |
212 | 0 | whenStoppedTracing = CmiWallTimer(); |
213 | 0 | } |
214 | 0 | } |
215 | | |
216 | 0 | void TraceControlPoints::resetAll(){ |
217 | 0 | totalIdleTime = 0.0; |
218 | 0 | totalEntryMethodTime = 0.0; |
219 | 0 | memUsage = 0; |
220 | 0 | totalEntryMethodInvocations = 0; |
221 | 0 | b2mlen=0; |
222 | 0 | b3mlen=0; |
223 | 0 | b2=0; |
224 | 0 | b3=0; |
225 | 0 | lastResetTime = CmiWallTimer(); |
226 | 0 | totalUntracedTime = 0; |
227 | 0 | if(whenStoppedTracing !=0){ |
228 | 0 | whenStoppedTracing = CmiWallTimer(); |
229 | 0 | } |
230 | 0 | } |
231 | | |
232 | | |
233 | | |
234 | | |
235 | | |
236 | | |
237 | 0 | TraceControlPoints *localControlPointTracingInstance(){ |
238 | 0 | return CkpvAccess(_trace); |
239 | 0 | } |
240 | | |
241 | | |
242 | | |
243 | 0 | extern "C" void traceControlPointsExitFunction() { |
244 | 0 | CkContinueExit(); |
245 | 0 | } |
246 | | |
247 | | // Initialization of the parallel trace module. |
248 | 0 | void initTraceControlPointsBOC() { |
249 | | /* |
250 | | if (CkMyRank() == 0) { |
251 | | registerExitFn(traceControlPointsExitFunction); |
252 | | } |
253 | | */ |
254 | 0 | } |
255 | | |
256 | | |
257 | | |
258 | | #include "TraceControlPoints.def.h" |
259 | | |
260 | | |
261 | | /*@}*/ |