Logo AND Algorithmique Numérique Distribuée

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