1 /* platf_private.h - Interface to the SimGrid platforms which visibility should be limited to this directory */
3 /* Copyright (c) 2004-2023. The SimGrid Team. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
11 #include "simgrid/host.h"
12 #include "simgrid/s4u/Link.hpp"
13 #include "src/kernel/xml/simgrid_dtd.h"
20 extern XBT_PRIVATE std::unordered_map<std::string, simgrid::kernel::profile::Profile*> traces_set_list;
22 namespace simgrid::kernel::routing {
23 /* ***************************************** */
25 * Platform creation functions. Instead of passing 123 arguments to the creation functions
26 * (one for each possible XML attribute), we pass structures containing them all. It removes the
27 * chances of switching arguments by error, and reduce the burden when we add a new attribute:
28 * old models can just continue to ignore it without having to update their headers.
30 * It shouldn't be too costly at runtime, provided that structures living on the stack are
31 * used, instead of malloced structures.
34 class HostCreationArgs {
37 std::vector<double> speed_per_pstate;
40 profile::Profile* speed_trace = nullptr;
41 profile::Profile* state_trace = nullptr;
42 std::string coord = "";
45 class HostLinkCreationArgs {
49 std::string link_down;
52 class LinkCreationArgs {
55 std::vector<double> bandwidths;
56 profile::Profile* bandwidth_trace = nullptr;
58 profile::Profile* latency_trace = nullptr;
59 profile::Profile* state_trace = nullptr;
60 s4u::Link::SharingPolicy policy = s4u::Link::SharingPolicy::FATPIPE;
61 std::unordered_map<std::string, std::string> properties;
64 class PeerCreationArgs {
71 profile::Profile* speed_trace;
72 profile::Profile* state_trace;
75 class RouteCreationArgs {
77 bool symmetrical = false;
78 NetPoint* src = nullptr;
79 NetPoint* dst = nullptr;
80 NetPoint* gw_src = nullptr;
81 NetPoint* gw_dst = nullptr;
82 std::vector<simgrid::s4u::LinkInRoute> link_list;
85 enum class ClusterTopology { DRAGONFLY = 3, FAT_TREE = 2, FLAT = 1, TORUS = 0 };
87 class ClusterCreationArgs {
92 std::vector<int> radicals;
93 std::vector<double> speeds;
99 double loopback_bw = 0;
100 double loopback_lat = 0;
101 double limiter_link = 0;
102 ClusterTopology topology = ClusterTopology::FLAT;
103 std::string topo_parameters;
104 std::unordered_map<std::string, std::string> properties;
105 std::string router_id;
106 s4u::Link::SharingPolicy sharing_policy = s4u::Link::SharingPolicy::SPLITDUPLEX;
107 s4u::Link::SharingPolicy bb_sharing_policy = s4u::Link::SharingPolicy::SHARED;
110 class CabinetCreationArgs {
115 std::vector<int> radicals;
121 class ClusterZoneCreationArgs {
124 std::vector<HostLinkCreationArgs> host_links;
125 std::vector<CabinetCreationArgs> cabinets;
126 std::unique_ptr<LinkCreationArgs> backbone;
129 class DiskCreationArgs {
132 std::unordered_map<std::string, std::string> properties;
137 class ProfileCreationArgs {
145 enum class TraceConnectKind { HOST_AVAIL, SPEED, LINK_AVAIL, BANDWIDTH, LATENCY };
147 class TraceConnectCreationArgs {
149 TraceConnectKind kind;
154 class ActorCreationArgs {
156 std::vector<std::string> args;
157 std::unordered_map<std::string, std::string> properties;
158 const char* host = nullptr;
159 const char* function = nullptr;
160 double start_time = 0.0;
161 double kill_time = 0.0;
162 bool restart_on_failure = false;
165 class ZoneCreationArgs {
171 extern XBT_PRIVATE xbt::signal<void(ClusterCreationArgs const&)> on_cluster_creation;
173 } // namespace simgrid::kernel::routing
175 /********** Routing **********/
176 void routing_cluster_add_backbone(std::unique_ptr<simgrid::kernel::routing::LinkCreationArgs> link);
177 /*** END of the parsing cruft ***/
179 XBT_PUBLIC simgrid::kernel::routing::NetZoneImpl*
180 sg_platf_new_zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone); // Begin description of new Zone
181 XBT_PUBLIC void sg_platf_new_zone_set_properties(const std::unordered_map<std::string, std::string>& props);
182 XBT_PUBLIC void sg_platf_new_zone_seal(); // That Zone is fully described
185 sg_platf_new_host_begin(const simgrid::kernel::routing::HostCreationArgs* host); // Add a host to the current Zone
186 XBT_PUBLIC void sg_platf_new_host_set_properties(const std::unordered_map<std::string, std::string>& props);
187 XBT_PUBLIC void sg_platf_new_host_seal(int pstate); // That Host is fully described
190 sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone
192 sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone
194 sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host
196 sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer); // Add a peer to the current Zone
197 XBT_PUBLIC void sg_platf_new_tag_cluster(
198 simgrid::kernel::routing::ClusterCreationArgs* clust); // Add a regular cluster to the current Zone
199 XBT_PUBLIC simgrid::kernel::routing::NetPoint* // Add a router to the current Zone
200 sg_platf_new_router(const std::string&, const std::string& coords);
202 sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone
203 XBT_PUBLIC void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route); // Add a route
204 XBT_PUBLIC void sg_platf_new_bypass_route(simgrid::kernel::routing::RouteCreationArgs* route); // Add a bypass route
206 XBT_PUBLIC void sg_platf_new_trace(const simgrid::kernel::routing::ProfileCreationArgs* trace);
208 XBT_PUBLIC void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor);
210 /* Prototypes of the functions offered by flex */
211 XBT_PUBLIC int simgrid_parse_lex();
212 XBT_PUBLIC int simgrid_parse_get_lineno();
213 XBT_PUBLIC FILE* simgrid_parse_get_in();
214 XBT_PUBLIC FILE* simgrid_parse_get_out();
215 XBT_PUBLIC int simgrid_parse_get_leng();
216 XBT_PUBLIC char* simgrid_parse_get_text();
217 XBT_PUBLIC void simgrid_parse_set_lineno(int line_number);
218 XBT_PUBLIC void simgrid_parse_set_in(FILE* in_str);
219 XBT_PUBLIC void simgrid_parse_set_out(FILE* out_str);
220 XBT_PUBLIC int simgrid_parse_get_debug();
221 XBT_PUBLIC void simgrid_parse_set_debug(int bdebug);
222 XBT_PUBLIC int simgrid_parse_lex_destroy();
224 #endif /* SG_PLATF_H */