Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics in AsCluster and friends
[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 typedef struct {
54   const char* id;
55   const char* link_up;
56   const char* link_down;
57 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
58
59 typedef struct {
60   const char* id;
61   const char* coord;
62 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
63
64 typedef struct {
65   const char* id;
66   double bandwidth;
67   tmgr_trace_t bandwidth_trace;
68   double latency;
69   tmgr_trace_t latency_trace;
70   tmgr_trace_t state_trace;
71   e_surf_link_sharing_policy_t policy;
72   xbt_dict_t properties;
73 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
74
75 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
76 typedef struct s_sg_platf_peer_cbarg {
77   const char* id;
78   double speed;
79   double bw_in;
80   double bw_out;
81   double lat;
82   const char* coord;
83   tmgr_trace_t availability_trace;
84   tmgr_trace_t state_trace;
85 } s_sg_platf_peer_cbarg_t;
86
87 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
88 typedef struct s_sg_platf_route_cbarg {
89   bool symmetrical;
90   const char *src;
91   const char *dst;
92   sg_netcard_t gw_src;
93   sg_netcard_t gw_dst;
94   std::vector<Link*> *link_list;
95 } s_sg_platf_route_cbarg_t;
96
97 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
98 typedef struct s_sg_platf_cluster_cbarg {
99   const char* id;
100   const char* prefix;
101   const char* suffix;
102   const char* radical;
103   double speed;
104   int core_amount;
105   double bw;
106   double lat;
107   double bb_bw;
108   double bb_lat;
109   double loopback_bw;
110   double loopback_lat;
111   double limiter_link;
112   e_surf_cluster_topology_t topology;
113   const char* topo_parameters;
114   xbt_dict_t properties;
115   const char* router_id;
116   e_surf_link_sharing_policy_t sharing_policy;
117   e_surf_link_sharing_policy_t bb_sharing_policy;
118 } s_sg_platf_cluster_cbarg_t;
119
120 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
121 typedef struct s_sg_platf_cabinet_cbarg {
122   const char* id;
123   const char* prefix;
124   const char* suffix;
125   const char* radical;
126   double speed;
127   double bw;
128   double lat;
129 } s_sg_platf_cabinet_cbarg_t;
130
131 typedef struct {
132   const char* id;
133   const char* type_id;
134   const char* content;
135   const char* content_type;
136   xbt_dict_t properties;
137   const char* attach;
138 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
139
140 typedef struct {
141   const char* id;
142   const char* model;
143   const char* content;
144   const char* content_type;
145   xbt_dict_t properties;
146   xbt_dict_t model_properties;
147   sg_size_t size;
148 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
149
150 typedef struct {
151   const char* storageId;
152   const char* name;
153 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
154
155 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
156 typedef struct s_sg_platf_prop_cbarg {
157   const char *id;
158   const char *value;
159 } s_sg_platf_prop_cbarg_t;
160
161 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
162 typedef struct s_sg_platf_trace_cbarg {
163   const char *id;
164   const char *file;
165   double periodicity;
166   const char *pc_data;
167 } s_sg_platf_trace_cbarg_t;
168
169 typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
170 typedef struct s_sg_platf_trace_connect_cbarg {
171   e_surf_trace_connect_kind_t kind;
172   const char *trace;
173   const char *element;
174 } s_sg_platf_trace_connect_cbarg_t;
175
176 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
177 typedef struct s_sg_platf_process_cbarg {
178   const char **argv;
179   int argc;
180   xbt_dict_t properties;
181   const char *host;
182   const char *function;
183   double start_time;
184   double kill_time;
185   e_surf_process_on_failure_t on_failure;
186 } s_sg_platf_process_cbarg_t;
187
188 typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
189 typedef struct s_sg_platf_AS_cbarg {
190   const char *id;
191   int routing;
192 } s_sg_platf_AS_cbarg_t;
193
194 #define SG_PLATF_AS_INITIALIZER {NULL,0}
195
196 /********** Routing **********/
197 void routing_cluster_add_backbone(Link* bb);
198 /*** END of the parsing cruft ***/
199
200 XBT_PUBLIC(void) sg_platf_begin(void);  // Start a new platform
201 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
202
203 XBT_PUBLIC(simgrid::s4u::As*) sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS); // Begin description of new AS
204 XBT_PUBLIC(void) sg_platf_new_AS_seal(void);                     // That AS is fully described
205
206 XBT_PUBLIC(void) sg_platf_new_host   (sg_platf_host_cbarg_t   host);   // Add an host   to the currently described AS
207 XBT_PUBLIC(void) sg_platf_new_hostlink(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
208 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router  to the currently described AS
209 XBT_PUBLIC(void) sg_platf_new_link   (sg_platf_link_cbarg_t link);     // Add a link    to the currently described AS
210 XBT_PUBLIC(void) sg_platf_new_peer   (sg_platf_peer_cbarg_t peer);     // Add a peer    to the currently described AS
211 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
212 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
213
214 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
215 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
216
217 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
218
219 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
220 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
221 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
222
223 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
224 XBT_PRIVATE void sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect);
225
226 /* Prototypes of the functions offered by flex */
227 XBT_PUBLIC(int) surf_parse_lex(void);
228 XBT_PUBLIC(int) surf_parse_get_lineno(void);
229 XBT_PUBLIC(FILE *) surf_parse_get_in(void);
230 XBT_PUBLIC(FILE *) surf_parse_get_out(void);
231 XBT_PUBLIC(yy_size_t) surf_parse_get_leng(void);
232 XBT_PUBLIC(char *) surf_parse_get_text(void);
233 XBT_PUBLIC(void) surf_parse_set_lineno(int line_number);
234 XBT_PUBLIC(void) surf_parse_set_in(FILE * in_str);
235 XBT_PUBLIC(void) surf_parse_set_out(FILE * out_str);
236 XBT_PUBLIC(int) surf_parse_get_debug(void);
237 XBT_PUBLIC(void) surf_parse_set_debug(int bdebug);
238 XBT_PUBLIC(int) surf_parse_lex_destroy(void);
239
240 /* To include files (?) */
241 XBT_PRIVATE void surfxml_bufferstack_push(int _new);
242 XBT_PRIVATE void surfxml_bufferstack_pop(int _new);
243 XBT_PUBLIC_DATA(int) surfxml_bufferstack_size;
244
245 XBT_PUBLIC(void) routing_route_free(sg_platf_route_cbarg_t route);
246 /********** Instr. **********/
247 XBT_PRIVATE void sg_instr_AS_begin(sg_platf_AS_cbarg_t AS);
248 XBT_PRIVATE void sg_instr_new_router(sg_platf_router_cbarg_t router);
249 XBT_PRIVATE void sg_instr_new_host(sg_platf_host_cbarg_t host);
250 XBT_PRIVATE void sg_instr_AS_end(void);
251
252 typedef struct s_surf_parsing_link_up_down *surf_parsing_link_up_down_t;
253 typedef struct s_surf_parsing_link_up_down {
254   Link* linkUp;
255   Link* linkDown;
256 } s_surf_parsing_link_up_down_t;
257
258
259 SG_END_DECL()
260
261 namespace simgrid {
262 namespace surf {
263
264 extern XBT_PRIVATE simgrid::xbt::signal<void(sg_platf_link_cbarg_t)> on_link;
265 extern XBT_PRIVATE simgrid::xbt::signal<void(sg_platf_cluster_cbarg_t)> on_cluster;
266
267 }
268 }
269
270 #endif                          /* SG_PLATF_H */