Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] dumping comment and comment_file to trace files when requested
[simgrid.git] / src / instr / instr_private.h
1 /* Copyright (c) 2010. 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_config.h"
11
12 #ifdef HAVE_TRACING
13
14 /* Need to define function drand48 for Windows */
15 #ifdef _WIN32
16 #  define drand48() (rand()/(RAND_MAX + 1.0))
17 #endif
18
19 #define INSTR_DEFAULT_STR_SIZE 500
20
21 #include "instr/instr.h"
22 #include "msg/msg.h"
23 #include "simdag/private.h"
24 #include "simix/smx_private.h"
25 #include "xbt/graph_private.h"
26
27 typedef enum {
28   PAJE_DefineContainerType,
29   PAJE_DefineVariableType,
30   PAJE_DefineStateType,
31   PAJE_DefineEventType,
32   PAJE_DefineLinkType,
33   PAJE_DefineEntityValue,
34   PAJE_CreateContainer,
35   PAJE_DestroyContainer,
36   PAJE_SetVariable,
37   PAJE_AddVariable,
38   PAJE_SubVariable,
39   PAJE_SetState,
40   PAJE_PushState,
41   PAJE_PopState,
42   PAJE_ResetState,
43   PAJE_StartLink,
44   PAJE_EndLink,
45   PAJE_NewEvent
46 } e_event_type;
47
48 typedef enum {
49   TYPE_VARIABLE,
50   TYPE_LINK,
51   TYPE_CONTAINER,
52   TYPE_STATE,
53   TYPE_EVENT
54 } e_entity_types;
55
56 typedef struct s_type *type_t;
57 typedef struct s_type {
58   char *id;
59   char *name;
60   char *color;
61   e_entity_types kind;
62   struct s_type *father;
63   xbt_dict_t children;
64   xbt_dict_t values; //valid for all types except variable and container
65 }s_type_t;
66
67 typedef struct s_val *val_t;
68 typedef struct s_val {
69   char *id;
70   char *name;
71   char *color;
72   type_t father;
73 }s_val_t;
74
75 typedef enum {
76   INSTR_HOST,
77   INSTR_LINK,
78   INSTR_ROUTER,
79   INSTR_AS,
80   INSTR_SMPI,
81   INSTR_MSG_PROCESS,
82   INSTR_MSG_TASK
83 } e_container_types;
84
85 typedef struct s_container *container_t;
86 typedef struct s_container {
87   sg_routing_edge_t net_elm;
88   char *name;     /* Unique name of this container */
89   char *id;       /* Unique id of this container */
90   type_t type;    /* Type of this container */
91   int level;      /* Level in the hierarchy, root level is 0 */
92   e_container_types kind; /* This container is of what kind */
93   struct s_container *father;
94   xbt_dict_t children;
95 }s_container_t;
96
97 extern xbt_dict_t created_categories;
98 extern xbt_dict_t declared_marks;
99 extern xbt_dict_t user_host_variables;
100 extern xbt_dict_t user_link_variables;
101 extern double TRACE_last_timestamp_to_dump;
102
103 /* instr_paje_header.c */
104 void TRACE_header(int basic);
105
106 /* from paje.c */
107 void TRACE_paje_start(void);
108 void TRACE_paje_end(void);
109 void TRACE_paje_dump_buffer (int force);
110 void new_pajeDefineContainerType(type_t type);
111 void new_pajeDefineVariableType(type_t type);
112 void new_pajeDefineStateType(type_t type);
113 void new_pajeDefineEventType(type_t type);
114 void new_pajeDefineLinkType(type_t type, type_t source, type_t dest);
115 void new_pajeDefineEntityValue (val_t type);
116 void new_pajeCreateContainer (container_t container);
117 void new_pajeDestroyContainer (container_t container);
118 void new_pajeSetVariable (double timestamp, container_t container, type_t type, double value);
119 void new_pajeAddVariable (double timestamp, container_t container, type_t type, double value);
120 void new_pajeSubVariable (double timestamp, container_t container, type_t type, double value);
121 void new_pajeSetState (double timestamp, container_t container, type_t type, val_t value);
122 void new_pajePushState (double timestamp, container_t container, type_t type, val_t value);
123 void new_pajePopState (double timestamp, container_t container, type_t type);
124 void new_pajeResetState (double timestamp, container_t container, type_t type);
125 void new_pajeStartLink (double timestamp, container_t container, type_t type, container_t sourceContainer, const char *value, const char *key);
126 void new_pajeEndLink (double timestamp, container_t container, type_t type, container_t destContainer, const char *value, const char *key);
127 void new_pajeNewEvent (double timestamp, container_t container, type_t type, val_t value);
128
129 /* declaration of instrumentation functions from msg_task_instr.c */
130 void TRACE_msg_set_task_category(msg_task_t task, const char *category);
131 void TRACE_msg_task_create(msg_task_t task);
132 void TRACE_msg_task_execute_start(msg_task_t task);
133 void TRACE_msg_task_execute_end(msg_task_t task);
134 void TRACE_msg_task_destroy(msg_task_t task);
135 void TRACE_msg_task_get_start(void);
136 void TRACE_msg_task_get_end(double start_time, msg_task_t task);
137 int TRACE_msg_task_put_start(msg_task_t task);    //returns TRUE if the task_put_end must be called
138 void TRACE_msg_task_put_end(void);
139
140 /* declaration of instrumentation functions from msg_process_instr.c */
141 char *instr_process_id (msg_process_t proc, char *str, int len);
142 char *instr_process_id_2 (const char *process_name, int process_pid, char *str, int len);
143 void TRACE_msg_process_change_host(msg_process_t process, msg_host_t old_host,
144                                    msg_host_t new_host);
145 void TRACE_msg_process_create (const char *process_name, int process_pid, msg_host_t host);
146 void TRACE_msg_process_destroy (const char *process_name, int process_pid, msg_host_t host);
147 void TRACE_msg_process_kill(msg_process_t process);
148 void TRACE_msg_process_suspend(msg_process_t process);
149 void TRACE_msg_process_resume(msg_process_t process);
150 void TRACE_msg_process_sleep_in(msg_process_t process);   //called from msg/gos.c
151 void TRACE_msg_process_sleep_out(msg_process_t process);
152 void TRACE_msg_process_end(msg_process_t process);
153
154 /* from surf_instr.c */
155 void TRACE_surf_alloc(void);
156 void TRACE_surf_release(void);
157 void TRACE_surf_host_set_power(double date, const char *resource, double power);
158 void TRACE_surf_link_set_bandwidth(double date, const char *resource, double bandwidth);
159 void TRACE_surf_link_set_latency(double date, const char *resource, double latency);
160 void TRACE_surf_action(surf_action_t surf_action, const char *category);
161
162 //for tracing gtnets
163 void TRACE_surf_gtnets_communicate(void *action, void *src, void *dst);
164
165 /* from smpi_instr.c */
166 void TRACE_internal_smpi_set_category (const char *category);
167 const char *TRACE_internal_smpi_get_category (void);
168 void TRACE_smpi_alloc(void);
169 void TRACE_smpi_release(void);
170 void TRACE_smpi_init(int rank);
171 void TRACE_smpi_finalize(int rank);
172 void TRACE_smpi_collective_in(int rank, int root, const char *operation);
173 void TRACE_smpi_collective_out(int rank, int root, const char *operation);
174 void TRACE_smpi_computing_init(int rank);
175 void TRACE_smpi_computing_out(int rank);
176 void TRACE_smpi_computing_in(int rank);
177 void TRACE_smpi_ptp_in(int rank, int src, int dst, const char *operation);
178 void TRACE_smpi_ptp_out(int rank, int src, int dst, const char *operation);
179 void TRACE_smpi_send(int rank, int src, int dst);
180 void TRACE_smpi_recv(int rank, int src, int dst);
181
182 /* from instr_config.c */
183 int TRACE_start (void);
184 int TRACE_end (void);
185 int TRACE_needs_platform (void);
186 int TRACE_is_enabled(void);
187 int TRACE_platform(void);
188 int TRACE_is_configured(void);
189 int TRACE_smpi_is_enabled(void);
190 int TRACE_smpi_is_grouped(void);
191 int TRACE_smpi_is_computing(void);
192 int TRACE_categorized (void);
193 int TRACE_uncategorized (void);
194 int TRACE_msg_process_is_enabled(void);
195 int TRACE_buffer (void);
196 int TRACE_onelink_only (void);
197 int TRACE_disable_destroy (void);
198 int TRACE_basic (void);
199 char *TRACE_get_comment (void);
200 char *TRACE_get_comment_file (void);
201 char *TRACE_get_filename(void);
202 char *TRACE_get_triva_uncat_conf (void);
203 char *TRACE_get_triva_cat_conf (void);
204 char *TRACE_get_viva_uncat_conf (void);
205 char *TRACE_get_viva_cat_conf (void);
206 void TRACE_global_init(int *argc, char **argv);
207 void TRACE_help(int detailed);
208 void TRACE_generate_triva_uncat_conf (void);
209 void TRACE_generate_triva_cat_conf (void);
210 void TRACE_generate_viva_uncat_conf (void);
211 void TRACE_generate_viva_cat_conf (void);
212
213 /* from resource_utilization.c */
214 void TRACE_surf_host_set_utilization(const char *resource,
215                                      const char *category,
216                                      double value,
217                                      double now,
218                                      double delta);
219 void TRACE_surf_link_set_utilization(const char *resource,
220                                      const char *category,
221                                      double value,
222                                      double now,
223                                      double delta);
224 void TRACE_surf_resource_utilization_alloc(void);
225 void TRACE_surf_resource_utilization_release(void);
226
227 /* instr_paje.c */
228 extern xbt_dict_t trivaNodeTypes;
229 extern xbt_dict_t trivaEdgeTypes;
230 long long int instr_new_paje_id (void);
231 void PJ_container_alloc (void);
232 void PJ_container_release (void);
233 container_t PJ_container_new (const char *name, e_container_types kind, container_t father);
234 container_t PJ_container_get (const char *name);
235 container_t PJ_container_get_or_null (const char *name);
236 container_t PJ_container_get_root (void);
237 void PJ_container_set_root (container_t root);
238 void PJ_container_free (container_t container);
239 void PJ_container_free_all (void);
240 void PJ_container_remove_from_parent (container_t container);
241
242 /* instr_paje_types.c */
243 void PJ_type_alloc (void);
244 void PJ_type_release (void);
245 type_t PJ_type_get_root (void);
246 type_t PJ_type_container_new (const char *name, type_t father);
247 type_t PJ_type_event_new (const char *name, type_t father);
248 type_t PJ_type_variable_new (const char *name, const char *color, type_t father);
249 type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t dest);
250 type_t PJ_type_state_new (const char *name, type_t father);
251 type_t PJ_type_get (const char *name, const type_t father);
252 type_t PJ_type_get_or_null (const char *name, type_t father);
253 void PJ_type_free (type_t type);
254 void PJ_type_free_all (void);
255
256 /* instr_paje_values.c */
257 val_t PJ_value_new (const char *name, const char *color, type_t father);
258 val_t PJ_value_get_or_new (const char *name, const char *color, type_t father);
259 val_t PJ_value_get (const char *name, const type_t father);
260 void PJ_value_free (val_t value);
261
262 /* instr_routing.c */
263 void instr_routing_define_callbacks (void);
264 void instr_new_variable_type (const char *new_typename, const char *color);
265 void instr_new_user_variable_type  (const char *father_type, const char *new_typename, const char *color);
266 void instr_new_user_state_type (const char *father_type, const char *new_typename);
267 void instr_new_value_for_user_state_type (const char *typename, const char *value, const char *color);
268 int instr_platform_traced (void);
269 xbt_graph_t instr_routing_platform_graph (void);
270 void instr_routing_platform_graph_export_graphviz (xbt_graph_t g, const char *filename);
271
272 #endif /* HAVE_TRACING */
273
274 #ifdef HAVE_JEDULE
275 #include "instr/jedule/jedule_sd_binding.h"
276 #endif
277
278 #endif /* INSTR_PRIVATE_H_ */