Logo AND Algorithmique Numérique Distribuée

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