1 /* platf_private.h - Interface to the SimGrid platforms which visibility should be limited to this directory */
3 /* Copyright (c) 2004-2017. 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;
26 /* ***************************************** */
28 * Platform creation functions. Instead of passing 123 arguments to the creation functions
29 * (one for each possible XML attribute), we pass structures containing them all. It removes the
30 * chances of switching arguments by error, and reduce the burden when we add a new attribute:
31 * old models can just continue to ignore it without having to update their headers.
33 * It shouldn't be too costly at runtime, provided that structures living on the stack are
34 * used, instead of malloced structures.
37 struct s_sg_platf_host_cbarg_t {
38 const char* id = nullptr;
39 std::vector<double> speed_per_pstate;
42 tmgr_trace_t speed_trace = nullptr;
43 tmgr_trace_t state_trace = nullptr;
44 const char* coord = nullptr;
45 std::map<std::string, std::string>* properties = nullptr;
47 typedef s_sg_platf_host_cbarg_t* sg_platf_host_cbarg_t;
49 class HostLinkCreationArgs {
53 std::string link_down;
56 class LinkCreationArgs {
60 tmgr_trace_t bandwidth_trace = nullptr;
62 tmgr_trace_t latency_trace = nullptr;
63 tmgr_trace_t state_trace = nullptr;
64 e_surf_link_sharing_policy_t policy = SURF_LINK_FATPIPE;
65 std::map<std::string, std::string>* properties = nullptr;
68 class PeerCreationArgs {
75 tmgr_trace_t speed_trace;
76 tmgr_trace_t state_trace;
79 class RouteCreationArgs {
81 bool symmetrical = false;
82 sg_netpoint_t src = nullptr;
83 sg_netpoint_t dst = nullptr;
84 sg_netpoint_t gw_src = nullptr;
85 sg_netpoint_t gw_dst = nullptr;
86 std::vector<simgrid::surf::LinkImpl*> link_list;
89 enum class ClusterTopology { DRAGONFLY = 3, FAT_TREE = 2, FLAT = 1, TORUS = 0 };
91 class ClusterCreationArgs {
96 std::vector<int>* radicals = nullptr;
97 std::vector<double> speeds;
103 double loopback_bw = 0;
104 double loopback_lat = 0;
105 double limiter_link = 0;
106 ClusterTopology topology;
107 std::string topo_parameters;
108 std::map<std::string, std::string>* properties;
109 std::string router_id;
110 e_surf_link_sharing_policy_t sharing_policy;
111 e_surf_link_sharing_policy_t bb_sharing_policy;
114 class CabinetCreationArgs {
119 std::vector<int>* radicals;
125 class StorageCreationArgs {
130 std::map<std::string, std::string>* properties;
134 class StorageTypeCreationArgs {
139 std::map<std::string, std::string>* properties;
140 std::map<std::string, std::string>* model_properties;
144 class MountCreationArgs {
146 std::string storageId;
150 class TraceCreationArgs {
158 enum class TraceConnectKind { HOST_AVAIL, SPEED, LINK_AVAIL, BANDWIDTH, LATENCY };
160 class TraceConnectCreationArgs {
162 TraceConnectKind kind;
167 enum class ActorOnFailure { DIE, RESTART };
169 class ActorCreationArgs {
171 std::vector<std::string> args;
172 std::map<std::string, std::string>* properties = nullptr;
173 const char* host = nullptr;
174 const char* function = nullptr;
175 double start_time = 0.0;
176 double kill_time = 0.0;
177 ActorOnFailure on_failure;
180 class ZoneCreationArgs {
186 /********** Routing **********/
187 void routing_cluster_add_backbone(simgrid::surf::LinkImpl* bb);
188 /*** END of the parsing cruft ***/
190 XBT_PUBLIC(void) sg_platf_begin(); // Start a new platform
191 XBT_PUBLIC(void) sg_platf_end(); // Finish the creation of the platform
193 XBT_PUBLIC(simgrid::s4u::NetZone*) sg_platf_new_Zone_begin(ZoneCreationArgs* zone); // Begin description of new Zone
194 XBT_PUBLIC(void) sg_platf_new_Zone_seal(); // That Zone is fully described
196 XBT_PUBLIC(void) sg_platf_new_host(sg_platf_host_cbarg_t host); // Add a host to the current Zone
197 XBT_PUBLIC(void) sg_platf_new_hostlink(HostLinkCreationArgs* h); // Add a host_link to the current Zone
198 XBT_PUBLIC(void) sg_platf_new_link(LinkCreationArgs* link); // Add a link to the current Zone
199 XBT_PUBLIC(void) sg_platf_new_peer(PeerCreationArgs* peer); // Add a peer to the current Zone
200 XBT_PUBLIC(void) sg_platf_new_cluster(ClusterCreationArgs* clust); // Add a cluster to the current Zone
201 XBT_PUBLIC(void) sg_platf_new_cabinet(CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone
202 XBT_PUBLIC(simgrid::kernel::routing::NetPoint*) // Add a router to the current Zone
203 sg_platf_new_router(std::string, const char* coords);
205 XBT_PUBLIC(void) sg_platf_new_route(RouteCreationArgs* route); // Add a route
206 XBT_PUBLIC(void) sg_platf_new_bypassRoute(RouteCreationArgs* bypassroute); // Add a bypassRoute
208 XBT_PUBLIC(void) sg_platf_new_trace(TraceCreationArgs* trace);
210 XBT_PUBLIC(void) sg_platf_new_storage(StorageCreationArgs* storage); // Add a storage to the current Zone
211 XBT_PUBLIC(void) sg_platf_new_storage_type(StorageTypeCreationArgs* storage_type);
212 XBT_PUBLIC(void) sg_platf_new_mount(MountCreationArgs* mount);
214 XBT_PUBLIC(void) sg_platf_new_actor(ActorCreationArgs* actor);
215 XBT_PRIVATE void sg_platf_trace_connect(TraceConnectCreationArgs* trace_connect);
217 /* Prototypes of the functions offered by flex */
218 XBT_PUBLIC(int) surf_parse_lex();
219 XBT_PUBLIC(int) surf_parse_get_lineno();
220 XBT_PUBLIC(FILE *) surf_parse_get_in();
221 XBT_PUBLIC(FILE *) surf_parse_get_out();
222 XBT_PUBLIC(int) surf_parse_get_leng();
223 XBT_PUBLIC(char *) surf_parse_get_text();
224 XBT_PUBLIC(void) surf_parse_set_lineno(int line_number);
225 XBT_PUBLIC(void) surf_parse_set_in(FILE * in_str);
226 XBT_PUBLIC(void) surf_parse_set_out(FILE * out_str);
227 XBT_PUBLIC(int) surf_parse_get_debug();
228 XBT_PUBLIC(void) surf_parse_set_debug(int bdebug);
229 XBT_PUBLIC(int) surf_parse_lex_destroy();
235 extern XBT_PRIVATE simgrid::xbt::signal<void(ClusterCreationArgs*)> on_cluster;
239 #endif /* SG_PLATF_H */