1 /* platf_private.h - Interface to the SimGrid platforms which visibility should be limited to this directory */
3 /* Copyright (c) 2004-2022. 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 "simgrid/s4u/Link.hpp"
14 #include "src/surf/xml/simgrid_dtd.h"
20 namespace simgrid::kernel::routing {
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 class HostCreationArgs {
35 std::vector<double> speed_per_pstate;
38 profile::Profile* speed_trace = nullptr;
39 profile::Profile* state_trace = nullptr;
40 std::string coord = "";
43 class HostLinkCreationArgs {
47 std::string link_down;
50 class LinkCreationArgs {
53 std::vector<double> bandwidths;
54 profile::Profile* bandwidth_trace = nullptr;
56 profile::Profile* latency_trace = nullptr;
57 profile::Profile* state_trace = nullptr;
58 s4u::Link::SharingPolicy policy = s4u::Link::SharingPolicy::FATPIPE;
59 std::unordered_map<std::string, std::string> properties;
62 class PeerCreationArgs {
69 profile::Profile* speed_trace;
70 profile::Profile* state_trace;
73 class RouteCreationArgs {
75 bool symmetrical = false;
76 NetPoint* src = nullptr;
77 NetPoint* dst = nullptr;
78 NetPoint* gw_src = nullptr;
79 NetPoint* gw_dst = nullptr;
80 std::vector<simgrid::s4u::LinkInRoute> link_list;
83 enum class ClusterTopology { DRAGONFLY = 3, FAT_TREE = 2, FLAT = 1, TORUS = 0 };
85 class ClusterCreationArgs {
90 std::vector<int> radicals;
91 std::vector<double> speeds;
97 double loopback_bw = 0;
98 double loopback_lat = 0;
99 double limiter_link = 0;
100 ClusterTopology topology = ClusterTopology::FLAT;
101 std::string topo_parameters;
102 std::unordered_map<std::string, std::string> properties;
103 std::string router_id;
104 s4u::Link::SharingPolicy sharing_policy = s4u::Link::SharingPolicy::SPLITDUPLEX;
105 s4u::Link::SharingPolicy bb_sharing_policy = s4u::Link::SharingPolicy::SHARED;
108 class CabinetCreationArgs {
113 std::vector<int> radicals;
119 class ClusterZoneCreationArgs {
122 std::vector<HostLinkCreationArgs> host_links;
123 std::vector<CabinetCreationArgs> cabinets;
124 std::unique_ptr<LinkCreationArgs> backbone;
127 class DiskCreationArgs {
130 std::unordered_map<std::string, std::string> properties;
135 class ProfileCreationArgs {
143 enum class TraceConnectKind { HOST_AVAIL, SPEED, LINK_AVAIL, BANDWIDTH, LATENCY };
145 class TraceConnectCreationArgs {
147 TraceConnectKind kind;
152 class ActorCreationArgs {
154 std::vector<std::string> args;
155 std::unordered_map<std::string, std::string> properties;
156 const char* host = nullptr;
157 const char* function = nullptr;
158 double start_time = 0.0;
159 double kill_time = 0.0;
160 bool restart_on_failure = false;
163 class ZoneCreationArgs {
169 extern XBT_PRIVATE xbt::signal<void(ClusterCreationArgs const&)> on_cluster_creation;
171 } // namespace simgrid::kernel::routing
173 /********** Routing **********/
174 void routing_cluster_add_backbone(std::unique_ptr<simgrid::kernel::routing::LinkCreationArgs> link);
175 /*** END of the parsing cruft ***/
177 XBT_PUBLIC simgrid::kernel::routing::NetZoneImpl*
178 sg_platf_new_zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone); // Begin description of new Zone
179 XBT_PUBLIC void sg_platf_new_zone_set_properties(const std::unordered_map<std::string, std::string>& props);
180 XBT_PUBLIC void sg_platf_new_zone_seal(); // That Zone is fully described
183 sg_platf_new_host_begin(const simgrid::kernel::routing::HostCreationArgs* host); // Add a host to the current Zone
184 XBT_PUBLIC void sg_platf_new_host_set_properties(const std::unordered_map<std::string, std::string>& props);
185 XBT_PUBLIC void sg_platf_new_host_seal(int pstate); // That Host is fully described
188 sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone
190 sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone
192 sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host
194 sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer); // Add a peer to the current Zone
195 XBT_PUBLIC void sg_platf_new_tag_cluster(
196 simgrid::kernel::routing::ClusterCreationArgs* clust); // Add a regular cluster to the current Zone
197 XBT_PUBLIC simgrid::kernel::routing::NetPoint* // Add a router to the current Zone
198 sg_platf_new_router(const std::string&, const std::string& coords);
200 sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone
201 XBT_PUBLIC void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route); // Add a route
202 XBT_PUBLIC void sg_platf_new_bypass_route(simgrid::kernel::routing::RouteCreationArgs* route); // Add a bypass route
204 XBT_PUBLIC void sg_platf_new_trace(const simgrid::kernel::routing::ProfileCreationArgs* trace);
206 XBT_PUBLIC void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor);
207 XBT_PRIVATE void sg_platf_trace_connect(simgrid::kernel::routing::TraceConnectCreationArgs* trace_connect);
209 /* Prototypes of the functions offered by flex */
210 XBT_PUBLIC int surf_parse_lex();
211 XBT_PUBLIC int surf_parse_get_lineno();
212 XBT_PUBLIC FILE* surf_parse_get_in();
213 XBT_PUBLIC FILE* surf_parse_get_out();
214 XBT_PUBLIC int surf_parse_get_leng();
215 XBT_PUBLIC char* surf_parse_get_text();
216 XBT_PUBLIC void surf_parse_set_lineno(int line_number);
217 XBT_PUBLIC void surf_parse_set_in(FILE* in_str);
218 XBT_PUBLIC void surf_parse_set_out(FILE* out_str);
219 XBT_PUBLIC int surf_parse_get_debug();
220 XBT_PUBLIC void surf_parse_set_debug(int bdebug);
221 XBT_PUBLIC int surf_parse_lex_destroy();
223 #endif /* SG_PLATF_H */