Logo AND Algorithmique Numérique Distribuée

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