Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ef48487cc73e57d2f2b3885cf8157e1f382dd5c0
[simgrid.git] / src / surf / xml / platf_private.hpp
1 /* platf_private.h - Interface to the SimGrid platforms which visibility should be limited to this directory */
2
3 /* Copyright (c) 2004-2015. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #ifndef SG_PLATF_H
10 #define SG_PLATF_H
11
12 #include "simgrid/host.h"
13 #include "src/surf/xml/platf.hpp"
14
15 SG_BEGIN_DECL()
16 #include "src/surf/xml/simgrid_dtd.h"
17
18 #ifndef YY_TYPEDEF_YY_SIZE_T
19 #define YY_TYPEDEF_YY_SIZE_T
20 typedef size_t yy_size_t;
21 #endif
22
23 XBT_PUBLIC(sg_netcard_t) sg_netcard_by_name_or_null(const char *name);
24
25 typedef enum {
26   SURF_CLUSTER_FAT_TREE=2,
27   SURF_CLUSTER_FLAT = 1,
28   SURF_CLUSTER_TORUS = 0
29 } e_surf_cluster_topology_t;
30
31 /* ***************************************** */
32 /*
33  * Platform creation functions. Instead of passing 123 arguments to the creation functions
34  * (one for each possible XML attribute), we pass structures containing them all. It removes the
35  * chances of switching arguments by error, and reduce the burden when we add a new attribute:
36  * old models can just continue to ignore it without having to update their headers.
37  *
38  * It shouldn't be too costly at runtime, provided that structures living on the stack are
39  * used, instead of malloced structures.
40  */
41
42 typedef struct {
43   const char* id;
44   xbt_dynar_t speed_per_pstate;
45   int pstate;
46   int core_amount;
47   tmgr_trace_t speed_trace;
48   tmgr_trace_t state_trace;
49   const char* coord;
50   xbt_dict_t properties;
51 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
52
53 #define SG_PLATF_HOST_INITIALIZER { \
54     NULL, 0, 1, 1, NULL, NULL, NULL, NULL \
55 }
56
57 typedef struct {
58   const char* id;
59   const char* link_up;
60   const char* link_down;
61 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
62
63 #define SG_PLATF_HOST_LINK_INITIALIZER {NULL,NULL,NULL}
64
65 typedef struct {
66   const char* id;
67   const char* coord;
68 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
69
70 #define SG_PLATF_ROUTER_INITIALIZER {NULL,NULL}
71
72 typedef struct {
73   const char* id;
74   double bandwidth;
75   tmgr_trace_t bandwidth_trace;
76   double latency;
77   tmgr_trace_t latency_trace;
78   tmgr_trace_t state_trace;
79   e_surf_link_sharing_policy_t policy;
80   xbt_dict_t properties;
81 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
82
83 #define SG_PLATF_LINK_INITIALIZER {\
84   NULL, 0., NULL, 0., NULL, NULL, SURF_LINK_SHARED, NULL \
85 }
86
87 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
88 typedef struct s_sg_platf_peer_cbarg {
89   const char* id;
90   double speed;
91   double bw_in;
92   double bw_out;
93   double lat;
94   const char* coord;
95   tmgr_trace_t availability_trace;
96   tmgr_trace_t state_trace;
97 } s_sg_platf_peer_cbarg_t;
98
99 #define SG_PLATF_PEER_INITIALIZER {NULL,0.0,0.0,0.0,0.0,NULL,NULL,NULL}
100
101 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
102 typedef struct s_sg_platf_route_cbarg {
103   bool symmetrical;
104   const char *src;
105   const char *dst;
106   sg_netcard_t gw_src;
107   sg_netcard_t gw_dst;
108   std::vector<Link*> *link_list;
109 } s_sg_platf_route_cbarg_t;
110
111 #define SG_PLATF_ROUTE_INITIALIZER {1,NULL,NULL,NULL,NULL,NULL}
112
113 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
114 typedef struct s_sg_platf_cluster_cbarg {
115   const char* id;
116   const char* prefix;
117   const char* suffix;
118   const char* radical;
119   double speed;
120   int core_amount;
121   double bw;
122   double lat;
123   double bb_bw;
124   double bb_lat;
125   double loopback_bw;
126   double loopback_lat;
127   double limiter_link;
128   e_surf_cluster_topology_t topology;
129   const char* topo_parameters;
130   xbt_dict_t properties;
131   const char* router_id;
132   e_surf_link_sharing_policy_t sharing_policy;
133   e_surf_link_sharing_policy_t bb_sharing_policy;
134   const char* availability_trace; //don't convert to tmgr_trace_t since there is a trace per host and some rewriting is needed
135   const char* state_trace;
136 } s_sg_platf_cluster_cbarg_t;
137
138 #define SG_PLATF_CLUSTER_INITIALIZER {NULL,NULL,NULL,NULL,0.0,1 \
139   ,1.,1.,0.,0.,0.,0.,0. \
140   ,SURF_CLUSTER_FLAT,NULL,NULL,NULL, \
141   SURF_LINK_SHARED,SURF_LINK_SHARED,NULL \
142   ,NULL}
143
144 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
145 typedef struct s_sg_platf_cabinet_cbarg {
146   const char* id;
147   const char* prefix;
148   const char* suffix;
149   const char* radical;
150   double speed;
151   double bw;
152   double lat;
153 } s_sg_platf_cabinet_cbarg_t;
154
155 #define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,0.0,0.0,0.0}
156
157 typedef struct {
158   const char* id;
159   const char* type_id;
160   const char* content;
161   const char* content_type;
162   xbt_dict_t properties;
163   const char* attach;
164 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
165
166 #define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL}
167
168 typedef struct {
169   const char* id;
170   const char* model;
171   const char* content;
172   const char* content_type;
173   xbt_dict_t properties;
174   xbt_dict_t model_properties;
175   sg_size_t size;
176 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
177
178 #define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,0}
179
180 typedef struct {
181   const char* storageId;
182   const char* name;
183 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
184
185 #define SG_PLATF_MOUNT_INITIALIZER {NULL,NULL}
186
187 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
188 typedef struct s_sg_platf_prop_cbarg {
189   const char *id;
190   const char *value;
191 } s_sg_platf_prop_cbarg_t;
192
193 #define SG_PLATF_PROP_INITIALIZER {NULL,NULL}
194
195 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
196 typedef struct s_sg_platf_trace_cbarg {
197   const char *id;
198   const char *file;
199   double periodicity;
200   const char *pc_data;
201 } s_sg_platf_trace_cbarg_t;
202
203 #define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,0.0,NULL}
204
205 typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
206 typedef struct s_sg_platf_trace_connect_cbarg {
207   e_surf_trace_connect_kind_t kind;
208   const char *trace;
209   const char *element;
210 } s_sg_platf_trace_connect_cbarg_t;
211
212 #define SG_PLATF_TRACE_CONNECT_INITIALIZER {SURF_TRACE_CONNECT_KIND_LATENCY,NULL,NULL}
213
214 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
215 typedef struct s_sg_platf_process_cbarg {
216   const char **argv;
217   int argc;
218   xbt_dict_t properties;
219   const char *host;
220   const char *function;
221   double start_time;
222   double kill_time;
223   e_surf_process_on_failure_t on_failure;
224 } s_sg_platf_process_cbarg_t;
225
226 #define SG_PLATF_PROCESS_INITIALIZER {NULL,0,NULL,NULL,NULL,-1.0,-1.0,SURF_PROCESS_ON_FAILURE_DIE}
227
228 typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
229 typedef struct s_sg_platf_AS_cbarg {
230   const char *id;
231   int routing;
232 } s_sg_platf_AS_cbarg_t;
233
234 #define SG_PLATF_AS_INITIALIZER {NULL,0}
235
236 /********** Routing **********/
237 void routing_cluster_add_backbone(Link* bb);
238 /*** END of the parsing cruft ***/
239
240 XBT_PUBLIC(void) sg_platf_begin(void);  // Start a new platform
241 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
242
243 XBT_PUBLIC(void) sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS); // Begin description of new AS
244 XBT_PUBLIC(void) sg_platf_new_AS_end(void);                     // That AS is fully described
245
246 XBT_PUBLIC(void) sg_platf_new_host   (sg_platf_host_cbarg_t   host);   // Add an host   to the currently described AS
247 XBT_PUBLIC(void) sg_platf_new_hostlink(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
248 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router  to the currently described AS
249 XBT_PUBLIC(void) sg_platf_new_link   (sg_platf_link_cbarg_t link);     // Add a link    to the currently described AS
250 XBT_PUBLIC(void) sg_platf_new_peer   (sg_platf_peer_cbarg_t peer);     // Add a peer    to the currently described AS
251 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
252 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
253
254 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
255 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
256
257 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
258
259 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
260 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
261 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
262
263 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
264 XBT_PRIVATE void sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect);
265
266 /* Prototypes of the functions offered by flex */
267 XBT_PUBLIC(int) surf_parse_lex(void);
268 XBT_PUBLIC(int) surf_parse_get_lineno(void);
269 XBT_PUBLIC(FILE *) surf_parse_get_in(void);
270 XBT_PUBLIC(FILE *) surf_parse_get_out(void);
271 XBT_PUBLIC(yy_size_t) surf_parse_get_leng(void);
272 XBT_PUBLIC(char *) surf_parse_get_text(void);
273 XBT_PUBLIC(void) surf_parse_set_lineno(int line_number);
274 XBT_PUBLIC(void) surf_parse_set_in(FILE * in_str);
275 XBT_PUBLIC(void) surf_parse_set_out(FILE * out_str);
276 XBT_PUBLIC(int) surf_parse_get_debug(void);
277 XBT_PUBLIC(void) surf_parse_set_debug(int bdebug);
278 XBT_PUBLIC(int) surf_parse_lex_destroy(void);
279
280 /* To include files (?) */
281 XBT_PRIVATE void surfxml_bufferstack_push(int _new);
282 XBT_PRIVATE void surfxml_bufferstack_pop(int _new);
283 XBT_PUBLIC_DATA(int) surfxml_bufferstack_size;
284
285 XBT_PUBLIC(void) routing_route_free(sg_platf_route_cbarg_t route);
286 /********** Instr. **********/
287 XBT_PRIVATE void sg_instr_AS_begin(sg_platf_AS_cbarg_t AS);
288 XBT_PRIVATE void sg_instr_new_router(sg_platf_router_cbarg_t router);
289 XBT_PRIVATE void sg_instr_new_host(sg_platf_host_cbarg_t host);
290 XBT_PRIVATE void sg_instr_AS_end(void);
291
292 typedef struct s_surf_parsing_link_up_down *surf_parsing_link_up_down_t;
293 typedef struct s_surf_parsing_link_up_down {
294   Link* link_up;
295   Link* link_down;
296 } s_surf_parsing_link_up_down_t;
297
298
299 SG_END_DECL()
300
301 namespace simgrid {
302 namespace surf {
303
304 extern XBT_PRIVATE simgrid::xbt::signal<void(sg_platf_link_cbarg_t)> on_link;
305 extern XBT_PRIVATE simgrid::xbt::signal<void(sg_platf_cluster_cbarg_t)> on_cluster;
306
307 }
308 }
309
310 #endif                          /* SG_PLATF_H */