Logo AND Algorithmique Numérique Distribuée

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