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;
42 #define TRACE_LINE_SIZE 1000
44 void TRACE_paje_start (FILE *file)
50 FILE *TRACE_paje_end (void)
57 void TRACE_paje_create_header(void) {
63 %%EventDef PajeDefineContainerType %d \n\
65 %% ContainerType string \n\
68 %%EventDef PajeDefineStateType %d \n\
70 %% ContainerType string \n\
73 %%EventDef PajeDefineEntityValue %d \n\
75 %% EntityType string \n\
78 %%EventDef PajeDefineEventType %d \n\
80 %% EntityType string \n\
83 %%EventDef PajeDefineLinkType %d \n\
85 %% ContainerType string \n\
86 %% SourceContainerType string \n\
87 %% DestContainerType string \n\
90 %%EventDef PajeCreateContainer %d \n\
94 %% Container string \n\
97 %%EventDef PajeDestroyContainer %d \n\
100 %% Container string \n\
102 %%EventDef PajeSetState %d \n\
104 %% EntityType string \n\
105 %% Container string \n\
108 %%EventDef PajeSetState %d \n\
110 %% EntityType string \n\
111 %% Container string \n\
115 %%EventDef PajePushState %d \n\
117 %% EntityType string \n\
118 %% Container string \n\
122 %%EventDef PajePopState %d \n\
124 %% EntityType string \n\
125 %% Container string \n\
127 %%EventDef PajeSetState %d \n\
129 %% EntityType string \n\
130 %% Container string \n\
136 %%EventDef PajeStartLink %d \n\
138 %% EntityType string \n\
139 %% Container string \n\
141 %% SourceContainer string \n\
144 %%EventDef PajeEndLink %d \n\
146 %% EntityType string \n\
147 %% Container string \n\
149 %% DestContainer string \n\
152 %%EventDef PajeCreateContainer %d \n\
156 %% Container string \n\
160 %%EventDef PajeStartLink %d \n\
162 %% EntityType string \n\
163 %% Container string \n\
165 %% SourceContainer string \n\
167 %% Bandwidth string \n\
168 %% Latency string \n\
170 %%EventDef PajePushState %d \n\
172 %% EntityType string \n\
173 %% Container string \n\
175 %% PowerUsed string \n\
177 %%EventDef PajePushState %d \n\
179 %% EntityType string \n\
180 %% Container string \n\
182 %% BandwidthUsed string \n\
184 %%EventDef PajeSetState %d \n\
186 %% EntityType string \n\
187 %% Container string \n\
189 %% PowerUsed string \n\
191 %%EventDef PajePushState %d \n\
193 %% EntityType string \n\
194 %% Container string \n\
197 %%EventDef PajeCreateContainer %d \n\
201 %% Container string \n\
203 %% Bandwidth string \n\
204 %% Latency string \n\
206 %%EventDef PajeCreateContainer %d \n\
210 %% Container string \n\
212 %% Bandwidth string \n\
213 %% Latency string \n\
214 %% SrcHost string \n\
215 %% DstHost string \n\
217 %%EventDef PajeSetVariable %d \n\
219 %% EntityType string \n\
220 %% Container string \n\
223 %%EventDef PajeAddVariable %d \n\
225 %% EntityType string \n\
226 %% Container string \n\
229 %%EventDef PajeSubVariable %d \n\
231 %% EntityType string \n\
232 %% Container string \n\
235 %%EventDef PajeDefineVariableType %d \n\
237 %% ContainerType string \n\
240 %%EventDef PajeStartLink %d \n\
242 %% EntityType string \n\
243 %% Container string \n\
245 %% SourceContainer string \n\
249 pajeDefineContainerTypeId, pajeDefineStateTypeId, pajeDefineEntityValueId,
250 pajeDefineEventTypeId, pajeDefineLinkTypeId, pajeCreateContainerId,
251 pajeDestroyContainerId, pajeSetStateId, pajeSetStateWithHostId,
252 pajePushStateWithHostId, pajePopStateId, pajeSetStateWithHostCommCompId,
253 pajeStartLinkId, pajeEndLinkId, pajeCreateContainerWithPowerId,
254 pajeStartLinkWithBandwidthLatencyId, pajePushStateWithPowerUsedId,
255 pajePushStateWithBandwidthUsedId, pajeSetStateWithPowerUsedId,
256 pajePushStateId, pajeCreateContainerWithBandwidthLatencyId,
257 pajeCreateContainerWithBandwidthLatencySrcDstId,
261 pajeDefineVariableTypeId,
262 pajeStartLinkWithVolumeId);
265 /* internal to this file */
266 static void __pajeCreateContainer (char *output, int len, int eventid, double time, const char *alias, const char *type,
267 const char *container, const char *name)
269 snprintf (output, len, "%d %.15lf %s %s %s %s", eventid, time,
270 alias, type, container, name);
273 static void __pajeSetState (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value)
275 snprintf (output, len, "%d %.15lf %s %s %s", eventid, time, entityType, container, value);
278 static void __pajeSetVariable (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value)
280 snprintf (output, len, "%d %.15lf %s %s %s", eventid, time, entityType, container, value);
283 static void __pajeStartLink (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value,
284 const char *sourceContainer, const char *key)
286 snprintf(output, len, "%d %.15lf %s %s %s %s %s", eventid, time, entityType, container, value, sourceContainer, key);
290 /* internal do the instrumentation module */
291 void pajeDefineContainerType(const char *alias, const char *containerType,
293 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineContainerTypeId, alias,
294 containerType, name);
297 void pajeDefineStateType(const char *alias, const char *containerType,
299 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineStateTypeId, alias,
300 containerType, name);
303 void pajeDefineEventType(const char *alias, const char *containerType,
305 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineEventTypeId, alias,
306 containerType, name);
309 void pajeDefineLinkType(const char *alias, const char *containerType,
310 const char *sourceContainerType, const char *destContainerType,
312 fprintf(tracing_file, "%d %s %s %s %s %s\n", pajeDefineLinkTypeId, alias,
313 containerType, sourceContainerType, destContainerType, name);
316 void pajeCreateContainer(double time, const char *alias, const char *type, const char *container, const char *name) {
317 char line[TRACE_LINE_SIZE];
318 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerId, time, alias, type, container, name);
319 fprintf (tracing_file, "%s\n", line);
322 void pajeCreateContainerWithPower (double time, const char *alias, const char *type, const char *container, const char *name, double power)
324 char line[TRACE_LINE_SIZE];
325 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerWithPowerId, time, alias, type, container, name);
326 fprintf (tracing_file, "%s %f\n", line, power);
329 void pajeCreateContainerWithBandwidthLatency (double time, const char *alias, const char *type, const char *container, const char *name, double bw, double lat)
331 char line[TRACE_LINE_SIZE];
332 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerWithBandwidthLatencyId, time, alias, type, container, name);
333 fprintf (tracing_file, "%s %f %f\n", line, bw, lat);
337 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)
339 char line[TRACE_LINE_SIZE];
340 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerWithBandwidthLatencySrcDstId, time, alias, type, container, name);
341 fprintf (tracing_file, "%s %f %f %s %s\n", line, bw, lat, src, dst);
345 void pajeDestroyContainer (double time, const char *type, const char *container)
347 fprintf(tracing_file, "%d %.15lf %s %s\n", pajeDestroyContainerId, time, type, container);
350 void pajeSetState (double time, const char *entityType, const char *container, const char *value)
352 char line[TRACE_LINE_SIZE];
353 __pajeSetState (line, TRACE_LINE_SIZE, pajeSetStateId, time, entityType, container, value);
354 fprintf(tracing_file, "%s\n", line);
357 void pajeSetStateWithPowerUsed (double time, const char *entityType, const char *container, const char *value, double powerUsed)
359 char line[TRACE_LINE_SIZE];
360 __pajeSetState (line, TRACE_LINE_SIZE, pajeSetStateWithPowerUsedId, time, entityType, container, value);
361 fprintf(tracing_file, "%s %f\n", line, powerUsed);
364 void pajeSetStateWithHost (double time, const char *entityType, const char *container, const char *value, const char *host)
366 char line[TRACE_LINE_SIZE];
367 __pajeSetState (line, TRACE_LINE_SIZE, pajeSetStateWithHostId, time, entityType, container, value);
368 fprintf(tracing_file, "%s %s\n", line, host);
371 void pajePushState (double time, const char *entityType, const char *container, const char *value)
373 char line[TRACE_LINE_SIZE];
374 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateId, time, entityType, container, value);
375 fprintf(tracing_file, "%s\n", line);
378 void pajePushStateWithHost (double time, const char *entityType, const char *container, const char *value, const char *host)
380 char line[TRACE_LINE_SIZE];
381 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateWithHostId, time, entityType, container, value);
382 fprintf(tracing_file, "%s %s\n", line, host);
385 void pajePushStateWithPowerUsed (double time, const char *entityType, const char *container, const char *value, double powerUsed)
387 char line[TRACE_LINE_SIZE];
388 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateWithPowerUsedId, time, entityType, container, value);
389 fprintf(tracing_file, "%s %f\n", line, powerUsed);
392 void pajePushStateWithBandwidthUsed (double time, const char *entityType, const char *container, const char *value, double bwUsed)
394 char line[TRACE_LINE_SIZE];
395 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateWithBandwidthUsedId, time, entityType, container, value);
396 fprintf(tracing_file, "%s %f\n", line, bwUsed);
399 void pajePopState (double time, const char *entityType, const char *container)
401 fprintf(tracing_file, "%d %.15lf %s %s\n", pajePopStateId, time, entityType, container);
404 void pajeStartLink (double time, const char *entityType, const char *container, const char *value,
405 const char *sourceContainer, const char *key)
407 char line[TRACE_LINE_SIZE];
408 __pajeStartLink (line, TRACE_LINE_SIZE, pajeStartLinkId, time, entityType, container, value, sourceContainer, key);
409 fprintf (tracing_file, "%s\n", line);
412 void pajeStartLinkWithBandwidthLatency (double time, const char *entityType, const char *container, const char *value,
413 const char *sourceContainer, const char *key, double bw, double lat)
415 char line[TRACE_LINE_SIZE];
416 __pajeStartLink (line, TRACE_LINE_SIZE, pajeStartLinkWithBandwidthLatencyId, time, entityType, container, value, sourceContainer, key);
417 fprintf (tracing_file, "%s %f %f\n", line, bw, lat);
420 void pajeStartLinkWithVolume (double time, const char *entityType, const char *container, const char *value,
421 const char *sourceContainer, const char *key, double volume)
423 char line[TRACE_LINE_SIZE];
424 __pajeStartLink (line, TRACE_LINE_SIZE, pajeStartLinkWithVolumeId, time, entityType, container, value, sourceContainer, key);
425 fprintf (tracing_file, "%s %f\n", line, volume);
428 void pajeEndLink (double time, const char *entityType, const char *container, const char *value,
429 const char *destContainer, const char *key)
431 fprintf(tracing_file, "%d %.15lf %s %s %s %s %s\n", pajeEndLinkId, time, entityType, container, value, destContainer, key);
434 void pajeDefineVariableType(const char *alias, const char *containerType, const char *name) {
435 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineVariableTypeId, alias, containerType, name);
439 void pajeSetVariable (double time, const char *entityType, const char *container, const char *value)
441 char line[TRACE_LINE_SIZE];
442 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeSetVariableId, time, entityType, container, value);
443 fprintf(tracing_file, "%s\n", line);
446 void pajeAddVariable (double time, const char *entityType, const char *container, const char *value)
448 char line[TRACE_LINE_SIZE];
449 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeAddVariableId, time, entityType, container, value);
450 fprintf(tracing_file, "%s\n", line);
453 void pajeSubVariable (double time, const char *entityType, const char *container, const char *value)
455 char line[TRACE_LINE_SIZE];
456 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeSubVariableId, time, entityType, container, value);
457 fprintf(tracing_file, "%s\n", line);