1 /* platf_private.h - Interface to the SimGrid platforms which visibility should be limited to this directory */
3 /* Copyright (c) 2004-2018. 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"
21 /* ***************************************** */
23 * Platform creation functions. Instead of passing 123 arguments to the creation functions
24 * (one for each possible XML attribute), we pass structures containing them all. It removes the
25 * chances of switching arguments by error, and reduce the burden when we add a new attribute:
26 * old models can just continue to ignore it without having to update their headers.
28 * It shouldn't be too costly at runtime, provided that structures living on the stack are
29 * used, instead of malloced structures.
32 struct HostCreationArgs {
33 const char* id = nullptr;
34 std::vector<double> speed_per_pstate;
37 tmgr_trace_t speed_trace = nullptr;
38 tmgr_trace_t state_trace = nullptr;
39 const char* coord = nullptr;
40 std::map<std::string, std::string>* properties = nullptr;
43 class HostLinkCreationArgs {
47 std::string link_down;
50 class LinkCreationArgs {
54 tmgr_trace_t bandwidth_trace = nullptr;
56 tmgr_trace_t latency_trace = nullptr;
57 tmgr_trace_t state_trace = nullptr;
58 e_surf_link_sharing_policy_t policy = SURF_LINK_FATPIPE;
59 std::map<std::string, std::string>* properties = nullptr;
62 class PeerCreationArgs {
69 tmgr_trace_t speed_trace;
70 tmgr_trace_t state_trace;
73 class RouteCreationArgs {
75 bool symmetrical = false;
76 sg_netpoint_t src = nullptr;
77 sg_netpoint_t dst = nullptr;
78 sg_netpoint_t gw_src = nullptr;
79 sg_netpoint_t gw_dst = nullptr;
80 std::vector<simgrid::surf::LinkImpl*> link_list;
83 enum class ClusterTopology { DRAGONFLY = 3, FAT_TREE = 2, FLAT = 1, TORUS = 0 };
85 class ClusterCreationArgs {
90 std::vector<int>* radicals = nullptr;
91 std::vector<double> speeds;
97 double loopback_bw = 0;
98 double loopback_lat = 0;
99 double limiter_link = 0;
100 ClusterTopology topology;
101 std::string topo_parameters;
102 std::map<std::string, std::string>* properties;
103 std::string router_id;
104 e_surf_link_sharing_policy_t sharing_policy;
105 e_surf_link_sharing_policy_t bb_sharing_policy;
108 class CabinetCreationArgs {
113 std::vector<int>* radicals;
119 class StorageCreationArgs {
124 std::map<std::string, std::string>* properties;
128 class StorageTypeCreationArgs {
133 std::map<std::string, std::string>* properties;
134 std::map<std::string, std::string>* model_properties;
138 class MountCreationArgs {
140 std::string storageId;
144 class TraceCreationArgs {
152 enum class TraceConnectKind { HOST_AVAIL, SPEED, LINK_AVAIL, BANDWIDTH, LATENCY };
154 class TraceConnectCreationArgs {
156 TraceConnectKind kind;
161 enum class ActorOnFailure { DIE, RESTART }; // FIXME: move to a better namespace
163 class ActorCreationArgs {
165 std::vector<std::string> args;
166 std::map<std::string, std::string>* properties = nullptr;
167 const char* host = nullptr;
168 const char* function = nullptr;
169 double start_time = 0.0;
170 double kill_time = 0.0;
171 ActorOnFailure on_failure;
174 class ZoneCreationArgs {
182 #include "src/surf/xml/simgrid_dtd.h"
184 #ifndef YY_TYPEDEF_YY_SIZE_T
185 #define YY_TYPEDEF_YY_SIZE_T
186 typedef size_t yy_size_t;
189 /********** Routing **********/
190 void routing_cluster_add_backbone(simgrid::surf::LinkImpl* bb);
191 /*** END of the parsing cruft ***/
193 XBT_PUBLIC void sg_platf_begin(); // Start a new platform
194 XBT_PUBLIC void sg_platf_end(); // Finish the creation of the platform
196 XBT_PUBLIC simgrid::s4u::NetZone* sg_platf_new_Zone_begin(simgrid::kernel::routing::ZoneCreationArgs* zone); // Begin description of new Zone
197 XBT_PUBLIC void sg_platf_new_Zone_seal(); // That Zone is fully described
199 XBT_PUBLIC void sg_platf_new_host(simgrid::kernel::routing::HostCreationArgs* host); // Add a host to the current Zone
200 XBT_PUBLIC void sg_platf_new_hostlink(simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone
201 XBT_PUBLIC void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone
202 XBT_PUBLIC void sg_platf_new_peer(simgrid::kernel::routing::PeerCreationArgs* peer); // Add a peer to the current Zone
203 XBT_PUBLIC void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* clust); // Add a cluster to the current Zone
204 XBT_PUBLIC void sg_platf_new_cabinet(simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone
205 XBT_PUBLIC simgrid::kernel::routing::NetPoint* // Add a router to the current Zone
206 sg_platf_new_router(std::string, const char* coords);
208 XBT_PUBLIC void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route); // Add a route
209 XBT_PUBLIC void sg_platf_new_bypassRoute(simgrid::kernel::routing::RouteCreationArgs* bypassroute); // Add a bypassRoute
211 XBT_PUBLIC void sg_platf_new_trace(simgrid::kernel::routing::TraceCreationArgs* trace);
213 XBT_PUBLIC void sg_platf_new_storage(simgrid::kernel::routing::StorageCreationArgs* storage); // Add a storage to the current Zone
214 XBT_PUBLIC void sg_platf_new_storage_type(simgrid::kernel::routing::StorageTypeCreationArgs* storage_type);
215 XBT_PUBLIC void sg_platf_new_mount(simgrid::kernel::routing::MountCreationArgs* mount);
217 XBT_PUBLIC void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor);
218 XBT_PRIVATE void sg_platf_trace_connect(simgrid::kernel::routing::TraceConnectCreationArgs* trace_connect);
220 /* Prototypes of the functions offered by flex */
221 XBT_PUBLIC int surf_parse_lex();
222 XBT_PUBLIC int surf_parse_get_lineno();
223 XBT_PUBLIC FILE* surf_parse_get_in();
224 XBT_PUBLIC FILE* surf_parse_get_out();
225 XBT_PUBLIC int surf_parse_get_leng();
226 XBT_PUBLIC char* surf_parse_get_text();
227 XBT_PUBLIC void surf_parse_set_lineno(int line_number);
228 XBT_PUBLIC void surf_parse_set_in(FILE* in_str);
229 XBT_PUBLIC void surf_parse_set_out(FILE* out_str);
230 XBT_PUBLIC int surf_parse_get_debug();
231 XBT_PUBLIC void surf_parse_set_debug(int bdebug);
232 XBT_PUBLIC int surf_parse_lex_destroy();
238 extern XBT_PRIVATE simgrid::xbt::signal<void(kernel::routing::ClusterCreationArgs*)> on_cluster;
242 #endif /* SG_PLATF_H */