Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
b505dc9a73465ebabd04aba84aa6a5b93e87f2b6
[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   double speed_scale;
56   tmgr_trace_t speed_trace;
57   int initiallyOn;
58   tmgr_trace_t state_trace;
59   const char* coord;
60   xbt_dict_t properties;
61 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
62
63 #define SG_PLATF_HOST_INITIALIZER { \
64     NULL, 0, 1, 1, 1., NULL, 1/*ON*/, NULL, \
65     NULL, NULL \
66 }
67
68 typedef struct {
69   const char* id;
70   const char* link_up;
71   const char* link_down;
72 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
73
74 #define SG_PLATF_HOST_LINK_INITIALIZER {NULL,NULL,NULL}
75
76 typedef struct {
77   const char* id;
78   const char* coord;
79 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
80
81 #define SG_PLATF_ROUTER_INITIALIZER {NULL,NULL}
82
83 typedef struct {
84   const char* id;
85   double bandwidth;
86   tmgr_trace_t bandwidth_trace;
87   double latency;
88   tmgr_trace_t latency_trace;
89   int initiallyOn;
90   tmgr_trace_t state_trace;
91   e_surf_link_sharing_policy_t policy;
92   xbt_dict_t properties;
93 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
94
95 #define SG_PLATF_LINK_INITIALIZER {\
96   NULL, 0., NULL, 0., NULL, 1/*ON*/, \
97   NULL, SURF_LINK_SHARED, NULL \
98 }
99
100 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
101 typedef struct s_sg_platf_peer_cbarg {
102   const char* id;
103   double speed;
104   double bw_in;
105   double bw_out;
106   double lat;
107   const char* coord;
108   tmgr_trace_t availability_trace;
109   tmgr_trace_t state_trace;
110 } s_sg_platf_peer_cbarg_t;
111
112 #define SG_PLATF_PEER_INITIALIZER {NULL,0.0,0.0,0.0,0.0,NULL,NULL,NULL}
113
114 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
115 typedef struct s_sg_platf_route_cbarg {
116   int symmetrical;
117   const char *src;
118   const char *dst;
119   sg_netcard_t gw_src;
120   sg_netcard_t gw_dst;
121   xbt_dynar_t link_list;
122 } s_sg_platf_route_cbarg_t;
123
124 #define SG_PLATF_ROUTE_INITIALIZER {1,NULL,NULL,NULL,NULL,NULL}
125
126 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
127 typedef struct s_sg_platf_cluster_cbarg {
128   const char* id;
129   const char* prefix;
130   const char* suffix;
131   const char* radical;
132   double speed;
133   int core_amount;
134   double bw;
135   double lat;
136   double bb_bw;
137   double bb_lat;
138   double loopback_bw;
139   double loopback_lat;
140   double limiter_link;
141   e_surf_cluster_topology_t topology;
142   const char* topo_parameters;
143   xbt_dict_t properties;
144   const char* router_id;
145   e_surf_link_sharing_policy_t sharing_policy;
146   e_surf_link_sharing_policy_t bb_sharing_policy;
147   const char* availability_trace; //don't convert to tmgr_trace_t since there is a trace per host and some rewriting is needed
148   const char* state_trace;
149 } s_sg_platf_cluster_cbarg_t;
150
151 #define SG_PLATF_CLUSTER_INITIALIZER {NULL,NULL,NULL,NULL,0.0,1 \
152   ,1.,1.,0.,0.,0.,0.,0. \
153   ,SURF_CLUSTER_FLAT,NULL,NULL,NULL, \
154   SURF_LINK_SHARED,SURF_LINK_SHARED,NULL \
155   ,NULL}
156
157 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
158 typedef struct s_sg_platf_cabinet_cbarg {
159   const char* id;
160   const char* prefix;
161   const char* suffix;
162   const char* radical;
163   double speed;
164   double bw;
165   double lat;
166 } s_sg_platf_cabinet_cbarg_t;
167
168 #define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,0.0,0.0,0.0}
169
170 typedef struct {
171   const char* id;
172   const char* type_id;
173   const char* content;
174   const char* content_type;
175   xbt_dict_t properties;
176   const char* attach;
177 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
178
179 #define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL}
180
181 typedef struct {
182   const char* id;
183   const char* model;
184   const char* content;
185   const char* content_type;
186   xbt_dict_t properties;
187   xbt_dict_t model_properties;
188   sg_size_t size;
189 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
190
191 #define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,0}
192
193 typedef struct {
194   const char* type_id;
195   const char* name;
196 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
197
198 #define SG_PLATF_MSTORAGE_INITIALIZER {NULL,NULL}
199
200 typedef struct {
201   const char* storageId;
202   const char* name;
203 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
204
205 #define SG_PLATF_MOUNT_INITIALIZER {NULL,NULL}
206
207 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
208 typedef struct s_sg_platf_prop_cbarg {
209   const char *id;
210   const char *value;
211 } s_sg_platf_prop_cbarg_t;
212
213 #define SG_PLATF_PROP_INITIALIZER {NULL,NULL}
214
215 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
216 typedef struct s_sg_platf_trace_cbarg {
217   const char *id;
218   const char *file;
219   double periodicity;
220   const char *pc_data;
221 } s_sg_platf_trace_cbarg_t;
222
223 #define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,0.0,NULL}
224
225 typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
226 typedef struct s_sg_platf_trace_connect_cbarg {
227   e_surf_trace_connect_kind_t kind;
228   const char *trace;
229   const char *element;
230 } s_sg_platf_trace_connect_cbarg_t;
231
232 #define SG_PLATF_TRACE_CONNECT_INITIALIZER {SURF_TRACE_CONNECT_KIND_LATENCY,NULL,NULL}
233
234 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
235 typedef struct s_sg_platf_process_cbarg {
236   const char **argv;
237   int argc;
238   xbt_dict_t properties;
239   const char *host;
240   const char *function;
241   double start_time;
242   double kill_time;
243   e_surf_process_on_failure_t on_failure;
244 } s_sg_platf_process_cbarg_t;
245
246 #define SG_PLATF_PROCESS_INITIALIZER {NULL,0,NULL,NULL,NULL,-1.0,-1.0,SURF_PROCESS_ON_FAILURE_DIE}
247
248 typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
249 typedef struct s_sg_platf_AS_cbarg {
250   const char *id;
251   int routing;
252 } s_sg_platf_AS_cbarg_t;
253
254 #define SG_PLATF_AS_INITIALIZER {NULL,0}
255
256 /** opaque structure defining a event generator for availability based on a probability distribution */
257 typedef struct probabilist_event_generator *probabilist_event_generator_t;
258
259 /********** Routing **********/
260 void routing_AS_begin(sg_platf_AS_cbarg_t AS);
261 void routing_AS_end(void);
262 void routing_cluster_add_backbone(Link* bb);
263 surf_As* routing_get_current();
264 /*** END of the parsing cruft ***/
265
266 XBT_PUBLIC(void) sg_platf_begin(void);  // Start a new platform
267 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
268
269 XBT_PUBLIC(void) sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS); // Begin description of new AS
270 XBT_PUBLIC(void) sg_platf_new_AS_end(void);                     // That AS is fully described
271
272 XBT_PUBLIC(void) sg_platf_new_host   (sg_platf_host_cbarg_t   host);   // Add an host   to the currently described AS
273 XBT_PUBLIC(void) sg_platf_new_hostlink(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
274 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router  to the currently described AS
275 XBT_PUBLIC(void) sg_platf_new_link   (sg_platf_link_cbarg_t link);     // Add a link    to the currently described AS
276 XBT_PUBLIC(void) sg_platf_new_peer   (sg_platf_peer_cbarg_t peer);     // Add a peer    to the currently described AS
277 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
278 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
279
280 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
281 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
282
283 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
284
285 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
286 XBT_PUBLIC(void) sg_platf_new_mstorage(sg_platf_mstorage_cbarg_t mstorage);
287 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
288 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
289
290 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
291
292 /* Prototypes of the functions offered by flex */
293 XBT_PUBLIC(int) surf_parse_lex(void);
294 XBT_PUBLIC(int) surf_parse_get_lineno(void);
295 XBT_PUBLIC(FILE *) surf_parse_get_in(void);
296 XBT_PUBLIC(FILE *) surf_parse_get_out(void);
297 XBT_PUBLIC(yy_size_t) surf_parse_get_leng(void);
298 XBT_PUBLIC(char *) surf_parse_get_text(void);
299 XBT_PUBLIC(void) surf_parse_set_lineno(int line_number);
300 XBT_PUBLIC(void) surf_parse_set_in(FILE * in_str);
301 XBT_PUBLIC(void) surf_parse_set_out(FILE * out_str);
302 XBT_PUBLIC(int) surf_parse_get_debug(void);
303 XBT_PUBLIC(void) surf_parse_set_debug(int bdebug);
304 XBT_PUBLIC(int) surf_parse_lex_destroy(void);
305
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 */