1 /* platf_private.h - Interface to the SimGrid platforms which visibility should be limited to this directory */
3 /* Copyright (c) 2004-2015. The SimGrid Team.
4 * All rights reserved. */
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. */
12 #include "simgrid/host.h"
13 #include "src/surf/xml/platf.hpp"
18 #include "src/surf/xml/simgrid_dtd.h"
20 #ifndef YY_TYPEDEF_YY_SIZE_T
21 #define YY_TYPEDEF_YY_SIZE_T
22 typedef size_t yy_size_t;
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;
32 /* ***************************************** */
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.
39 * It shouldn't be too costly at runtime, provided that structures living on the stack are
40 * used, instead of malloced structures.
45 std::vector<double> speed_per_pstate;
48 tmgr_trace_t speed_trace;
49 tmgr_trace_t state_trace;
51 xbt_dict_t properties;
52 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
57 const char* link_down;
58 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
63 tmgr_trace_t bandwidth_trace;
65 tmgr_trace_t latency_trace;
66 tmgr_trace_t state_trace;
67 e_surf_link_sharing_policy_t policy;
68 xbt_dict_t properties;
69 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
71 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
72 typedef struct s_sg_platf_peer_cbarg {
78 tmgr_trace_t speed_trace;
79 tmgr_trace_t state_trace;
80 } s_sg_platf_peer_cbarg_t;
82 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
83 typedef struct s_sg_platf_route_cbarg {
89 std::vector<simgrid::surf::LinkImpl*>* link_list;
90 } s_sg_platf_route_cbarg_t;
92 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
93 typedef struct s_sg_platf_cluster_cbarg {
97 std::vector<int>* radicals;
107 e_surf_cluster_topology_t topology;
108 const char* topo_parameters;
109 xbt_dict_t properties;
110 const char* router_id;
111 e_surf_link_sharing_policy_t sharing_policy;
112 e_surf_link_sharing_policy_t bb_sharing_policy;
113 } s_sg_platf_cluster_cbarg_t;
115 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
116 typedef struct s_sg_platf_cabinet_cbarg {
120 std::vector<int>* radicals;
124 } s_sg_platf_cabinet_cbarg_t;
130 const char* content_type;
131 xbt_dict_t properties;
133 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
139 const char* content_type;
140 xbt_dict_t properties;
141 xbt_dict_t model_properties;
143 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
146 const char* storageId;
148 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
150 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
151 typedef struct s_sg_platf_prop_cbarg {
154 } s_sg_platf_prop_cbarg_t;
156 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
157 typedef struct s_sg_platf_trace_cbarg {
162 } s_sg_platf_trace_cbarg_t;
164 typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
165 typedef struct s_sg_platf_trace_connect_cbarg {
166 e_surf_trace_connect_kind_t kind;
169 } s_sg_platf_trace_connect_cbarg_t;
171 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
172 typedef struct s_sg_platf_process_cbarg {
175 xbt_dict_t properties;
177 const char *function;
180 e_surf_process_on_failure_t on_failure;
181 } s_sg_platf_process_cbarg_t;
183 typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
184 typedef struct s_sg_platf_AS_cbarg {
187 } s_sg_platf_AS_cbarg_t;
189 #define SG_PLATF_AS_INITIALIZER {nullptr,0}
191 /********** Routing **********/
192 void routing_cluster_add_backbone(simgrid::surf::LinkImpl* bb);
193 /*** END of the parsing cruft ***/
195 XBT_PUBLIC(void) sg_platf_begin(); // Start a new platform
196 XBT_PUBLIC(void) sg_platf_end(); // Finish the creation of the platform
198 XBT_PUBLIC(simgrid::s4u::NetZone*) sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS); // Begin description of new AS
199 XBT_PUBLIC(void) sg_platf_new_AS_seal(); // That AS is fully described
201 XBT_PUBLIC(void) sg_platf_new_host (sg_platf_host_cbarg_t host); // Add an host to the currently described AS
202 XBT_PUBLIC(void) sg_platf_new_hostlink(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
203 XBT_PUBLIC(simgrid::kernel::routing::NetPoint*)
204 sg_platf_new_router(const char* name, const char* coords); // Add a router to the currently described AS
205 XBT_PUBLIC(void) sg_platf_new_link (sg_platf_link_cbarg_t link); // Add a link to the currently described AS
206 XBT_PUBLIC(void) sg_platf_new_peer (sg_platf_peer_cbarg_t peer); // Add a peer to the currently described AS
207 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
208 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
210 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
211 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
213 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
215 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
216 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
217 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
219 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
220 XBT_PRIVATE void sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect);
222 /* Prototypes of the functions offered by flex */
223 XBT_PUBLIC(int) surf_parse_lex();
224 XBT_PUBLIC(int) surf_parse_get_lineno();
225 XBT_PUBLIC(FILE *) surf_parse_get_in();
226 XBT_PUBLIC(FILE *) surf_parse_get_out();
227 XBT_PUBLIC(int) surf_parse_get_leng();
228 XBT_PUBLIC(char *) surf_parse_get_text();
229 XBT_PUBLIC(void) surf_parse_set_lineno(int line_number);
230 XBT_PUBLIC(void) surf_parse_set_in(FILE * in_str);
231 XBT_PUBLIC(void) surf_parse_set_out(FILE * out_str);
232 XBT_PUBLIC(int) surf_parse_get_debug();
233 XBT_PUBLIC(void) surf_parse_set_debug(int bdebug);
234 XBT_PUBLIC(int) surf_parse_lex_destroy();
236 /* To include files (?) */
237 XBT_PRIVATE void surfxml_bufferstack_push(int _new);
238 XBT_PRIVATE void surfxml_bufferstack_pop(int _new);
239 XBT_PUBLIC_DATA(int) surfxml_bufferstack_size;
241 XBT_PUBLIC(void) routing_route_free(sg_platf_route_cbarg_t route);
242 /********** Instr. **********/
243 XBT_PRIVATE void sg_instr_AS_begin(sg_platf_AS_cbarg_t AS);
244 XBT_PRIVATE void sg_instr_new_router(const char* name);
245 XBT_PRIVATE void sg_instr_new_host(simgrid::s4u::Host& host);
246 XBT_PRIVATE void sg_instr_AS_end();
253 extern XBT_PRIVATE simgrid::xbt::signal<void(sg_platf_cluster_cbarg_t)> on_cluster;
258 #endif /* SG_PLATF_H */