Logo AND Algorithmique Numérique Distribuée

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