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;
47 #define TRACE_LINE_SIZE 1000
49 void TRACE_paje_start (FILE *file)
55 FILE *TRACE_paje_end (void)
62 void TRACE_paje_create_header(void) {
68 %%EventDef PajeDefineContainerType %d \n\
70 %% ContainerType string \n\
73 %%EventDef PajeDefineStateType %d \n\
75 %% ContainerType string \n\
78 %%EventDef PajeDefineEntityValue %d \n\
80 %% EntityType string \n\
83 %%EventDef PajeDefineEventType %d \n\
85 %% EntityType string \n\
88 %%EventDef PajeDefineLinkType %d \n\
90 %% ContainerType string \n\
91 %% SourceContainerType string \n\
92 %% DestContainerType string \n\
95 %%EventDef PajeCreateContainer %d \n\
99 %% Container string \n\
102 %%EventDef PajeDestroyContainer %d \n\
105 %% Container string \n\
107 %%EventDef PajeSetState %d \n\
109 %% EntityType string \n\
110 %% Container string \n\
113 %%EventDef PajeSetState %d \n\
115 %% EntityType string \n\
116 %% Container string \n\
120 %%EventDef PajePushState %d \n\
122 %% EntityType string \n\
123 %% Container string \n\
127 %%EventDef PajePopState %d \n\
129 %% EntityType string \n\
130 %% Container string \n\
132 %%EventDef PajeSetState %d \n\
134 %% EntityType string \n\
135 %% Container string \n\
141 %%EventDef PajeStartLink %d \n\
143 %% EntityType string \n\
144 %% Container string \n\
146 %% SourceContainer string \n\
149 %%EventDef PajeEndLink %d \n\
151 %% EntityType string \n\
152 %% Container string \n\
154 %% DestContainer string \n\
157 %%EventDef PajeCreateContainer %d \n\
161 %% Container string \n\
165 %%EventDef PajeStartLink %d \n\
167 %% EntityType string \n\
168 %% Container string \n\
170 %% SourceContainer string \n\
172 %% Bandwidth string \n\
173 %% Latency string \n\
175 %%EventDef PajePushState %d \n\
177 %% EntityType string \n\
178 %% Container string \n\
180 %% PowerUsed string \n\
182 %%EventDef PajePushState %d \n\
184 %% EntityType string \n\
185 %% Container string \n\
187 %% BandwidthUsed string \n\
189 %%EventDef PajeSetState %d \n\
191 %% EntityType string \n\
192 %% Container string \n\
194 %% PowerUsed string \n\
196 %%EventDef PajePushState %d \n\
198 %% EntityType string \n\
199 %% Container string \n\
202 %%EventDef PajeCreateContainer %d \n\
206 %% Container string \n\
208 %% Bandwidth string \n\
209 %% Latency string \n\
211 %%EventDef PajeCreateContainer %d \n\
215 %% Container string \n\
217 %% Bandwidth string \n\
218 %% Latency string \n\
219 %% SrcHost string \n\
220 %% DstHost string \n\
222 %%EventDef PajeSetVariable %d \n\
224 %% EntityType string \n\
225 %% Container string \n\
228 %%EventDef PajeAddVariable %d \n\
230 %% EntityType string \n\
231 %% Container string \n\
234 %%EventDef PajeSubVariable %d \n\
236 %% EntityType string \n\
237 %% Container string \n\
240 %%EventDef PajeDefineVariableType %d \n\
242 %% ContainerType string \n\
245 pajeDefineContainerTypeId, pajeDefineStateTypeId, pajeDefineEntityValueId,
246 pajeDefineEventTypeId, pajeDefineLinkTypeId, pajeCreateContainerId,
247 pajeDestroyContainerId, pajeSetStateId, pajeSetStateWithHostId,
248 pajePushStateWithHostId, pajePopStateId, pajeSetStateWithHostCommCompId,
249 pajeStartLinkId, pajeEndLinkId, pajeCreateContainerWithPowerId,
250 pajeStartLinkWithBandwidthLatencyId, pajePushStateWithPowerUsedId,
251 pajePushStateWithBandwidthUsedId, pajeSetStateWithPowerUsedId,
252 pajePushStateId, pajeCreateContainerWithBandwidthLatencyId,
253 pajeCreateContainerWithBandwidthLatencySrcDstId,
257 pajeDefineVariableTypeId);
260 /* internal to this file */
261 static void __pajeCreateContainer (char *output, int len, int eventid, double time, const char *alias, const char *type,
262 const char *container, const char *name)
264 snprintf (output, len, "%d %.15lf %s %s %s %s", eventid, time,
265 alias, type, container, name);
268 static void __pajeSetState (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value)
270 snprintf (output, len, "%d %.15lf %s %s %s", eventid, time, entityType, container, value);
273 static void __pajeSetVariable (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 __pajeStartLink (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value,
279 const char *sourceContainer, const char *key)
281 snprintf(output, len, "%d %.15lf %s %s %s %s %s", eventid, time, entityType, container, value, sourceContainer, key);
285 /* internal do the instrumentation module */
286 void pajeDefineContainerType(const char *alias, const char *containerType,
288 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineContainerTypeId, alias,
289 containerType, name);
292 void pajeDefineStateType(const char *alias, const char *containerType,
294 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineStateTypeId, alias,
295 containerType, name);
298 void pajeDefineEventType(const char *alias, const char *containerType,
300 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineEventTypeId, alias,
301 containerType, name);
304 void pajeDefineLinkType(const char *alias, const char *containerType,
305 const char *sourceContainerType, const char *destContainerType,
307 fprintf(tracing_file, "%d %s %s %s %s %s\n", pajeDefineLinkTypeId, alias,
308 containerType, sourceContainerType, destContainerType, name);
311 void pajeCreateContainer(double time, const char *alias, const char *type, const char *container, const char *name) {
312 char line[TRACE_LINE_SIZE];
313 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerId, time, alias, type, container, name);
314 fprintf (tracing_file, "%s\n", line);
317 void pajeCreateContainerWithPower (double time, const char *alias, const char *type, const char *container, const char *name, double power)
319 char line[TRACE_LINE_SIZE];
320 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerWithPowerId, time, alias, type, container, name);
321 fprintf (tracing_file, "%s %f\n", line, power);
324 void pajeCreateContainerWithBandwidthLatency (double time, const char *alias, const char *type, const char *container, const char *name, double bw, double lat)
326 char line[TRACE_LINE_SIZE];
327 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerWithBandwidthLatencyId, time, alias, type, container, name);
328 fprintf (tracing_file, "%s %f %f\n", line, bw, lat);
332 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)
334 char line[TRACE_LINE_SIZE];
335 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerWithBandwidthLatencySrcDstId, time, alias, type, container, name);
336 fprintf (tracing_file, "%s %f %f %s %s\n", line, bw, lat, src, dst);
340 void pajeDestroyContainer (double time, const char *type, const char *container)
342 fprintf(tracing_file, "%d %.15lf %s %s\n", pajeDestroyContainerId, time, type, container);
345 void pajeSetState (double time, const char *entityType, const char *container, const char *value)
347 char line[TRACE_LINE_SIZE];
348 __pajeSetState (line, TRACE_LINE_SIZE, pajeSetStateId, time, entityType, container, value);
349 fprintf(tracing_file, "%s\n", line);
352 void pajeSetStateWithPowerUsed (double time, const char *entityType, const char *container, const char *value, double powerUsed)
354 char line[TRACE_LINE_SIZE];
355 __pajeSetState (line, TRACE_LINE_SIZE, pajeSetStateWithPowerUsedId, time, entityType, container, value);
356 fprintf(tracing_file, "%s %f\n", line, powerUsed);
359 void pajeSetStateWithHost (double time, const char *entityType, const char *container, const char *value, const char *host)
361 char line[TRACE_LINE_SIZE];
362 __pajeSetState (line, TRACE_LINE_SIZE, pajeSetStateWithHostId, time, entityType, container, value);
363 fprintf(tracing_file, "%s %s\n", line, host);
366 void pajePushState (double time, const char *entityType, const char *container, const char *value)
368 char line[TRACE_LINE_SIZE];
369 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateId, time, entityType, container, value);
370 fprintf(tracing_file, "%s\n", line);
373 void pajePushStateWithHost (double time, const char *entityType, const char *container, const char *value, const char *host)
375 char line[TRACE_LINE_SIZE];
376 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateWithHostId, time, entityType, container, value);
377 fprintf(tracing_file, "%s %s\n", line, host);
380 void pajePushStateWithPowerUsed (double time, const char *entityType, const char *container, const char *value, double powerUsed)
382 char line[TRACE_LINE_SIZE];
383 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateWithPowerUsedId, time, entityType, container, value);
384 fprintf(tracing_file, "%s %f\n", line, powerUsed);
387 void pajePushStateWithBandwidthUsed (double time, const char *entityType, const char *container, const char *value, double bwUsed)
389 char line[TRACE_LINE_SIZE];
390 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateWithBandwidthUsedId, time, entityType, container, value);
391 fprintf(tracing_file, "%s %f\n", line, bwUsed);
394 void pajePopState (double time, const char *entityType, const char *container)
396 fprintf(tracing_file, "%d %.15lf %s %s\n", pajePopStateId, time, entityType, container);
399 void pajeStartLink (double time, const char *entityType, const char *container, const char *value,
400 const char *sourceContainer, const char *key)
402 char line[TRACE_LINE_SIZE];
403 __pajeStartLink (line, TRACE_LINE_SIZE, pajeStartLinkId, time, entityType, container, value, sourceContainer, key);
404 fprintf (tracing_file, "%s\n", line);
407 void pajeStartLinkWithBandwidthLatency (double time, const char *entityType, const char *container, const char *value,
408 const char *sourceContainer, const char *key, double bw, double lat)
410 char line[TRACE_LINE_SIZE];
411 __pajeStartLink (line, TRACE_LINE_SIZE, pajeStartLinkWithBandwidthLatencyId, time, entityType, container, value, sourceContainer, key);
412 fprintf (tracing_file, "%s %f %f\n", line, bw, lat);
415 void pajeEndLink (double time, const char *entityType, const char *container, const char *value,
416 const char *destContainer, const char *key)
418 fprintf(tracing_file, "%d %.15lf %s %s %s %s %s\n", pajeEndLinkId, time, entityType, container, value, destContainer, key);
421 void pajeDefineVariableType(const char *alias, const char *containerType, const char *name) {
422 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineVariableTypeId, alias, containerType, name);
426 void pajeSetVariable (double time, const char *entityType, const char *container, const char *value)
428 char line[TRACE_LINE_SIZE];
429 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeSetVariableId, time, entityType, container, value);
430 fprintf(tracing_file, "%s\n", line);
433 void pajeAddVariable (double time, const char *entityType, const char *container, const char *value)
435 char line[TRACE_LINE_SIZE];
436 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeAddVariableId, time, entityType, container, value);
437 fprintf(tracing_file, "%s\n", line);
440 void pajeSubVariable (double time, const char *entityType, const char *container, const char *value)
442 char line[TRACE_LINE_SIZE];
443 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeSubVariableId, time, entityType, container, value);
444 fprintf(tracing_file, "%s\n", line);