4 * Created on: Oct 7, 2009
5 * Author: Lucas Schnorr
6 * License: This program is free software; you can redistribute
7 * it and/or modify it under the terms of the license
8 * (GNU LGPL) which comes with this package.
10 * Copyright (c) 2009 The SimGrid team.
13 #include "instr/private.h"
17 static FILE *tracing_file = NULL;
18 int tracing_active = 0;
20 static int pajeDefineContainerTypeId = 0;
21 static int pajeDefineStateTypeId = 1;
22 static int pajeDefineEntityValueId = 2;
23 static int pajeDefineEventTypeId = 3;
24 static int pajeDefineLinkTypeId = 4;
25 static int pajeCreateContainerId = 5;
26 static int pajeSetStateId = 6;
27 static int pajePushStateWithHostId = 7;
28 static int pajePopStateId = 8;
29 static int pajeDestroyContainerId = 9;
30 static int pajeSetStateWithHostId = 10;
31 static int pajeSetStateWithHostCommCompId = 11;
32 static int pajeStartLinkId = 12;
33 static int pajeEndLinkId = 13;
34 static int pajeCreateContainerWithPowerId = 14;
35 static int pajeStartLinkWithBandwidthLatencyId = 15;
36 static int pajePushStateWithPowerUsedId = 16;
37 static int pajePushStateWithBandwidthUsedId = 17;
38 static int pajeSetStateWithPowerUsedId = 18;
39 static int pajePushStateId = 19;
40 static int pajeCreateContainerWithBandwidthLatencyId = 20;
41 static int pajeCreateContainerWithBandwidthLatencySrcDstId = 21;
42 static int pajeSetVariableId = 22;
43 static int pajeAddVariableId = 23;
44 static int pajeSubVariableId = 24;
45 static int pajeDefineVariableTypeId = 25;
46 static int pajeStartLinkWithVolumeId = 26;
48 #define TRACE_LINE_SIZE 1000
50 void TRACE_paje_start (FILE *file)
56 FILE *TRACE_paje_end (void)
63 void TRACE_paje_create_header(void) {
69 %%EventDef PajeDefineContainerType %d \n\
71 %% ContainerType string \n\
74 %%EventDef PajeDefineStateType %d \n\
76 %% ContainerType string \n\
79 %%EventDef PajeDefineEntityValue %d \n\
81 %% EntityType string \n\
84 %%EventDef PajeDefineEventType %d \n\
86 %% EntityType string \n\
89 %%EventDef PajeDefineLinkType %d \n\
91 %% ContainerType string \n\
92 %% SourceContainerType string \n\
93 %% DestContainerType string \n\
96 %%EventDef PajeCreateContainer %d \n\
100 %% Container string \n\
103 %%EventDef PajeDestroyContainer %d \n\
106 %% Container string \n\
108 %%EventDef PajeSetState %d \n\
110 %% EntityType string \n\
111 %% Container string \n\
114 %%EventDef PajeSetState %d \n\
116 %% EntityType string \n\
117 %% Container string \n\
121 %%EventDef PajePushState %d \n\
123 %% EntityType string \n\
124 %% Container string \n\
128 %%EventDef PajePopState %d \n\
130 %% EntityType string \n\
131 %% Container string \n\
133 %%EventDef PajeSetState %d \n\
135 %% EntityType string \n\
136 %% Container string \n\
142 %%EventDef PajeStartLink %d \n\
144 %% EntityType string \n\
145 %% Container string \n\
147 %% SourceContainer string \n\
150 %%EventDef PajeEndLink %d \n\
152 %% EntityType string \n\
153 %% Container string \n\
155 %% DestContainer string \n\
158 %%EventDef PajeCreateContainer %d \n\
162 %% Container string \n\
166 %%EventDef PajeStartLink %d \n\
168 %% EntityType string \n\
169 %% Container string \n\
171 %% SourceContainer string \n\
173 %% Bandwidth string \n\
174 %% Latency string \n\
176 %%EventDef PajePushState %d \n\
178 %% EntityType string \n\
179 %% Container string \n\
181 %% PowerUsed string \n\
183 %%EventDef PajePushState %d \n\
185 %% EntityType string \n\
186 %% Container string \n\
188 %% BandwidthUsed string \n\
190 %%EventDef PajeSetState %d \n\
192 %% EntityType string \n\
193 %% Container string \n\
195 %% PowerUsed string \n\
197 %%EventDef PajePushState %d \n\
199 %% EntityType string \n\
200 %% Container string \n\
203 %%EventDef PajeCreateContainer %d \n\
207 %% Container string \n\
209 %% Bandwidth string \n\
210 %% Latency string \n\
212 %%EventDef PajeCreateContainer %d \n\
216 %% Container string \n\
218 %% Bandwidth string \n\
219 %% Latency string \n\
220 %% SrcHost string \n\
221 %% DstHost string \n\
223 %%EventDef PajeSetVariable %d \n\
225 %% EntityType string \n\
226 %% Container string \n\
229 %%EventDef PajeAddVariable %d \n\
231 %% EntityType string \n\
232 %% Container string \n\
235 %%EventDef PajeSubVariable %d \n\
237 %% EntityType string \n\
238 %% Container string \n\
241 %%EventDef PajeDefineVariableType %d \n\
243 %% ContainerType string \n\
246 %%EventDef PajeStartLink %d \n\
248 %% EntityType string \n\
249 %% Container string \n\
251 %% SourceContainer string \n\
255 pajeDefineContainerTypeId, pajeDefineStateTypeId, pajeDefineEntityValueId,
256 pajeDefineEventTypeId, pajeDefineLinkTypeId, pajeCreateContainerId,
257 pajeDestroyContainerId, pajeSetStateId, pajeSetStateWithHostId,
258 pajePushStateWithHostId, pajePopStateId, pajeSetStateWithHostCommCompId,
259 pajeStartLinkId, pajeEndLinkId, pajeCreateContainerWithPowerId,
260 pajeStartLinkWithBandwidthLatencyId, pajePushStateWithPowerUsedId,
261 pajePushStateWithBandwidthUsedId, pajeSetStateWithPowerUsedId,
262 pajePushStateId, pajeCreateContainerWithBandwidthLatencyId,
263 pajeCreateContainerWithBandwidthLatencySrcDstId,
267 pajeDefineVariableTypeId,
268 pajeStartLinkWithVolumeId);
271 /* internal to this file */
272 static void __pajeCreateContainer (char *output, int len, int eventid, double time, const char *alias, const char *type,
273 const char *container, const char *name)
275 snprintf (output, len, "%d %.15lf %s %s %s %s", eventid, time,
276 alias, type, container, name);
279 static void __pajeSetState (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value)
281 snprintf (output, len, "%d %.15lf %s %s %s", eventid, time, entityType, container, value);
284 static void __pajeSetVariable (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value)
286 snprintf (output, len, "%d %.15lf %s %s %s", eventid, time, entityType, container, value);
289 static void __pajeStartLink (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value,
290 const char *sourceContainer, const char *key)
292 snprintf(output, len, "%d %.15lf %s %s %s %s %s", eventid, time, entityType, container, value, sourceContainer, key);
296 /* internal do the instrumentation module */
297 void pajeDefineContainerType(const char *alias, const char *containerType,
299 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineContainerTypeId, alias,
300 containerType, name);
303 void pajeDefineStateType(const char *alias, const char *containerType,
305 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineStateTypeId, alias,
306 containerType, name);
309 void pajeDefineEventType(const char *alias, const char *containerType,
311 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineEventTypeId, alias,
312 containerType, name);
315 void pajeDefineLinkType(const char *alias, const char *containerType,
316 const char *sourceContainerType, const char *destContainerType,
318 fprintf(tracing_file, "%d %s %s %s %s %s\n", pajeDefineLinkTypeId, alias,
319 containerType, sourceContainerType, destContainerType, name);
322 void pajeCreateContainer(double time, const char *alias, const char *type, const char *container, const char *name) {
323 char line[TRACE_LINE_SIZE];
324 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerId, time, alias, type, container, name);
325 fprintf (tracing_file, "%s\n", line);
328 void pajeCreateContainerWithPower (double time, const char *alias, const char *type, const char *container, const char *name, double power)
330 char line[TRACE_LINE_SIZE];
331 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerWithPowerId, time, alias, type, container, name);
332 fprintf (tracing_file, "%s %f\n", line, power);
335 void pajeCreateContainerWithBandwidthLatency (double time, const char *alias, const char *type, const char *container, const char *name, double bw, double lat)
337 char line[TRACE_LINE_SIZE];
338 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerWithBandwidthLatencyId, time, alias, type, container, name);
339 fprintf (tracing_file, "%s %f %f\n", line, bw, lat);
343 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)
345 char line[TRACE_LINE_SIZE];
346 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerWithBandwidthLatencySrcDstId, time, alias, type, container, name);
347 fprintf (tracing_file, "%s %f %f %s %s\n", line, bw, lat, src, dst);
351 void pajeDestroyContainer (double time, const char *type, const char *container)
353 fprintf(tracing_file, "%d %.15lf %s %s\n", pajeDestroyContainerId, time, type, container);
356 void pajeSetState (double time, const char *entityType, const char *container, const char *value)
358 char line[TRACE_LINE_SIZE];
359 __pajeSetState (line, TRACE_LINE_SIZE, pajeSetStateId, time, entityType, container, value);
360 fprintf(tracing_file, "%s\n", line);
363 void pajeSetStateWithPowerUsed (double time, const char *entityType, const char *container, const char *value, double powerUsed)
365 char line[TRACE_LINE_SIZE];
366 __pajeSetState (line, TRACE_LINE_SIZE, pajeSetStateWithPowerUsedId, time, entityType, container, value);
367 fprintf(tracing_file, "%s %f\n", line, powerUsed);
370 void pajeSetStateWithHost (double time, const char *entityType, const char *container, const char *value, const char *host)
372 char line[TRACE_LINE_SIZE];
373 __pajeSetState (line, TRACE_LINE_SIZE, pajeSetStateWithHostId, time, entityType, container, value);
374 fprintf(tracing_file, "%s %s\n", line, host);
377 void pajePushState (double time, const char *entityType, const char *container, const char *value)
379 char line[TRACE_LINE_SIZE];
380 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateId, time, entityType, container, value);
381 fprintf(tracing_file, "%s\n", line);
384 void pajePushStateWithHost (double time, const char *entityType, const char *container, const char *value, const char *host)
386 char line[TRACE_LINE_SIZE];
387 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateWithHostId, time, entityType, container, value);
388 fprintf(tracing_file, "%s %s\n", line, host);
391 void pajePushStateWithPowerUsed (double time, const char *entityType, const char *container, const char *value, double powerUsed)
393 char line[TRACE_LINE_SIZE];
394 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateWithPowerUsedId, time, entityType, container, value);
395 fprintf(tracing_file, "%s %f\n", line, powerUsed);
398 void pajePushStateWithBandwidthUsed (double time, const char *entityType, const char *container, const char *value, double bwUsed)
400 char line[TRACE_LINE_SIZE];
401 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateWithBandwidthUsedId, time, entityType, container, value);
402 fprintf(tracing_file, "%s %f\n", line, bwUsed);
405 void pajePopState (double time, const char *entityType, const char *container)
407 fprintf(tracing_file, "%d %.15lf %s %s\n", pajePopStateId, time, entityType, container);
410 void pajeStartLink (double time, const char *entityType, const char *container, const char *value,
411 const char *sourceContainer, const char *key)
413 char line[TRACE_LINE_SIZE];
414 __pajeStartLink (line, TRACE_LINE_SIZE, pajeStartLinkId, time, entityType, container, value, sourceContainer, key);
415 fprintf (tracing_file, "%s\n", line);
418 void pajeStartLinkWithBandwidthLatency (double time, const char *entityType, const char *container, const char *value,
419 const char *sourceContainer, const char *key, double bw, double lat)
421 char line[TRACE_LINE_SIZE];
422 __pajeStartLink (line, TRACE_LINE_SIZE, pajeStartLinkWithBandwidthLatencyId, time, entityType, container, value, sourceContainer, key);
423 fprintf (tracing_file, "%s %f %f\n", line, bw, lat);
426 void pajeStartLinkWithVolume (double time, const char *entityType, const char *container, const char *value,
427 const char *sourceContainer, const char *key, double volume)
429 char line[TRACE_LINE_SIZE];
430 __pajeStartLink (line, TRACE_LINE_SIZE, pajeStartLinkWithVolumeId, time, entityType, container, value, sourceContainer, key);
431 fprintf (tracing_file, "%s %f\n", line, volume);
434 void pajeEndLink (double time, const char *entityType, const char *container, const char *value,
435 const char *destContainer, const char *key)
437 fprintf(tracing_file, "%d %.15lf %s %s %s %s %s\n", pajeEndLinkId, time, entityType, container, value, destContainer, key);
440 void pajeDefineVariableType(const char *alias, const char *containerType, const char *name) {
441 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineVariableTypeId, alias, containerType, name);
445 void pajeSetVariable (double time, const char *entityType, const char *container, const char *value)
447 char line[TRACE_LINE_SIZE];
448 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeSetVariableId, time, entityType, container, value);
449 fprintf(tracing_file, "%s\n", line);
452 void pajeAddVariable (double time, const char *entityType, const char *container, const char *value)
454 char line[TRACE_LINE_SIZE];
455 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeAddVariableId, time, entityType, container, value);
456 fprintf(tracing_file, "%s\n", line);
459 void pajeSubVariable (double time, const char *entityType, const char *container, const char *value)
461 char line[TRACE_LINE_SIZE];
462 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeSubVariableId, time, entityType, container, value);
463 fprintf(tracing_file, "%s\n", line);