Logo AND Algorithmique Numérique Distribuée

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