Logo AND Algorithmique Numérique Distribuée

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