Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
instr: kill an unused field
[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 "instr/instr_interface.h"
12 #include "simgrid/instr.h"
13 #include "simgrid_config.h"
14 #include "src/internal_config.h"
15 #include <set>
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
28 namespace simgrid {
29 namespace instr {
30 typedef enum {
31   PAJE_DefineContainerType,
32   PAJE_DefineVariableType,
33   PAJE_DefineStateType,
34   PAJE_DefineEventType,
35   PAJE_DefineLinkType,
36   PAJE_DefineEntityValue,
37   PAJE_CreateContainer,
38   PAJE_DestroyContainer,
39   PAJE_SetVariable,
40   PAJE_AddVariable,
41   PAJE_SubVariable,
42   PAJE_SetState,
43   PAJE_PushState,
44   PAJE_PopState,
45   PAJE_ResetState,
46   PAJE_StartLink,
47   PAJE_EndLink,
48   PAJE_NewEvent
49 } e_event_type;
50
51 typedef enum {
52   TYPE_VARIABLE,
53   TYPE_LINK,
54   TYPE_CONTAINER,
55   TYPE_STATE,
56   TYPE_EVENT
57 } e_entity_types;
58
59 //--------------------------------------------------
60
61 class Type {
62 public:
63   char* id_;
64   char* name_;
65   char* color_;
66
67   e_entity_types kind_;
68   Type* father_;
69   xbt_dict_t children_;
70   xbt_dict_t values_; // valid for all types except variable and container
71   Type(const char* typeNameBuff, const char* key, const char* color, e_entity_types kind, Type* father);
72   static Type* getOrNull(const char* name, Type* father);
73   static Type* containerNew(const char* name, Type* father);
74   static Type* eventNew(const char* name, Type* father);
75   static Type* variableNew(const char* name, const char* color, Type* father);
76   static Type* linkNew(const char* name, Type* father, Type* source, Type* dest);
77   static Type* stateNew(const char* name, Type* father);
78 };
79
80 //--------------------------------------------------
81 class Value {
82 public:
83   char* id_;
84   char* name_;
85   char* color_;
86
87   Type* father_;
88   Value* ret_;
89   Value(const char* name, const char* color, Type* father);
90   ~Value();
91   static Value* get_or_new(const char* name, const char* color, Type* father);
92   static Value* get(const char* name, Type* father);
93 };
94
95
96 //--------------------------------------------------
97 typedef enum {
98   INSTR_HOST,
99   INSTR_LINK,
100   INSTR_ROUTER,
101   INSTR_AS,
102   INSTR_SMPI,
103   INSTR_MSG_VM,
104   INSTR_MSG_PROCESS,
105   INSTR_MSG_TASK
106 } e_container_types;
107
108 //--------------------------------------------------
109
110 class Container {
111 public:
112   sg_netpoint_t netpoint_;
113   char* name_;             /* Unique name of this container */
114   char* id_;               /* Unique id of this container */
115   Type* type_;             /* Type of this container */
116   int level_;              /* Level in the hierarchy, root level is 0 */
117   e_container_types kind_; /* This container is of what kind */
118   Container* father_;
119   xbt_dict_t children_;
120 };
121
122 //--------------------------------------------------
123 class PajeEvent {
124   public:
125     double timestamp_;
126     e_event_type eventType_;
127     virtual void print() = 0;
128     virtual ~PajeEvent();
129 };
130
131 //--------------------------------------------------
132
133 class DefineVariableTypeEvent : public PajeEvent
134 {
135   public:
136     Type* type;
137     DefineVariableTypeEvent(Type* type);
138     void print() override;
139 };
140 //--------------------------------------------------
141
142 class DefineStateTypeEvent : public PajeEvent  {
143   Type* type;
144
145 public:
146   DefineStateTypeEvent(Type* type);
147   void print() override;
148 };
149
150
151 class SetVariableEvent : public PajeEvent  {
152   private:
153     Container* container;
154     Type* type;
155     double value;
156
157   public:
158     SetVariableEvent(double timestamp, Container* container, Type* type, double value);
159     void print() override;
160 };
161
162
163 class AddVariableEvent:public PajeEvent {
164   private:
165     Container* container;
166     Type* type;
167     double value;
168
169   public:
170     AddVariableEvent(double timestamp, Container* container, Type* type, double value);
171     void print() override;
172 };
173
174 //--------------------------------------------------
175
176
177 class SubVariableEvent : public PajeEvent  {
178   private:
179     Container* container;
180     Type* type;
181     double value;
182
183   public:
184     SubVariableEvent(double timestamp, Container* container, Type* type, double value);
185     void print() override;
186 };
187 //--------------------------------------------------
188
189 class SetStateEvent : public PajeEvent  {
190   private:
191     Container* container;
192     Type* type;
193     Value* val;
194     const char* filename;
195     int linenumber;
196
197   public:
198     SetStateEvent(double timestamp, Container* container, Type* type, Value* val);
199     void print() override;
200 };
201
202
203 class PushStateEvent : public PajeEvent  {
204   public:
205     Container* container;
206     Type* type;
207     Value* val;
208     int size;
209     const char* filename;
210     int linenumber;
211     void* extra_;
212
213   public:
214     PushStateEvent(double timestamp, Container* container, Type* type, Value* val);
215     PushStateEvent(double timestamp, Container* container, Type* type, Value* val, void* extra);
216     void print() override;
217 };
218
219 class PopStateEvent : public PajeEvent  {
220   Container* container;
221   Type* type;
222
223 public:
224   PopStateEvent(double timestamp, Container* container, Type* type);
225   void print() override;
226 };
227
228 class ResetStateEvent : public PajeEvent  {
229   Container* container;
230   Type* type;
231
232 public:
233   ResetStateEvent(double timestamp, Container* container, Type* type);
234   void print() override;
235 };
236
237 class StartLinkEvent : public PajeEvent  {
238   public:
239     Container* container;
240     Type* type;
241     Container* sourceContainer;
242     char* value;
243     char* key;
244     int size;
245
246   public:
247     ~StartLinkEvent();
248     StartLinkEvent(double timestamp, Container* container, Type* type, Container* sourceContainer, const char* value,
249                    const char* key);
250     StartLinkEvent(double timestamp, Container* container, Type* type, Container* sourceContainer, const char* value,
251                    const char* key, int size);
252     void print() override;
253 };
254
255 class EndLinkEvent : public PajeEvent  {
256   Container* container;
257   Type* type;
258   Container* destContainer;
259   char *value;
260   char *key;
261   public:
262     EndLinkEvent(double timestamp, Container* container, Type* type, Container* destContainer, const char* value,
263                  const char* key);
264     ~EndLinkEvent();
265     void print() override;
266 };
267
268
269 class NewEvent : public PajeEvent  {
270   public:
271     Container* container;
272     Type* type;
273     Value* val;
274
275   public:
276     NewEvent(double timestamp, Container* container, Type* type, Value* val);
277     void print() override;
278 };
279 }
280 } // namespace simgrid::instr
281 typedef simgrid::instr::Container* container_t;
282
283 SG_BEGIN_DECL()
284
285 extern XBT_PRIVATE std::set<std::string> created_categories;
286 extern XBT_PRIVATE std::set<std::string> declared_marks;
287 extern XBT_PRIVATE std::set<std::string> user_host_variables;
288 extern XBT_PRIVATE std::set<std::string> user_vm_variables;
289 extern XBT_PRIVATE std::set<std::string> user_link_variables;
290 extern XBT_PRIVATE double TRACE_last_timestamp_to_dump;
291
292 /* instr_paje_header.c */
293 XBT_PRIVATE void TRACE_header(int basic, int size);
294
295 /* from paje.c */
296 XBT_PRIVATE void TRACE_paje_start();
297 XBT_PRIVATE void TRACE_paje_end();
298 XBT_PRIVATE void TRACE_paje_dump_buffer (int force);
299
300
301 /* from instr_config.c */
302 XBT_PRIVATE bool TRACE_needs_platform ();
303 XBT_PRIVATE bool TRACE_is_enabled();
304 XBT_PRIVATE bool TRACE_platform();
305 XBT_PRIVATE bool TRACE_platform_topology();
306 XBT_PRIVATE bool TRACE_is_configured();
307 XBT_PRIVATE bool TRACE_categorized ();
308 XBT_PRIVATE bool TRACE_uncategorized ();
309 XBT_PRIVATE bool TRACE_msg_process_is_enabled();
310 XBT_PRIVATE bool TRACE_msg_vm_is_enabled();
311 XBT_PRIVATE bool TRACE_buffer ();
312 XBT_PRIVATE bool TRACE_disable_link();
313 XBT_PRIVATE bool TRACE_disable_speed();
314 XBT_PRIVATE bool TRACE_onelink_only ();
315 XBT_PRIVATE bool TRACE_disable_destroy ();
316 XBT_PRIVATE bool TRACE_basic ();
317 XBT_PRIVATE bool TRACE_display_sizes ();
318 XBT_PRIVATE char *TRACE_get_comment ();
319 XBT_PRIVATE char *TRACE_get_comment_file ();
320 XBT_PRIVATE int TRACE_precision ();
321 XBT_PRIVATE char *TRACE_get_filename();
322 XBT_PRIVATE char *TRACE_get_viva_uncat_conf ();
323 XBT_PRIVATE char *TRACE_get_viva_cat_conf ();
324 XBT_PRIVATE void TRACE_generate_viva_uncat_conf ();
325 XBT_PRIVATE void TRACE_generate_viva_cat_conf ();
326 XBT_PRIVATE void instr_pause_tracing ();
327 XBT_PRIVATE void instr_resume_tracing ();
328
329 /* Public functions used in SMPI */
330 XBT_PUBLIC(bool) TRACE_smpi_is_enabled();
331 XBT_PUBLIC(bool) TRACE_smpi_is_grouped();
332 XBT_PUBLIC(bool) TRACE_smpi_is_computing();
333 XBT_PUBLIC(bool) TRACE_smpi_is_sleeping();
334 XBT_PUBLIC(bool) TRACE_smpi_view_internals();
335
336 /* from resource_utilization.c */
337 XBT_PRIVATE void TRACE_surf_host_set_utilization(const char *resource, const char *category, double value, double now,
338                                      double delta);
339 XBT_PRIVATE void TRACE_surf_link_set_utilization(const char *resource,const char *category, double value, double now,
340                                      double delta);
341 XBT_PUBLIC(void) TRACE_surf_resource_utilization_alloc();
342
343 /* instr_paje.c */
344 extern XBT_PRIVATE std::set<std::string> trivaNodeTypes;
345 extern XBT_PRIVATE std::set<std::string> trivaEdgeTypes;
346 XBT_PRIVATE long long int instr_new_paje_id ();
347 XBT_PRIVATE void PJ_container_alloc ();
348 XBT_PRIVATE void PJ_container_release ();
349 XBT_PUBLIC(container_t) PJ_container_new(const char* name, simgrid::instr::e_container_types kind, container_t father);
350 XBT_PUBLIC(container_t) PJ_container_get (const char *name);
351 XBT_PUBLIC(container_t) PJ_container_get_or_null (const char *name);
352 XBT_PUBLIC(container_t) PJ_container_get_root ();
353 XBT_PUBLIC(void) PJ_container_set_root (container_t root);
354 XBT_PUBLIC(void) PJ_container_free (container_t container);
355 XBT_PUBLIC(void) PJ_container_free_all (void);
356 XBT_PUBLIC(void) PJ_container_remove_from_parent (container_t container);
357
358 /* instr_paje_types.c */
359 XBT_PRIVATE void PJ_type_release ();
360 XBT_PUBLIC(simgrid::instr::Type*) PJ_type_get_root();
361 XBT_PUBLIC(simgrid::instr::Type*) PJ_type_get(const char* name, simgrid::instr::Type* father);
362 XBT_PRIVATE XBT_PRIVATE void PJ_type_free(simgrid::instr::Type* type);
363
364 /* instr_config.c */
365 XBT_PRIVATE void recursiveDestroyType(simgrid::instr::Type* type);
366
367 XBT_PRIVATE void TRACE_TI_start();
368 XBT_PRIVATE void TRACE_TI_end();
369
370 XBT_PRIVATE void TRACE_paje_dump_buffer (int force);
371 XBT_PRIVATE void dump_comment_file (const char *filename);
372 XBT_PRIVATE void dump_comment (const char *comment);
373
374 struct s_instr_extra_data;
375 typedef struct s_instr_extra_data *instr_extra_data;
376
377 typedef enum{
378   TRACING_INIT,
379   TRACING_FINALIZE,
380   TRACING_COMM_SIZE,
381   TRACING_COMM_SPLIT,
382   TRACING_COMM_DUP,
383   TRACING_SEND,
384   TRACING_ISEND,
385   TRACING_SSEND,
386   TRACING_ISSEND,
387   TRACING_RECV,
388   TRACING_IRECV,
389   TRACING_SENDRECV,
390   TRACING_TEST,
391   TRACING_WAIT,
392   TRACING_WAITALL,
393   TRACING_WAITANY,
394   TRACING_BARRIER,
395   TRACING_BCAST,
396   TRACING_REDUCE,
397   TRACING_ALLREDUCE,
398   TRACING_ALLTOALL,
399   TRACING_ALLTOALLV,
400   TRACING_GATHER,
401   TRACING_GATHERV,
402   TRACING_SCATTER,
403   TRACING_SCATTERV,
404   TRACING_ALLGATHER,
405   TRACING_ALLGATHERV,
406   TRACING_REDUCE_SCATTER,
407   TRACING_COMPUTING,
408   TRACING_SLEEPING,
409   TRACING_SCAN,
410   TRACING_EXSCAN
411 } e_caller_type ;
412
413 typedef struct s_instr_extra_data {
414   e_caller_type type;
415   int send_size;
416   int recv_size;
417   double comp_size;
418   double sleep_duration;
419   int src;
420   int dst;
421   int root;
422   const char* datatype1;
423   const char* datatype2;
424   int * sendcounts;
425   int * recvcounts;
426   int num_processes;
427 } s_instr_extra_data_t;
428
429 /* Format of TRACING output.
430  *   - paje is the regular format, that we all know
431  *   - 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.
432  *     This trick should be removed and replaced by some code using the signal that we will create to cleanup the TRACING
433  */
434 typedef enum { instr_fmt_paje, instr_fmt_TI } instr_fmt_type_t;
435 extern instr_fmt_type_t instr_fmt_type;
436
437 SG_END_DECL()
438
439 void DefineContainerEvent(simgrid::instr::Type* type);
440 void LogVariableTypeDefinition(simgrid::instr::Type* type);
441 void LogStateTypeDefinition(simgrid::instr::Type* type);
442 void LogLinkTypeDefinition(simgrid::instr::Type* type, simgrid::instr::Type* source, simgrid::instr::Type* dest);
443 void LogEntityValue(simgrid::instr::Value* val);
444 void LogContainerCreation (container_t container);
445 void LogContainerDestruction (container_t container);
446 void LogDefineEventType(simgrid::instr::Type* type);
447
448 #endif