Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make time independent tracing output by default in one file per process
[simgrid.git] / src / instr / instr_private.h
1 /* Copyright (c) 2010-2013. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #ifndef INSTR_PRIVATE_H_
8 #define INSTR_PRIVATE_H_
9
10 #include "instr/instr.h"
11 #include "instr/instr_interface.h"
12 #include "internal_config.h"
13 #include "simgrid_config.h"
14
15 #ifdef HAVE_TRACING
16
17 /* Need to define function drand48 for Windows */
18 #ifdef _WIN32
19 #  define drand48() (rand()/(RAND_MAX + 1.0))
20 #endif
21
22 #define INSTR_DEFAULT_STR_SIZE 500
23
24 #include "xbt/graph.h"
25 #include "xbt/dict.h"
26 #include "simgrid/platf.h"
27
28 typedef enum {
29   PAJE_DefineContainerType,
30   PAJE_DefineVariableType,
31   PAJE_DefineStateType,
32   PAJE_DefineEventType,
33   PAJE_DefineLinkType,
34   PAJE_DefineEntityValue,
35   PAJE_CreateContainer,
36   PAJE_DestroyContainer,
37   PAJE_SetVariable,
38   PAJE_AddVariable,
39   PAJE_SubVariable,
40   PAJE_SetState,
41   PAJE_PushState,
42   PAJE_PopState,
43   PAJE_ResetState,
44   PAJE_StartLink,
45   PAJE_EndLink,
46   PAJE_NewEvent
47 } e_event_type;
48
49 typedef enum {
50   TYPE_VARIABLE,
51   TYPE_LINK,
52   TYPE_CONTAINER,
53   TYPE_STATE,
54   TYPE_EVENT
55 } e_entity_types;
56
57 typedef struct s_type *type_t;
58 typedef struct s_type {
59   char *id;
60   char *name;
61   char *color;
62   e_entity_types kind;
63   struct s_type *father;
64   xbt_dict_t children;
65   xbt_dict_t values; //valid for all types except variable and container
66 }s_type_t;
67
68 typedef struct s_val *val_t;
69 typedef struct s_val {
70   char *id;
71   char *name;
72   char *color;
73   type_t father;
74 }s_val_t;
75
76 typedef enum {
77   INSTR_HOST,
78   INSTR_LINK,
79   INSTR_ROUTER,
80   INSTR_AS,
81   INSTR_SMPI,
82   INSTR_MSG_VM,
83   INSTR_MSG_PROCESS,
84   INSTR_MSG_TASK
85 } e_container_types;
86
87 typedef struct s_container *container_t;
88 typedef struct s_container {
89   sg_routing_edge_t net_elm;
90   char *name;     /* Unique name of this container */
91   char *id;       /* Unique id of this container */
92   type_t type;    /* Type of this container */
93   int level;      /* Level in the hierarchy, root level is 0 */
94   e_container_types kind; /* This container is of what kind */
95   struct s_container *father;
96   xbt_dict_t children;
97 }s_container_t;
98
99 typedef struct paje_event *paje_event_t;
100 typedef struct paje_event {
101   double timestamp;
102   e_event_type event_type;
103   void (*print) (paje_event_t event);
104   void (*free) (paje_event_t event);
105   void *data;
106 } s_paje_event_t;
107
108 typedef struct s_defineContainerType *defineContainerType_t;
109 typedef struct s_defineContainerType {
110   type_t type;
111 }s_defineContainerType_t;
112
113 typedef struct s_defineVariableType *defineVariableType_t;
114 typedef struct s_defineVariableType {
115   type_t type;
116 }s_defineVariableType_t;
117
118 typedef struct s_defineStateType *defineStateType_t;
119 typedef struct s_defineStateType {
120   type_t type;
121 }s_defineStateType_t;
122
123 typedef struct s_defineEventType *defineEventType_t;
124 typedef struct s_defineEventType {
125   type_t type;
126 }s_defineEventType_t;
127
128 typedef struct s_defineLinkType *defineLinkType_t;
129 typedef struct s_defineLinkType {
130   type_t type;
131   type_t source;
132   type_t dest;
133 }s_defineLinkType_t;
134
135 typedef struct s_defineEntityValue *defineEntityValue_t;
136 typedef struct s_defineEntityValue {
137   val_t value;
138 }s_defineEntityValue_t;
139
140 typedef struct s_createContainer *createContainer_t;
141 typedef struct s_createContainer {
142   container_t container;
143 }s_createContainer_t;
144
145 typedef struct s_destroyContainer *destroyContainer_t;
146 typedef struct s_destroyContainer {
147   container_t container;
148 }s_destroyContainer_t;
149
150 typedef struct s_setVariable *setVariable_t;
151 typedef struct s_setVariable {
152   container_t container;
153   type_t type;
154   double value;
155 }s_setVariable_t;
156
157 typedef struct s_addVariable *addVariable_t;
158 typedef struct s_addVariable {
159   container_t container;
160   type_t type;
161   double value;
162 }s_addVariable_t;
163
164 typedef struct s_subVariable *subVariable_t;
165 typedef struct s_subVariable {
166   container_t container;
167   type_t type;
168   double value;
169 }s_subVariable_t;
170
171 typedef struct s_setState *setState_t;
172 typedef struct s_setState {
173   container_t container;
174   type_t type;
175   val_t value;
176 }s_setState_t;
177
178 typedef struct s_pushState *pushState_t;
179 typedef struct s_pushState {
180   container_t container;
181   type_t type;
182   val_t value;
183   int size;
184   void* extra;
185 }s_pushState_t;
186
187 typedef struct s_popState *popState_t;
188 typedef struct s_popState {
189   container_t container;
190   type_t type;
191   xbt_dynar_t extra;
192 }s_popState_t;
193
194 typedef struct s_resetState *resetState_t;
195 typedef struct s_resetState {
196   container_t container;
197   type_t type;
198 }s_resetState_t;
199
200 typedef struct s_startLink *startLink_t;
201 typedef struct s_startLink {
202   container_t container;
203   type_t type;
204   container_t sourceContainer;
205   char *value;
206   char *key;
207   int size;
208 }s_startLink_t;
209
210 typedef struct s_endLink *endLink_t;
211 typedef struct s_endLink {
212   container_t container;
213   type_t type;
214   container_t destContainer;
215   char *value;
216   char *key;
217 }s_endLink_t;
218
219 typedef struct s_newEvent *newEvent_t;
220 typedef struct s_newEvent {
221   container_t container;
222   type_t type;
223   val_t value;
224 }s_newEvent_t;
225
226 extern xbt_dict_t created_categories;
227 extern xbt_dict_t declared_marks;
228 extern xbt_dict_t user_host_variables;
229 extern xbt_dict_t user_vm_variables;
230 extern xbt_dict_t user_link_variables;
231 extern double TRACE_last_timestamp_to_dump;
232
233 /* instr_paje_header.c */
234 void TRACE_header(int basic, int size);
235
236 /* from paje.c */
237 void TRACE_paje_init(void);
238 void TRACE_paje_start(void);
239 void TRACE_paje_end(void);
240 void TRACE_paje_dump_buffer (int force);
241 XBT_PUBLIC(void) new_pajeDefineContainerType(type_t type);
242 XBT_PUBLIC(void) new_pajeDefineVariableType(type_t type);
243 XBT_PUBLIC(void) new_pajeDefineStateType(type_t type);
244 XBT_PUBLIC(void) new_pajeDefineEventType(type_t type);
245 XBT_PUBLIC(void) new_pajeDefineLinkType(type_t type, type_t source, type_t dest);
246 XBT_PUBLIC(void) new_pajeDefineEntityValue (val_t type);
247 XBT_PUBLIC(void) new_pajeCreateContainer (container_t container);
248 XBT_PUBLIC(void) new_pajeDestroyContainer (container_t container);
249 XBT_PUBLIC(void) new_pajeSetVariable (double timestamp, container_t container, type_t type, double value);
250 XBT_PUBLIC(void) new_pajeAddVariable (double timestamp, container_t container, type_t type, double value);
251 XBT_PUBLIC(void) new_pajeSubVariable (double timestamp, container_t container, type_t type, double value);
252 XBT_PUBLIC(void) new_pajeSetState (double timestamp, container_t container, type_t type, val_t value);
253 XBT_PUBLIC(void) new_pajePushState (double timestamp, container_t container, type_t type, val_t value);
254 XBT_PUBLIC(void) new_pajePushStateWithExtra (double timestamp, container_t container, type_t type, val_t value, void* extra);
255 XBT_PUBLIC(void) new_pajePopState (double timestamp, container_t container, type_t type);
256 XBT_PUBLIC(void) new_pajeResetState (double timestamp, container_t container, type_t type);
257 XBT_PUBLIC(void) new_pajeStartLink (double timestamp, container_t container, type_t type, container_t sourceContainer, const char *value, const char *key);
258 XBT_PUBLIC(void) new_pajeStartLinkWithSize (double timestamp, container_t container, type_t type, container_t sourceContainer, const char *value, const char *key, int size);
259 XBT_PUBLIC(void) new_pajeEndLink (double timestamp, container_t container, type_t type, container_t destContainer, const char *value, const char *key);
260 XBT_PUBLIC(void) new_pajeNewEvent (double timestamp, container_t container, type_t type, val_t value);
261
262 //for tracing gtnets
263 void TRACE_surf_gtnets_communicate(void *action, void *src, void *dst);
264
265 /* from instr_config.c */
266 int TRACE_needs_platform (void);
267 int TRACE_is_enabled(void);
268 int TRACE_platform(void);
269 int TRACE_platform_topology(void);
270 int TRACE_is_configured(void);
271 int TRACE_categorized (void);
272 int TRACE_uncategorized (void);
273 int TRACE_msg_process_is_enabled(void);
274 int TRACE_msg_vm_is_enabled(void);
275 int TRACE_buffer (void);
276 int TRACE_disable_link(void);
277 int TRACE_disable_power(void);
278 int TRACE_onelink_only (void);
279 int TRACE_disable_destroy (void);
280 int TRACE_basic (void);
281 int TRACE_display_sizes (void);
282 char *TRACE_get_comment (void);
283 char *TRACE_get_comment_file (void);
284 char *TRACE_get_filename(void);
285 char *TRACE_get_viva_uncat_conf (void);
286 char *TRACE_get_viva_cat_conf (void);
287 void TRACE_generate_viva_uncat_conf (void);
288 void TRACE_generate_viva_cat_conf (void);
289 void instr_pause_tracing (void);
290 void instr_resume_tracing (void);
291
292 /* Public functions used in SMPI */
293 XBT_PUBLIC(int) TRACE_smpi_is_enabled(void);
294 XBT_PUBLIC(int) TRACE_smpi_is_grouped(void);
295 XBT_PUBLIC(int) TRACE_smpi_is_computing(void);
296 XBT_PUBLIC(int) TRACE_smpi_view_internals(void);
297
298 /* from resource_utilization.c */
299 void TRACE_surf_host_set_utilization(const char *resource,
300                                      const char *category,
301                                      double value,
302                                      double now,
303                                      double delta);
304 void TRACE_surf_link_set_utilization(const char *resource,
305                                      const char *category,
306                                      double value,
307                                      double now,
308                                      double delta);
309 void TRACE_surf_resource_utilization_alloc(void);
310
311 /* instr_paje.c */
312 extern xbt_dict_t trivaNodeTypes;
313 extern xbt_dict_t trivaEdgeTypes;
314 long long int instr_new_paje_id (void);
315 void PJ_container_alloc (void);
316 void PJ_container_release (void);
317 XBT_PUBLIC(container_t) PJ_container_new (const char *name, e_container_types kind, container_t father);
318 XBT_PUBLIC(container_t) PJ_container_get (const char *name);
319 XBT_PUBLIC(container_t) PJ_container_get_or_null (const char *name);
320 XBT_PUBLIC(container_t) PJ_container_get_root (void);
321 XBT_PUBLIC(void) PJ_container_set_root (container_t root);
322 XBT_PUBLIC(void) PJ_container_free (container_t container);
323 XBT_PUBLIC(void) PJ_container_free_all (void);
324 XBT_PUBLIC(void) PJ_container_remove_from_parent (container_t container);
325
326 /* instr_paje_types.c */
327 void PJ_type_alloc (void);
328 void PJ_type_release (void);
329 XBT_PUBLIC(type_t)  PJ_type_get_root (void);
330 type_t PJ_type_container_new (const char *name, type_t father);
331 type_t PJ_type_event_new (const char *name, type_t father);
332 type_t PJ_type_variable_new (const char *name, const char *color, type_t father);
333 type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t dest);
334 type_t PJ_type_state_new (const char *name, type_t father);
335 XBT_PUBLIC(type_t)  PJ_type_get (const char *name, const type_t father);
336 XBT_PUBLIC(type_t)  PJ_type_get_or_null (const char *name, type_t father);
337 void PJ_type_free (type_t type);
338 void PJ_type_free_all (void);
339
340 /* instr_paje_values.c */
341 XBT_PUBLIC(val_t)  PJ_value_new (const char *name, const char *color, type_t father);
342 XBT_PUBLIC(val_t)  PJ_value_get_or_new (const char *name, const char *color, type_t father);
343 XBT_PUBLIC(val_t)  PJ_value_get (const char *name, const type_t father);
344 void PJ_value_free (val_t value);
345
346
347 void print_pajeDefineContainerType(paje_event_t event);
348 void print_pajeDefineVariableType(paje_event_t event);
349 void print_pajeDefineStateType(paje_event_t event);
350 void print_pajeDefineEventType(paje_event_t event);
351 void print_pajeDefineLinkType(paje_event_t event);
352 void print_pajeDefineEntityValue (paje_event_t event);
353 void print_pajeCreateContainer(paje_event_t event);
354 void print_pajeDestroyContainer(paje_event_t event);
355 void print_pajeSetVariable(paje_event_t event);
356 void print_pajeAddVariable(paje_event_t event);
357 void print_pajeSubVariable(paje_event_t event);
358 void print_pajeSetState(paje_event_t event);
359 void print_pajePushState(paje_event_t event);
360 void print_pajePopState(paje_event_t event);
361 void print_pajeResetState(paje_event_t event);
362 void print_pajeStartLink(paje_event_t event);
363 void print_pajeEndLink(paje_event_t event);
364 void print_pajeNewEvent (paje_event_t event);
365
366 void print_TIPushState(paje_event_t event);
367 void print_TICreateContainer(paje_event_t event);
368 void print_TIDestroyContainer(paje_event_t event);
369 void TRACE_TI_start(void);
370 void TRACE_TI_end(void);
371 void TRACE_TI_init(void);
372
373 void print_NULL (paje_event_t event);
374 void TRACE_paje_dump_buffer (int force);
375 void dump_comment_file (const char *filename);
376 void dump_comment (const char *comment);
377
378
379
380
381 typedef struct instr_trace_writer {
382   void (*print_DefineContainerType) (paje_event_t event);
383   void (*print_DefineVariableType)(paje_event_t event);
384   void (*print_DefineStateType)(paje_event_t event);
385   void (*print_DefineEventType)(paje_event_t event);
386   void (*print_DefineLinkType)(paje_event_t event);
387   void (*print_DefineEntityValue)(paje_event_t event);
388   void (*print_CreateContainer)(paje_event_t event);
389   void (*print_DestroyContainer)(paje_event_t event);
390   void (*print_SetVariable)(paje_event_t event);
391   void (*print_AddVariable)(paje_event_t event);
392   void (*print_SubVariable)(paje_event_t event);
393   void (*print_SetState)(paje_event_t event);
394   void (*print_PushState)(paje_event_t event);
395   void (*print_PopState)(paje_event_t event);
396   void (*print_ResetState)(paje_event_t event);
397   void (*print_StartLink)(paje_event_t event);
398   void (*print_EndLink)(paje_event_t event);
399   void (*print_NewEvent) (paje_event_t event);
400 } s_instr_trace_writer_t;
401
402
403
404 struct s_instr_extra_data;
405 typedef struct s_instr_extra_data *instr_extra_data;
406
407
408 typedef enum{
409   TRACING_INIT,
410   TRACING_FINALIZE,
411   TRACING_COMM_SIZE,
412   TRACING_COMM_SPLIT,
413   TRACING_COMM_DUP,
414   TRACING_SEND,
415   TRACING_ISEND,
416   TRACING_SSEND,
417   TRACING_ISSEND,
418   TRACING_RECV,
419   TRACING_IRECV,
420   TRACING_SENDRECV,
421   TRACING_WAIT,
422   TRACING_WAITALL,
423   TRACING_WAITANY,
424   TRACING_BARRIER,
425   TRACING_BCAST,
426   TRACING_REDUCE,
427   TRACING_ALLREDUCE,
428   TRACING_ALLTOALL,
429   TRACING_ALLTOALLV,
430   TRACING_GATHER,
431   TRACING_GATHERV,
432   TRACING_SCATTER,
433   TRACING_SCATTERV,
434   TRACING_ALLGATHER,
435   TRACING_ALLGATHERV,
436   TRACING_REDUCE_SCATTER,
437   TRACING_COMPUTING,
438   TRACING_SCAN,
439   TRACING_EXSCAN
440 } e_caller_type ;
441
442
443
444 typedef struct s_instr_extra_data {
445   e_caller_type type;
446   int send_size;
447   int recv_size;
448   double comp_size;
449   int src;
450   int dst;
451   int root;
452   const char* datatype1;
453   const char* datatype2;
454   int * sendcounts;
455   int * recvcounts;
456   int num_processes;
457 } s_instr_extra_data_t;
458
459 #endif /* HAVE_TRACING */
460
461 #ifdef HAVE_JEDULE
462 #include "instr/jedule/jedule_sd_binding.h"
463 #endif
464
465
466
467
468
469
470 #endif /* INSTR_PRIVATE_H_ */