Logo AND Algorithmique Numérique Distribuée

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