Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove DefineContainerEvent
[simgrid.git] / src / instr / instr_private.h
1 /* Copyright (c) 2010-2017. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef INSTR_PRIVATE_H_
7 #define INSTR_PRIVATE_H_
8
9 #include <xbt/base.h>
10
11 #include "simgrid/instr.h"
12 #include "instr/instr_interface.h"
13 #include "src/internal_config.h"
14 #include "simgrid_config.h"
15
16 SG_BEGIN_DECL()
17
18 /* Need to define function drand48 for Windows */
19 /* FIXME: use _drand48() defined in src/surf/random_mgr.c instead */
20 #ifdef _WIN32
21 #  define drand48() (rand()/(RAND_MAX + 1.0))
22 #endif
23
24 #define INSTR_DEFAULT_STR_SIZE 500
25
26 #include "xbt/graph.h"
27 #include "xbt/dict.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 //--------------------------------------------------
59 class s_type;
60 typedef s_type *type_t;
61 class s_type {
62   public:
63   char *id;
64   char *name;
65   char *color;
66   e_entity_types kind;
67   s_type *father;
68   xbt_dict_t children;
69   xbt_dict_t values; //valid for all types except variable and container
70 };
71
72 typedef s_type s_type_t;
73
74 //--------------------------------------------------
75 class s_val;
76 typedef s_val *val_t;
77
78 class s_val {
79   public:
80   char *id;
81   char *name;
82   char *color;
83   type_t father;
84 };
85 typedef s_val s_val_t;
86
87 //--------------------------------------------------
88 typedef enum {
89   INSTR_HOST,
90   INSTR_LINK,
91   INSTR_ROUTER,
92   INSTR_AS,
93   INSTR_SMPI,
94   INSTR_MSG_VM,
95   INSTR_MSG_PROCESS,
96   INSTR_MSG_TASK
97 } e_container_types;
98
99 //--------------------------------------------------
100 class s_container;
101 typedef s_container *container_t;
102
103 class s_container {
104   public: 
105   sg_netpoint_t netpoint;
106   char *name;     /* Unique name of this container */
107   char *id;       /* Unique id of this container */
108   type_t type;    /* Type of this container */
109   int level;      /* Level in the hierarchy, root level is 0 */
110   e_container_types kind; /* This container is of what kind */
111   s_container *father;
112   xbt_dict_t children;
113 };
114 typedef s_container s_container_t;
115
116 //--------------------------------------------------
117 class PajeEvent {
118   public:
119   double timestamp;
120   e_event_type event_type;
121   virtual void print() = 0;
122   void *data;
123   virtual ~PajeEvent();
124 };
125
126 //--------------------------------------------------
127
128 class DefineVariableTypeEvent : public PajeEvent 
129 {
130   public:
131   type_t type;
132    DefineVariableTypeEvent(type_t type);
133    void print() override;
134 };
135 //--------------------------------------------------
136
137 class DefineStateTypeEvent : public PajeEvent  {
138   type_t type;
139   public:
140   DefineStateTypeEvent(type_t type);
141   void print() override;
142 };
143
144 class DefineEventTypeEvent : public PajeEvent  {
145   type_t type;
146   public: 
147   DefineEventTypeEvent(type_t type);
148   void print() override;
149 };
150
151 class DefineLinkTypeEvent : public PajeEvent  {
152   type_t type;
153   type_t source;
154   type_t dest;
155   public:
156   DefineLinkTypeEvent(type_t type, type_t source, type_t dest);
157   void print() override;
158 };
159
160 class DefineEntityValueEvent : public PajeEvent  {
161   val_t value;
162   public:
163   DefineEntityValueEvent (val_t type);
164   void print() override;
165 };
166
167 class CreateContainerEvent : public PajeEvent  {
168   public:
169   container_t container;
170   explicit CreateContainerEvent (container_t container);
171   void print() override;
172 };
173
174 class DestroyContainerEvent : public PajeEvent  {
175   public:
176   container_t container;
177   DestroyContainerEvent (container_t container);
178   void print() override;
179 };
180
181
182 class SetVariableEvent : public PajeEvent  {
183   container_t container;
184   type_t type;
185   double value;
186   public:
187   SetVariableEvent (double timestamp, container_t container, type_t type, double value);
188   void print() override;
189 };
190
191
192 class AddVariableEvent:public PajeEvent {
193   container_t container;
194   type_t type;
195   double value;
196   public:
197   AddVariableEvent (double timestamp, container_t container, type_t type, double value);
198   void print() override;
199 };
200
201 //--------------------------------------------------
202
203
204 class SubVariableEvent : public PajeEvent  {
205   public:
206   container_t container;
207   type_t type;
208   double value; 
209   public:
210   SubVariableEvent(double timestamp, container_t container, type_t type, double value);
211   void print() override;
212 };
213 //--------------------------------------------------
214
215 class SetStateEvent : public PajeEvent  {
216   public:
217   container_t container;
218   type_t type;
219   val_t value;
220   const char* filename;
221   int linenumber;
222   public:
223   SetStateEvent (double timestamp, container_t container, type_t type, val_t value);
224   void print() override;
225 };
226
227
228 class PushStateEvent : public PajeEvent  {
229   public:
230   container_t container;
231   type_t type;
232   val_t value;
233   int size;
234   const char* filename;
235   int linenumber;
236   void* extra_;
237   public:
238   PushStateEvent (double timestamp, container_t container, type_t type, val_t value);
239   PushStateEvent (double timestamp, container_t container, type_t type, val_t value,
240                                              void* extra);
241   void print() override;
242 };
243
244 class PopStateEvent : public PajeEvent  {
245   container_t container;
246   type_t type;
247   public:
248   PopStateEvent (double timestamp, container_t container, type_t type);
249   void print() override;
250 };
251
252 class ResetStateEvent : public PajeEvent  {
253   container_t container;
254   type_t type;
255   public:
256   ResetStateEvent (double timestamp, container_t container, type_t type);
257   void print() override;
258 };
259
260 class StartLinkEvent : public PajeEvent  {
261   public:
262   container_t container;
263   type_t type;
264   container_t sourceContainer;
265   char *value;
266   char *key;
267   int size;
268   public:
269     ~StartLinkEvent();
270     StartLinkEvent(double timestamp, container_t container, type_t type, container_t sourceContainer, const char* value,
271                    const char* key);
272     StartLinkEvent(double timestamp, container_t container, type_t type, container_t sourceContainer, const char* value,
273                    const char* key, int size);
274     void print() override;
275 };
276
277 class EndLinkEvent : public PajeEvent  {
278   container_t container;
279   type_t type;
280   container_t destContainer;
281   char *value;
282   char *key;
283   public:
284   EndLinkEvent (double timestamp, container_t container, type_t type, container_t destContainer,
285                                   const char *value, const char *key);
286   ~EndLinkEvent();
287   void print() override;
288 };
289
290
291 class NewEvent : public PajeEvent  {
292   public:
293   container_t container;
294   type_t type;
295   val_t value;
296   public:
297   NewEvent (double timestamp, container_t container, type_t type, val_t value);
298   void print() override;
299
300 };
301
302
303 extern XBT_PRIVATE xbt_dict_t created_categories;
304 extern XBT_PRIVATE xbt_dict_t declared_marks;
305 extern XBT_PRIVATE xbt_dict_t user_host_variables;
306 extern XBT_PRIVATE xbt_dict_t user_vm_variables;
307 extern XBT_PRIVATE xbt_dict_t user_link_variables;
308 extern XBT_PRIVATE double TRACE_last_timestamp_to_dump;
309
310 /* instr_paje_header.c */
311 XBT_PRIVATE void TRACE_header(int basic, int size);
312
313 /* from paje.c */
314 XBT_PRIVATE void TRACE_paje_start();
315 XBT_PRIVATE void TRACE_paje_end();
316 XBT_PRIVATE void TRACE_paje_dump_buffer (int force);
317
318
319 /* from instr_config.c */
320 XBT_PRIVATE bool TRACE_needs_platform ();
321 XBT_PRIVATE bool TRACE_is_enabled();
322 XBT_PRIVATE bool TRACE_platform();
323 XBT_PRIVATE bool TRACE_platform_topology();
324 XBT_PRIVATE bool TRACE_is_configured();
325 XBT_PRIVATE bool TRACE_categorized ();
326 XBT_PRIVATE bool TRACE_uncategorized ();
327 XBT_PRIVATE bool TRACE_msg_process_is_enabled();
328 XBT_PRIVATE bool TRACE_msg_vm_is_enabled();
329 XBT_PRIVATE bool TRACE_buffer ();
330 XBT_PRIVATE bool TRACE_disable_link();
331 XBT_PRIVATE bool TRACE_disable_speed();
332 XBT_PRIVATE bool TRACE_onelink_only ();
333 XBT_PRIVATE bool TRACE_disable_destroy ();
334 XBT_PRIVATE bool TRACE_basic ();
335 XBT_PRIVATE bool TRACE_display_sizes ();
336 XBT_PRIVATE char *TRACE_get_comment ();
337 XBT_PRIVATE char *TRACE_get_comment_file ();
338 XBT_PRIVATE int TRACE_precision ();
339 XBT_PRIVATE char *TRACE_get_filename();
340 XBT_PRIVATE char *TRACE_get_viva_uncat_conf ();
341 XBT_PRIVATE char *TRACE_get_viva_cat_conf ();
342 XBT_PRIVATE void TRACE_generate_viva_uncat_conf ();
343 XBT_PRIVATE void TRACE_generate_viva_cat_conf ();
344 XBT_PRIVATE void instr_pause_tracing ();
345 XBT_PRIVATE void instr_resume_tracing ();
346
347 /* Public functions used in SMPI */
348 XBT_PUBLIC(bool) TRACE_smpi_is_enabled();
349 XBT_PUBLIC(bool) TRACE_smpi_is_grouped();
350 XBT_PUBLIC(bool) TRACE_smpi_is_computing();
351 XBT_PUBLIC(bool) TRACE_smpi_is_sleeping();
352 XBT_PUBLIC(bool) TRACE_smpi_view_internals();
353
354 /* from resource_utilization.c */
355 XBT_PRIVATE void TRACE_surf_host_set_utilization(const char *resource, const char *category, double value, double now,
356                                      double delta);
357 XBT_PRIVATE void TRACE_surf_link_set_utilization(const char *resource,const char *category, double value, double now,
358                                      double delta);
359 XBT_PUBLIC(void) TRACE_surf_resource_utilization_alloc();
360
361 /* instr_paje.c */
362 extern XBT_PRIVATE xbt_dict_t trivaNodeTypes;
363 extern XBT_PRIVATE xbt_dict_t trivaEdgeTypes;
364 XBT_PRIVATE long long int instr_new_paje_id ();
365 XBT_PRIVATE void PJ_container_alloc ();
366 XBT_PRIVATE void PJ_container_release ();
367 XBT_PUBLIC(container_t) PJ_container_new (const char *name, e_container_types kind, container_t father);
368 XBT_PUBLIC(container_t) PJ_container_get (const char *name);
369 XBT_PUBLIC(container_t) PJ_container_get_or_null (const char *name);
370 XBT_PUBLIC(container_t) PJ_container_get_root ();
371 XBT_PUBLIC(void) PJ_container_set_root (container_t root);
372 XBT_PUBLIC(void) PJ_container_free (container_t container);
373 XBT_PUBLIC(void) PJ_container_free_all (void);
374 XBT_PUBLIC(void) PJ_container_remove_from_parent (container_t container);
375
376 /* instr_paje_types.c */
377 XBT_PRIVATE void PJ_type_alloc ();
378 XBT_PRIVATE void PJ_type_release ();
379 XBT_PUBLIC(type_t)  PJ_type_get_root ();
380 XBT_PRIVATE type_t PJ_type_container_new (const char *name, type_t father);
381 XBT_PRIVATE type_t PJ_type_event_new (const char *name, type_t father);
382 type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t dest);
383 XBT_PRIVATE XBT_PRIVATE type_t PJ_type_variable_new (const char *name, const char *color, type_t father);
384 XBT_PRIVATE type_t PJ_type_state_new (const char *name, type_t father);
385 XBT_PUBLIC(type_t)  PJ_type_get (const char *name, const type_t father);
386 XBT_PUBLIC(type_t)  PJ_type_get_or_null (const char *name, type_t father);
387 void PJ_type_free_all ();
388 XBT_PRIVATE XBT_PRIVATE void PJ_type_free (type_t type);
389
390 /* instr_paje_values.c */
391 XBT_PUBLIC(val_t)  PJ_value_new (const char *name, const char *color, type_t father);
392 XBT_PUBLIC(val_t)  PJ_value_get_or_new (const char *name, const char *color, type_t father);
393 XBT_PUBLIC(val_t)  PJ_value_get (const char *name, const type_t father);
394 XBT_PRIVATE void PJ_value_free (val_t value);
395
396 XBT_PRIVATE void TRACE_TI_start();
397 XBT_PRIVATE void TRACE_TI_end();
398
399 XBT_PRIVATE void print_NULL (PajeEvent* event);
400 XBT_PRIVATE void TRACE_paje_dump_buffer (int force);
401 XBT_PRIVATE void dump_comment_file (const char *filename);
402 XBT_PRIVATE void dump_comment (const char *comment);
403
404 struct s_instr_extra_data;
405 typedef struct s_instr_extra_data *instr_extra_data;
406
407 typedef enum{
408   TRACING_INIT,
409   TRACING_FINALIZE,
410   TRACING_COMM_SIZE,
411   TRACING_COMM_SPLIT,
412   TRACING_COMM_DUP,
413   TRACING_SEND,
414   TRACING_ISEND,
415   TRACING_SSEND,
416   TRACING_ISSEND,
417   TRACING_RECV,
418   TRACING_IRECV,
419   TRACING_SENDRECV,
420   TRACING_TEST,
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_SLEEPING,
439   TRACING_SCAN,
440   TRACING_EXSCAN
441 } e_caller_type ;
442
443 typedef struct s_instr_extra_data {
444   e_caller_type type;
445   int send_size;
446   int recv_size;
447   double comp_size;
448   double sleep_duration;
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 /* Format of TRACING output.
460  *   - paje is the regular format, that we all know
461  *   - TI is a trick to reuse the tracing functions to generate a time independent trace during the execution. Such trace can easily be replayed with smpi_replay afterward.
462  *     This trick should be removed and replaced by some code using the signal that we will create to cleanup the TRACING
463  */
464 typedef enum { instr_fmt_paje, instr_fmt_TI } instr_fmt_type_t;
465 extern instr_fmt_type_t instr_fmt_type;
466
467 SG_END_DECL()
468
469 void DefineContainerEvent(type_t type);
470
471 #endif