Logo AND Algorithmique Numérique Distribuée

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