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"
14 #include "instr/config.h"
18 static FILE *tracing_file = NULL;
19 int tracing_active = 0;
21 static int pajeDefineContainerTypeId = 0;
22 static int pajeDefineStateTypeId = 1;
23 static int pajeDefineEntityValueId = 2;
24 static int pajeDefineEventTypeId = 3;
25 static int pajeDefineLinkTypeId = 4;
26 static int pajeCreateContainerId = 5;
27 static int pajeSetStateId = 6;
28 static int pajePushStateWithHostId = 7;
29 static int pajePopStateId = 8;
30 static int pajeDestroyContainerId = 9;
31 static int pajeSetStateWithHostId = 10;
32 static int pajeSetStateWithHostCommCompId = 11;
33 static int pajeStartLinkId = 12;
34 static int pajeEndLinkId = 13;
35 static int pajeCreateContainerWithPowerId = 14;
36 static int pajeStartLinkWithBandwidthLatencyId = 15;
37 static int pajePushStateWithPowerUsedId = 16;
38 static int pajePushStateWithBandwidthUsedId = 17;
39 static int pajeSetStateWithPowerUsedId = 18;
40 static int pajePushStateId = 19;
41 static int pajeCreateContainerWithBandwidthLatencyId = 20;
42 static int pajeCreateContainerWithBandwidthLatencySrcDstId = 21;
43 static int pajeSetVariableId = 22;
44 static int pajeAddVariableId = 23;
45 static int pajeSubVariableId = 24;
46 static int pajeDefineVariableTypeId = 25;
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 pajeDefineContainerTypeId, pajeDefineStateTypeId, pajeDefineEntityValueId,
247 pajeDefineEventTypeId, pajeDefineLinkTypeId, pajeCreateContainerId,
248 pajeDestroyContainerId, pajeSetStateId, pajeSetStateWithHostId,
249 pajePushStateWithHostId, pajePopStateId, pajeSetStateWithHostCommCompId,
250 pajeStartLinkId, pajeEndLinkId, pajeCreateContainerWithPowerId,
251 pajeStartLinkWithBandwidthLatencyId, pajePushStateWithPowerUsedId,
252 pajePushStateWithBandwidthUsedId, pajeSetStateWithPowerUsedId,
253 pajePushStateId, pajeCreateContainerWithBandwidthLatencyId,
254 pajeCreateContainerWithBandwidthLatencySrcDstId,
258 pajeDefineVariableTypeId);
261 /* internal to this file */
262 static void __pajeCreateContainer (char *output, int len, int eventid, double time, const char *alias, const char *type,
263 const char *container, const char *name)
265 snprintf (output, len, "%d %.15lf %s %s %s %s", eventid, time,
266 alias, type, container, name);
269 static void __pajeSetState (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value)
271 snprintf (output, len, "%d %.15lf %s %s %s", eventid, time, entityType, container, value);
274 static void __pajeSetVariable (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value)
276 snprintf (output, len, "%d %.15lf %s %s %s", eventid, time, entityType, container, value);
279 static void __pajeStartLink (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value,
280 const char *sourceContainer, const char *key)
282 snprintf(output, len, "%d %.15lf %s %s %s %s %s", eventid, time, entityType, container, value, sourceContainer, key);
286 /* internal do the instrumentation module */
287 void pajeDefineContainerType(const char *alias, const char *containerType,
289 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineContainerTypeId, alias,
290 containerType, name);
293 void pajeDefineStateType(const char *alias, const char *containerType,
295 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineStateTypeId, alias,
296 containerType, name);
299 void pajeDefineEventType(const char *alias, const char *containerType,
301 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineEventTypeId, alias,
302 containerType, name);
305 void pajeDefineLinkType(const char *alias, const char *containerType,
306 const char *sourceContainerType, const char *destContainerType,
308 fprintf(tracing_file, "%d %s %s %s %s %s\n", pajeDefineLinkTypeId, alias,
309 containerType, sourceContainerType, destContainerType, name);
312 void pajeCreateContainer(double time, const char *alias, const char *type, const char *container, const char *name) {
313 char line[TRACE_LINE_SIZE];
314 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerId, time, alias, type, container, name);
315 fprintf (tracing_file, "%s\n", line);
318 void pajeCreateContainerWithPower (double time, const char *alias, const char *type, const char *container, const char *name, double power)
320 char line[TRACE_LINE_SIZE];
321 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerWithPowerId, time, alias, type, container, name);
322 fprintf (tracing_file, "%s %f\n", line, power);
325 void pajeCreateContainerWithBandwidthLatency (double time, const char *alias, const char *type, const char *container, const char *name, double bw, double lat)
327 char line[TRACE_LINE_SIZE];
328 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerWithBandwidthLatencyId, time, alias, type, container, name);
329 fprintf (tracing_file, "%s %f %f\n", line, bw, lat);
333 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)
335 char line[TRACE_LINE_SIZE];
336 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerWithBandwidthLatencySrcDstId, time, alias, type, container, name);
337 fprintf (tracing_file, "%s %f %f %s %s\n", line, bw, lat, src, dst);
341 void pajeDestroyContainer (double time, const char *type, const char *container)
343 fprintf(tracing_file, "%d %.15lf %s %s\n", pajeDestroyContainerId, time, type, container);
346 void pajeSetState (double time, const char *entityType, const char *container, const char *value)
348 char line[TRACE_LINE_SIZE];
349 __pajeSetState (line, TRACE_LINE_SIZE, pajeSetStateId, time, entityType, container, value);
350 fprintf(tracing_file, "%s\n", line);
353 void pajeSetStateWithPowerUsed (double time, const char *entityType, const char *container, const char *value, double powerUsed)
355 char line[TRACE_LINE_SIZE];
356 __pajeSetState (line, TRACE_LINE_SIZE, pajeSetStateWithPowerUsedId, time, entityType, container, value);
357 fprintf(tracing_file, "%s %f\n", line, powerUsed);
360 void pajeSetStateWithHost (double time, const char *entityType, const char *container, const char *value, const char *host)
362 char line[TRACE_LINE_SIZE];
363 __pajeSetState (line, TRACE_LINE_SIZE, pajeSetStateWithHostId, time, entityType, container, value);
364 fprintf(tracing_file, "%s %s\n", line, host);
367 void pajePushState (double time, const char *entityType, const char *container, const char *value)
369 char line[TRACE_LINE_SIZE];
370 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateId, time, entityType, container, value);
371 fprintf(tracing_file, "%s\n", line);
374 void pajePushStateWithHost (double time, const char *entityType, const char *container, const char *value, const char *host)
376 char line[TRACE_LINE_SIZE];
377 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateWithHostId, time, entityType, container, value);
378 fprintf(tracing_file, "%s %s\n", line, host);
381 void pajePushStateWithPowerUsed (double time, const char *entityType, const char *container, const char *value, double powerUsed)
383 char line[TRACE_LINE_SIZE];
384 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateWithPowerUsedId, time, entityType, container, value);
385 fprintf(tracing_file, "%s %f\n", line, powerUsed);
388 void pajePushStateWithBandwidthUsed (double time, const char *entityType, const char *container, const char *value, double bwUsed)
390 char line[TRACE_LINE_SIZE];
391 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateWithBandwidthUsedId, time, entityType, container, value);
392 fprintf(tracing_file, "%s %f\n", line, bwUsed);
395 void pajePopState (double time, const char *entityType, const char *container)
397 fprintf(tracing_file, "%d %.15lf %s %s\n", pajePopStateId, time, entityType, container);
400 void pajeStartLink (double time, const char *entityType, const char *container, const char *value,
401 const char *sourceContainer, const char *key)
403 char line[TRACE_LINE_SIZE];
404 __pajeStartLink (line, TRACE_LINE_SIZE, pajeStartLinkId, time, entityType, container, value, sourceContainer, key);
405 fprintf (tracing_file, "%s\n", line);
408 void pajeStartLinkWithBandwidthLatency (double time, const char *entityType, const char *container, const char *value,
409 const char *sourceContainer, const char *key, double bw, double lat)
411 char line[TRACE_LINE_SIZE];
412 __pajeStartLink (line, TRACE_LINE_SIZE, pajeStartLinkWithBandwidthLatencyId, time, entityType, container, value, sourceContainer, key);
413 fprintf (tracing_file, "%s %f %f\n", line, bw, lat);
416 void pajeEndLink (double time, const char *entityType, const char *container, const char *value,
417 const char *destContainer, const char *key)
419 fprintf(tracing_file, "%d %.15lf %s %s %s %s %s\n", pajeEndLinkId, time, entityType, container, value, destContainer, key);
422 void pajeDefineVariableType(const char *alias, const char *containerType, const char *name) {
423 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineVariableTypeId, alias, containerType, name);
427 void pajeSetVariable (double time, const char *entityType, const char *container, const char *value)
429 char line[TRACE_LINE_SIZE];
430 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeSetVariableId, time, entityType, container, value);
431 fprintf(tracing_file, "%s\n", line);
434 void pajeAddVariable (double time, const char *entityType, const char *container, const char *value)
436 char line[TRACE_LINE_SIZE];
437 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeAddVariableId, time, entityType, container, value);
438 fprintf(tracing_file, "%s\n", line);
441 void pajeSubVariable (double time, const char *entityType, const char *container, const char *value)
443 char line[TRACE_LINE_SIZE];
444 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeSubVariableId, time, entityType, container, value);
445 fprintf(tracing_file, "%s\n", line);