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;
22 static int pajePopStateId = 8;
23 static int pajeDestroyContainerId = 9;
26 static int pajeStartLinkId = 12;
27 static int pajeEndLinkId = 13;
33 static int pajePushStateId = 19;
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 PajePopState %d \n\
111 %% EntityType string \n\
112 %% Container string \n\
114 %%EventDef PajeStartLink %d \n\
116 %% EntityType string \n\
117 %% Container string \n\
119 %% SourceContainer string \n\
122 %%EventDef PajeEndLink %d \n\
124 %% EntityType string \n\
125 %% Container string \n\
127 %% DestContainer string \n\
130 %%EventDef PajePushState %d \n\
132 %% EntityType string \n\
133 %% Container string \n\
136 %%EventDef PajeSetVariable %d \n\
138 %% EntityType string \n\
139 %% Container string \n\
142 %%EventDef PajeAddVariable %d \n\
144 %% EntityType string \n\
145 %% Container string \n\
148 %%EventDef PajeSubVariable %d \n\
150 %% EntityType string \n\
151 %% Container string \n\
154 %%EventDef PajeDefineVariableType %d \n\
156 %% ContainerType string \n\
159 %%EventDef PajeStartLink %d \n\
161 %% EntityType string \n\
162 %% Container string \n\
164 %% SourceContainer string \n\
168 %%EventDef PajeNewEvent %d \n\
170 %% EntityType string \n\
171 %% Container string \n\
174 pajeDefineContainerTypeId, pajeDefineStateTypeId, pajeDefineEntityValueId,
175 pajeDefineEventTypeId, pajeDefineLinkTypeId, pajeCreateContainerId,
176 pajeDestroyContainerId, pajeSetStateId,
178 pajeStartLinkId, pajeEndLinkId,
183 pajeDefineVariableTypeId,
184 pajeStartLinkWithVolumeId,
188 /* internal to this file */
189 static void __pajeCreateContainer (char *output, int len, int eventid, double time, const char *alias, const char *type,
190 const char *container, const char *name)
192 snprintf (output, len, "%d %lf %s %s %s %s", eventid, time,
193 alias, type, container, name);
196 static void __pajeSetState (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value)
198 snprintf (output, len, "%d %lf %s %s %s", eventid, time, entityType, container, value);
201 static void __pajeSetVariable (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value)
203 snprintf (output, len, "%d %lf %s %s %s", eventid, time, entityType, container, value);
206 static void __pajeStartLink (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value,
207 const char *sourceContainer, const char *key)
209 snprintf(output, len, "%d %lf %s %s %s %s %s", eventid, time, entityType, container, value, sourceContainer, key);
212 /* internal do the instrumentation module */
213 void pajeDefineContainerType(const char *alias, const char *containerType,
215 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineContainerTypeId, alias,
216 containerType, name);
219 void pajeDefineStateType(const char *alias, const char *containerType,
221 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineStateTypeId, alias,
222 containerType, name);
225 void pajeDefineEventType(const char *alias, const char *containerType,
227 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineEventTypeId, alias,
228 containerType, name);
231 void pajeDefineLinkType(const char *alias, const char *containerType,
232 const char *sourceContainerType, const char *destContainerType,
234 fprintf(tracing_file, "%d %s %s %s %s %s\n", pajeDefineLinkTypeId, alias,
235 containerType, sourceContainerType, destContainerType, name);
238 void pajeCreateContainer(double time, const char *alias, const char *type, const char *container, const char *name) {
239 char line[TRACE_LINE_SIZE];
240 __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerId, time, alias, type, container, name);
241 fprintf (tracing_file, "%s\n", line);
244 void pajeDestroyContainer (double time, const char *type, const char *container)
246 fprintf(tracing_file, "%d %lf %s %s\n", pajeDestroyContainerId, time, type, container);
249 void pajeSetState (double time, const char *entityType, const char *container, const char *value)
251 char line[TRACE_LINE_SIZE];
252 __pajeSetState (line, TRACE_LINE_SIZE, pajeSetStateId, time, entityType, container, value);
253 fprintf(tracing_file, "%s\n", line);
256 void pajePushState (double time, const char *entityType, const char *container, const char *value)
258 char line[TRACE_LINE_SIZE];
259 __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateId, time, entityType, container, value);
260 fprintf(tracing_file, "%s\n", line);
263 void pajePopState (double time, const char *entityType, const char *container)
265 fprintf(tracing_file, "%d %lf %s %s\n", pajePopStateId, time, entityType, container);
268 void pajeStartLink (double time, const char *entityType, const char *container, const char *value,
269 const char *sourceContainer, const char *key)
271 char line[TRACE_LINE_SIZE];
272 __pajeStartLink (line, TRACE_LINE_SIZE, pajeStartLinkId, time, entityType, container, value, sourceContainer, key);
273 fprintf (tracing_file, "%s\n", line);
276 void pajeStartLinkWithVolume (double time, const char *entityType, const char *container, const char *value,
277 const char *sourceContainer, const char *key, double volume)
279 char line[TRACE_LINE_SIZE];
280 __pajeStartLink (line, TRACE_LINE_SIZE, pajeStartLinkWithVolumeId, time, entityType, container, value, sourceContainer, key);
281 fprintf (tracing_file, "%s %f\n", line, volume);
284 void pajeEndLink (double time, const char *entityType, const char *container, const char *value,
285 const char *destContainer, const char *key)
287 fprintf(tracing_file, "%d %lf %s %s %s %s %s\n", pajeEndLinkId, time, entityType, container, value, destContainer, key);
290 void pajeDefineVariableType(const char *alias, const char *containerType, const char *name) {
291 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineVariableTypeId, alias, containerType, name);
294 void pajeSetVariable (double time, const char *entityType, const char *container, const char *value)
296 char line[TRACE_LINE_SIZE];
297 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeSetVariableId, time, entityType, container, value);
298 fprintf(tracing_file, "%s\n", line);
301 void pajeAddVariable (double time, const char *entityType, const char *container, const char *value)
303 char line[TRACE_LINE_SIZE];
304 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeAddVariableId, time, entityType, container, value);
305 fprintf(tracing_file, "%s\n", line);
308 void pajeSubVariable (double time, const char *entityType, const char *container, const char *value)
310 char line[TRACE_LINE_SIZE];
311 __pajeSetVariable (line, TRACE_LINE_SIZE, pajeSubVariableId, time, entityType, container, value);
312 fprintf(tracing_file, "%s\n", line);
315 void pajeNewEvent (double time, const char *entityType, const char *container, const char *value)
317 fprintf(tracing_file, "%d %lf %s %s %s\n", pajeNewEventId, time, entityType, container, value);