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"
19 extern XBT_PRIVATE std::unordered_map<std::string, simgrid::kernel::profile::Profile*> traces_set_list;
21 namespace simgrid::kernel::routing {
22 /* ***************************************** */
24 * Platform creation functions. Instead of passing 123 arguments to the creation functions
25 * (one for each possible XML attribute), we pass structures containing them all. It removes the
26 * chances of switching arguments by error, and reduce the burden when we add a new attribute:
27 * old models can just continue to ignore it without having to update their headers.
29 * It shouldn't be too costly at runtime, provided that structures living on the stack are
30 * used, instead of malloced structures.
33 class HostCreationArgs {
36 std::vector<double> speed_per_pstate;
39 profile::Profile* speed_trace = nullptr;
40 profile::Profile* state_trace = nullptr;
41 std::string coord = "";
44 class HostLinkCreationArgs {
48 std::string link_down;
51 class LinkCreationArgs {
54 std::vector<double> bandwidths;
55 profile::Profile* bandwidth_trace = nullptr;
57 profile::Profile* latency_trace = nullptr;
58 profile::Profile* state_trace = nullptr;
59 s4u::Link::SharingPolicy policy = s4u::Link::SharingPolicy::FATPIPE;
60 std::unordered_map<std::string, std::string> properties;
63 class PeerCreationArgs {
70 profile::Profile* speed_trace;
71 profile::Profile* state_trace;
74 class RouteCreationArgs {
76 bool symmetrical = false;
77 NetPoint* src = nullptr;
78 NetPoint* dst = nullptr;
79 NetPoint* gw_src = nullptr;
80 NetPoint* gw_dst = nullptr;
81 std::vector<simgrid::s4u::LinkInRoute> link_list;
84 enum class ClusterTopology { DRAGONFLY = 3, FAT_TREE = 2, FLAT = 1, TORUS = 0 };
86 class ClusterCreationArgs {
91 std::vector<int> radicals;
92 std::vector<double> speeds;
98 double loopback_bw = 0;
99 double loopback_lat = 0;
100 double limiter_link = 0;
101 ClusterTopology topology = ClusterTopology::FLAT;
102 std::string topo_parameters;
103 std::unordered_map<std::string, std::string> properties;
104 std::string router_id;
105 s4u::Link::SharingPolicy sharing_policy = s4u::Link::SharingPolicy::SPLITDUPLEX;
106 s4u::Link::SharingPolicy bb_sharing_policy = s4u::Link::SharingPolicy::SHARED;
109 class CabinetCreationArgs {
114 std::vector<int> radicals;
120 class ClusterZoneCreationArgs {
123 std::vector<HostLinkCreationArgs> host_links;
124 std::vector<CabinetCreationArgs> cabinets;
125 std::unique_ptr<LinkCreationArgs> backbone;
128 class DiskCreationArgs {
131 std::unordered_map<std::string, std::string> properties;
136 class ProfileCreationArgs {
144 enum class TraceConnectKind { HOST_AVAIL, SPEED, LINK_AVAIL, BANDWIDTH, LATENCY };
146 class TraceConnectCreationArgs {
148 TraceConnectKind kind;
153 class ActorCreationArgs {
155 std::vector<std::string> args;
156 std::unordered_map<std::string, std::string> properties;
157 const char* host = nullptr;
158 const char* function = nullptr;
159 double start_time = 0.0;
160 double kill_time = 0.0;
161 bool restart_on_failure = false;
164 class ZoneCreationArgs {
170 extern XBT_PRIVATE xbt::signal<void(ClusterCreationArgs const&)> on_cluster_creation;
172 } // namespace simgrid::kernel::routing
174 /********** Routing **********/
175 void routing_cluster_add_backbone(std::unique_ptr<simgrid::kernel::routing::LinkCreationArgs> link);
176 /*** END of the parsing cruft ***/
178 XBT_PUBLIC simgrid::kernel::routing::NetZoneImpl*
179 sg_platf_new_zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone); // Begin description of new Zone
180 XBT_PUBLIC void sg_platf_new_zone_set_properties(const std::unordered_map<std::string, std::string>& props);
181 XBT_PUBLIC void sg_platf_new_zone_seal(); // That Zone is fully described
184 sg_platf_new_host_begin(const simgrid::kernel::routing::HostCreationArgs* host); // Add a host to the current Zone
185 XBT_PUBLIC void sg_platf_new_host_set_properties(const std::unordered_map<std::string, std::string>& props);
186 XBT_PUBLIC void sg_platf_new_host_seal(int pstate); // That Host is fully described
189 sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone
191 sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone
193 sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host
195 sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer); // Add a peer to the current Zone
196 XBT_PUBLIC void sg_platf_new_tag_cluster(
197 simgrid::kernel::routing::ClusterCreationArgs* clust); // Add a regular cluster to the current Zone
198 XBT_PUBLIC simgrid::kernel::routing::NetPoint* // Add a router to the current Zone
199 sg_platf_new_router(const std::string&, const std::string& coords);
201 sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone
202 XBT_PUBLIC void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route); // Add a route
203 XBT_PUBLIC void sg_platf_new_bypass_route(simgrid::kernel::routing::RouteCreationArgs* route); // Add a bypass route
205 XBT_PUBLIC void sg_platf_new_trace(const simgrid::kernel::routing::ProfileCreationArgs* trace);
207 XBT_PUBLIC void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor);
209 /* Prototypes of the functions offered by flex */
210 XBT_PUBLIC int simgrid_parse_lex();
211 XBT_PUBLIC int simgrid_parse_get_lineno();
212 XBT_PUBLIC FILE* simgrid_parse_get_in();
213 XBT_PUBLIC FILE* simgrid_parse_get_out();
214 XBT_PUBLIC int simgrid_parse_get_leng();
215 XBT_PUBLIC char* simgrid_parse_get_text();
216 XBT_PUBLIC void simgrid_parse_set_lineno(int line_number);
217 XBT_PUBLIC void simgrid_parse_set_in(FILE* in_str);
218 XBT_PUBLIC void simgrid_parse_set_out(FILE* out_str);
219 XBT_PUBLIC int simgrid_parse_get_debug();
220 XBT_PUBLIC void simgrid_parse_set_debug(int bdebug);
221 XBT_PUBLIC int simgrid_parse_lex_destroy();
223 #endif /* SG_PLATF_H */