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"
19 #include "src/surf/xml/simgrid_dtd.h"
21 #ifndef YY_TYPEDEF_YY_SIZE_T
22 #define YY_TYPEDEF_YY_SIZE_T
23 typedef size_t yy_size_t;
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;
33 /* ***************************************** */
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.
40 * It shouldn't be too costly at runtime, provided that structures living on the stack are
41 * used, instead of malloced structures.
46 std::vector<double> speed_per_pstate;
49 tmgr_trace_t speed_trace;
50 tmgr_trace_t state_trace;
52 std::map<std::string, std::string>* properties;
53 } s_sg_platf_host_cbarg_t;
54 typedef s_sg_platf_host_cbarg_t* sg_platf_host_cbarg_t;
56 class HostLinkCreationArgs {
60 std::string link_down;
63 class LinkCreationArgs {
67 tmgr_trace_t bandwidth_trace = nullptr;
69 tmgr_trace_t latency_trace = nullptr;
70 tmgr_trace_t state_trace = nullptr;
71 e_surf_link_sharing_policy_t policy = SURF_LINK_FATPIPE;
72 std::map<std::string, std::string>* properties = nullptr;
75 class PeerCreationArgs {
82 tmgr_trace_t speed_trace;
83 tmgr_trace_t state_trace;
86 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
87 typedef struct s_sg_platf_route_cbarg {
93 std::vector<simgrid::surf::LinkImpl*>* link_list;
94 } s_sg_platf_route_cbarg_t;
96 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
97 typedef struct s_sg_platf_cluster_cbarg {
101 std::vector<int>* radicals;
102 std::vector<double> speeds;
111 e_surf_cluster_topology_t topology;
112 const char* topo_parameters;
113 std::map<std::string, std::string>* 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;
119 class CabinetCreationArgs {
124 std::vector<int>* radicals;
130 class StorageCreationArgs {
135 std::map<std::string, std::string>* properties;
139 class StorageTypeCreationArgs {
144 std::map<std::string, std::string>* properties;
145 std::map<std::string, std::string>* model_properties;
149 class MountCreationArgs {
151 std::string storageId;
155 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
156 typedef struct s_sg_platf_prop_cbarg {
159 } s_sg_platf_prop_cbarg_t;
161 class TraceCreationArgs {
169 class TraceConnectCreationArgs {
171 e_surf_trace_connect_kind_t kind;
176 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
177 typedef struct s_sg_platf_process_cbarg {
180 std::map<std::string, std::string>* properties;
182 const char *function;
185 e_surf_process_on_failure_t on_failure;
186 } s_sg_platf_process_cbarg_t;
188 class ZoneCreationArgs {
194 /* The default current property receiver. Setup in the corresponding opening callbacks. */
195 extern std::map<std::string, std::string>* current_property_set;
197 /********** Routing **********/
198 void routing_cluster_add_backbone(simgrid::surf::LinkImpl* bb);
199 /*** END of the parsing cruft ***/
201 XBT_PUBLIC(void) sg_platf_begin(); // Start a new platform
202 XBT_PUBLIC(void) sg_platf_end(); // Finish the creation of the platform
204 XBT_PUBLIC(simgrid::s4u::NetZone*) sg_platf_new_Zone_begin(ZoneCreationArgs* zone); // Begin description of new Zone
205 XBT_PUBLIC(void) sg_platf_new_Zone_seal(); // That Zone is fully described
207 XBT_PUBLIC(void) sg_platf_new_host(sg_platf_host_cbarg_t host); // Add a host to the current Zone
208 XBT_PUBLIC(void) sg_platf_new_hostlink(HostLinkCreationArgs* h); // Add a host_link to the current Zone
209 XBT_PUBLIC(void) sg_platf_new_link(LinkCreationArgs* link); // Add a link to the current Zone
210 XBT_PUBLIC(void) sg_platf_new_peer(PeerCreationArgs* peer); // Add a peer to the current Zone
211 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the current Zone
212 XBT_PUBLIC(void) sg_platf_new_cabinet(CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone
213 XBT_PUBLIC(simgrid::kernel::routing::NetPoint*) // Add a router to the current Zone
214 sg_platf_new_router(const char* name, const char* coords);
216 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
217 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
219 XBT_PUBLIC(void) sg_platf_new_trace(TraceCreationArgs* trace);
221 XBT_PUBLIC(void) sg_platf_new_storage(StorageCreationArgs* storage); // Add a storage to the current Zone
222 XBT_PUBLIC(void) sg_platf_new_storage_type(StorageTypeCreationArgs* storage_type);
223 XBT_PUBLIC(void) sg_platf_new_mount(MountCreationArgs* mount);
225 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
226 XBT_PRIVATE void sg_platf_trace_connect(TraceConnectCreationArgs* trace_connect);
228 /* Prototypes of the functions offered by flex */
229 XBT_PUBLIC(int) surf_parse_lex();
230 XBT_PUBLIC(int) surf_parse_get_lineno();
231 XBT_PUBLIC(FILE *) surf_parse_get_in();
232 XBT_PUBLIC(FILE *) surf_parse_get_out();
233 XBT_PUBLIC(int) surf_parse_get_leng();
234 XBT_PUBLIC(char *) surf_parse_get_text();
235 XBT_PUBLIC(void) surf_parse_set_lineno(int line_number);
236 XBT_PUBLIC(void) surf_parse_set_in(FILE * in_str);
237 XBT_PUBLIC(void) surf_parse_set_out(FILE * out_str);
238 XBT_PUBLIC(int) surf_parse_get_debug();
239 XBT_PUBLIC(void) surf_parse_set_debug(int bdebug);
240 XBT_PUBLIC(int) surf_parse_lex_destroy();
242 XBT_PUBLIC(void) routing_route_free(sg_platf_route_cbarg_t route);
249 extern XBT_PRIVATE simgrid::xbt::signal<void(sg_platf_cluster_cbarg_t)> on_cluster;
254 #endif /* SG_PLATF_H */