1 /* Copyright (c) 2010. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "instr/private.h"
11 static FILE *tracing_file = NULL;
12 int tracing_active = 0;
14 static int pajeDefineContainerTypeId = 0;
15 static int pajeDefineStateTypeId = 1;
16 static int pajeDefineEntityValueId = 2;
17 static int pajeDefineEventTypeId = 3;
18 static int pajeDefineLinkTypeId = 4;
19 static int pajeCreateContainerId = 5;
20 static int pajeSetStateId = 6;
21 static int pajePushStateWithHostId = 7;
22 static int pajePopStateId = 8;
23 static int pajeDestroyContainerId = 9;
24 static int pajeSetStateWithHostId = 10;
25 static int pajeSetStateWithHostCommCompId = 11;
26 static int pajeStartLinkId = 12;
27 static int pajeEndLinkId = 13;
28 static int pajeCreateContainerWithPowerId = 14;
29 static int pajeStartLinkWithBandwidthLatencyId = 15;
30 static int pajePushStateWithPowerUsedId = 16;
31 static int pajePushStateWithBandwidthUsedId = 17;
32 static int pajeSetStateWithPowerUsedId = 18;
33 static int pajePushStateId = 19;
34 static int pajeCreateContainerWithBandwidthLatencyId = 20;
35 static int pajeCreateContainerWithBandwidthLatencySrcDstId = 21;
36 static int pajeSetVariableId = 22;
37 static int pajeAddVariableId = 23;
38 static int pajeSubVariableId = 24;
39 static int pajeDefineVariableTypeId = 25;
40 static int pajeStartLinkWithVolumeId = 26;
41 static int pajeNewEventId = 27;
43 #define TRACE_LINE_SIZE 1000
45 void TRACE_paje_start (FILE *file)
51 FILE *TRACE_paje_end (void)
58 void TRACE_paje_create_header(void) {
64 %%EventDef PajeDefineContainerType %d \n\
66 %% ContainerType string \n\
69 %%EventDef PajeDefineStateType %d \n\
71 %% ContainerType string \n\
74 %%EventDef PajeDefineEntityValue %d \n\
76 %% EntityType string \n\
79 %%EventDef PajeDefineEventType %d \n\
81 %% EntityType string \n\
84 %%EventDef PajeDefineLinkType %d \n\
86 %% ContainerType string \n\
87 %% SourceContainerType string \n\
88 %% DestContainerType string \n\
91 %%EventDef PajeCreateContainer %d \n\
95 %% Container string \n\
98 %%EventDef PajeDestroyContainer %d \n\
101 %% Container string \n\
103 %%EventDef PajeSetState %d \n\
105 %% EntityType string \n\
106 %% Container string \n\
109 %%EventDef PajeSetState %d \n\
111 %% EntityType string \n\
112 %% Container string \n\
116 %%EventDef PajePushState %d \n\
118 %% EntityType string \n\
119 %% Container string \n\
123 %%EventDef PajePopState %d \n\
125 %% EntityType string \n\
126 %% Container string \n\
128 %%EventDef PajeSetState %d \n\
130 %% EntityType string \n\
131 %% Container string \n\
137 %%EventDef PajeStartLink %d \n\
139 %% EntityType string \n\
140 %% Container string \n\
142 %% SourceContainer string \n\
145 %%EventDef PajeEndLink %d \n\
147 %% EntityType string \n\
148 %% Container string \n\
150 %% DestContainer string \n\
153 %%EventDef PajeCreateContainer %d \n\
157 %% Container string \n\
161 %%EventDef PajeStartLink %d \n\
163 %% EntityType string \n\
164 %% Container string \n\
166 %% SourceContainer string \n\
168 %% Bandwidth string \n\
169 %% Latency string \n\
171 %%EventDef PajePushState %d \n\
173 %% EntityType string \n\
174 %% Container string \n\
176 %% PowerUsed string \n\
178 %%EventDef PajePushState %d \n\
180 %% EntityType string \n\
181 %% Container string \n\
183 %% BandwidthUsed string \n\
185 %%EventDef PajeSetState %d \n\
187 %% EntityType string \n\
188 %% Container string \n\
190 %% PowerUsed string \n\
192 %%EventDef PajePushState %d \n\
194 %% EntityType string \n\
195 %% Container string \n\
198 %%EventDef PajeCreateContainer %d \n\
202 %% Container string \n\
204 %% Bandwidth string \n\
205 %% Latency string \n\
207 %%EventDef PajeCreateContainer %d \n\
211 %% Container string \n\
213 %% Bandwidth string \n\
214 %% Latency string \n\
215 %% SrcHost string \n\
216 %% DstHost string \n\
218 %%EventDef PajeSetVariable %d \n\
220 %% EntityType string \n\
221 %% Container string \n\
224 %%EventDef PajeAddVariable %d \n\
226 %% EntityType string \n\
227 %% Container string \n\
230 %%EventDef PajeSubVariable %d \n\
232 %% EntityType string \n\
233 %% Container string \n\
236 %%EventDef PajeDefineVariableType %d \n\
238 %% ContainerType string \n\
241 %%EventDef PajeStartLink %d \n\
243 %% EntityType string \n\
244 %% Container string \n\
246 %% SourceContainer string \n\
250 %%EventDef PajeNewEvent %d \n\
252 %% EntityType string \n\
253 %% Container string \n\
256 pajeDefineContainerTypeId, pajeDefineStateTypeId, pajeDefineEntityValueId,
257 pajeDefineEventTypeId, pajeDefineLinkTypeId, pajeCreateContainerId,
258 pajeDestroyContainerId, pajeSetStateId, pajeSetStateWithHostId,
259 pajePushStateWithHostId, pajePopStateId, pajeSetStateWithHostCommCompId,
260 pajeStartLinkId, pajeEndLinkId, pajeCreateContainerWithPowerId,
261 pajeStartLinkWithBandwidthLatencyId, pajePushStateWithPowerUsedId,
262 pajePushStateWithBandwidthUsedId, pajeSetStateWithPowerUsedId,
263 pajePushStateId, pajeCreateContainerWithBandwidthLatencyId,
264 pajeCreateContainerWithBandwidthLatencySrcDstId,
268 pajeDefineVariableTypeId,
269 pajeStartLinkWithVolumeId,
273 /* internal to this file */
274 static void __pajeCreateContainer (char *output, int len, int eventid, double time, const char *alias, const char *type,
275 const char *container, const char *name)
277 snprintf (output, len, "%d %.15lf %s %s %s %s", eventid, time,
278 alias, type, container, name);
281 static void __pajeSetState (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value)
283 snprintf (output, len, "%d %.15lf %s %s %s", eventid, time, entityType, container, value);
286 static void __pajeSetVariable (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value)
288 snprintf (output, len, "%d %.15lf %s %s %s", eventid, time, entityType, container, value);
291 static void __pajeStartLink (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value,
292 const char *sourceContainer, const char *key)
294 snprintf(output, len, "%d %.15lf %s %s %s %s %s", eventid, time, entityType, container, value, sourceContainer, key);
298 /* internal do the instrumentation module */
299 void pajeDefineContainerType(const char *alias, const char *containerType,
301 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineContainerTypeId, alias,
302 containerType, name);
305 void pajeDefineStateType(const char *alias, const char *containerType,
307 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineStateTypeId, alias,
308 containerType, name);
311 void pajeDefineEventType(const char *alias, const char *containerType,
313 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineEventTypeId, alias,
314 containerType, name);
317 void pajeDefineLinkType(const char *alias, const char *containerType,
318 const char *sourceContainerType, const char *destContainerType,
320 fprintf(tracing_file, "%d %s %s %s %s %s\n", pajeDefineLinkTypeId, alias,
321 containerType, sourceContainerType, destContainerType, name);
324 void pajeCreateContainer(double time, const char *alias, const char *type, const char *container, const char *name) {
325 char line[TRACE_LINE_SIZE];
326 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerId, time, alias, type, container, name);
327 fprintf (tracing_file, "%s\n", line);
330 void pajeCreateContainerWithPower (double time, const char *alias, const char *type, const char *container, const char *name, double power)
332 char line[TRACE_LINE_SIZE];
333 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerWithPowerId, time, alias, type, container, name);
334 fprintf (tracing_file, "%s %f\n", line, power);
337 void pajeCreateContainerWithBandwidthLatency (double time, const char *alias, const char *type, const char *container, const char *name, double bw, double lat)
339 char line[TRACE_LINE_SIZE];
340 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerWithBandwidthLatencyId, time, alias, type, container, name);
341 fprintf (tracing_file, "%s %f %f\n", line, bw, lat);
345 void pajeCreateContainerWithBandwidthLatencySrcDst (double time, const char *alias, const char *type, const char *container, const char *name, double bw, double lat, const char *src, const char *dst)
347 char line[TRACE_LINE_SIZE];
348 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerWithBandwidthLatencySrcDstId, time, alias, type, container, name);
349 fprintf (tracing_file, "%s %f %f %s %s\n", line, bw, lat, src, dst);
353 void pajeDestroyContainer (double time, const char *type, const char *container)
355 fprintf(tracing_file, "%d %.15lf %s %s\n", pajeDestroyContainerId, time, type, container);
358 void pajeSetState (double time, const char *entityType, const char *container, const char *value)
360 char line[TRACE_LINE_SIZE];
361 __pajeSetState (line, TRACE_LINE_SIZE, pajeSetStateId, time, entityType, container, value);
362 fprintf(tracing_file, "%s\n", line);
365 void pajeSetStateWithPowerUsed (double time, const char *entityType, const char *container, const char *value, double powerUsed)
367 char line[TRACE_LINE_SIZE];
368 __pajeSetState (line, TRACE_LINE_SIZE, pajeSetStateWithPowerUsedId, time, entityType, container, value);
369 fprintf(tracing_file, "%s %f\n", line, powerUsed);
372 void pajeSetStateWithHost (double time, const char *entityType, const char *container, const char *value, const char *host)
374 char line[TRACE_LINE_SIZE];
375 __pajeSetState (line, TRACE_LINE_SIZE, pajeSetStateWithHostId, time, entityType, container, value);
376 fprintf(tracing_file, "%s %s\n", line, host);
379 void pajePushState (double time, const char *entityType, const char *container, const char *value)
381 char line[TRACE_LINE_SIZE];
382 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateId, time, entityType, container, value);
383 fprintf(tracing_file, "%s\n", line);
386 void pajePushStateWithHost (double time, const char *entityType, const char *container, const char *value, const char *host)
388 char line[TRACE_LINE_SIZE];
389 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateWithHostId, time, entityType, container, value);
390 fprintf(tracing_file, "%s %s\n", line, host);
393 void pajePushStateWithPowerUsed (double time, const char *entityType, const char *container, const char *value, double powerUsed)
395 char line[TRACE_LINE_SIZE];
396 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateWithPowerUsedId, time, entityType, container, value);
397 fprintf(tracing_file, "%s %f\n", line, powerUsed);
400 void pajePushStateWithBandwidthUsed (double time, const char *entityType, const char *container, const char *value, double bwUsed)
402 char line[TRACE_LINE_SIZE];
403 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateWithBandwidthUsedId, time, entityType, container, value);
404 fprintf(tracing_file, "%s %f\n", line, bwUsed);
407 void pajePopState (double time, const char *entityType, const char *container)
409 fprintf(tracing_file, "%d %.15lf %s %s\n", pajePopStateId, time, entityType, container);
412 void pajeStartLink (double time, const char *entityType, const char *container, const char *value,
413 const char *sourceContainer, const char *key)
415 char line[TRACE_LINE_SIZE];
416 __pajeStartLink (line, TRACE_LINE_SIZE, pajeStartLinkId, time, entityType, container, value, sourceContainer, key);
417 fprintf (tracing_file, "%s\n", line);
420 void pajeStartLinkWithBandwidthLatency (double time, const char *entityType, const char *container, const char *value,
421 const char *sourceContainer, const char *key, double bw, double lat)
423 char line[TRACE_LINE_SIZE];
424 __pajeStartLink (line, TRACE_LINE_SIZE, pajeStartLinkWithBandwidthLatencyId, time, entityType, container, value, sourceContainer, key);
425 fprintf (tracing_file, "%s %f %f\n", line, bw, lat);
428 void pajeStartLinkWithVolume (double time, const char *entityType, const char *container, const char *value,
429 const char *sourceContainer, const char *key, double volume)
431 char line[TRACE_LINE_SIZE];
432 __pajeStartLink (line, TRACE_LINE_SIZE, pajeStartLinkWithVolumeId, time, entityType, container, value, sourceContainer, key);
433 fprintf (tracing_file, "%s %f\n", line, volume);
436 void pajeEndLink (double time, const char *entityType, const char *container, const char *value,
437 const char *destContainer, const char *key)
439 fprintf(tracing_file, "%d %.15lf %s %s %s %s %s\n", pajeEndLinkId, time, entityType, container, value, destContainer, key);
442 void pajeDefineVariableType(const char *alias, const char *containerType, const char *name) {
443 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineVariableTypeId, alias, containerType, name);
447 void pajeSetVariable (double time, const char *entityType, const char *container, const char *value)
449 char line[TRACE_LINE_SIZE];
450 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeSetVariableId, time, entityType, container, value);
451 fprintf(tracing_file, "%s\n", line);
454 void pajeAddVariable (double time, const char *entityType, const char *container, const char *value)
456 char line[TRACE_LINE_SIZE];
457 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeAddVariableId, time, entityType, container, value);
458 fprintf(tracing_file, "%s\n", line);
461 void pajeSubVariable (double time, const char *entityType, const char *container, const char *value)
463 char line[TRACE_LINE_SIZE];
464 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeSubVariableId, time, entityType, container, value);
465 fprintf(tracing_file, "%s\n", line);
468 void pajeNewEvent (double time, const char *entityType, const char *container, const char *value)
470 fprintf(tracing_file, "%d %.15lf %s %s %s\n", pajeNewEventId, time, entityType, container, value);