1 /* platf_private.h - Interface to the SimGrid platforms which visibility should be limited to this directory */
3 /* Copyright (c) 2004-2021. 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/platf.hpp"
15 #include "src/surf/xml/simgrid_dtd.h"
24 /* ***************************************** */
26 * Platform creation functions. Instead of passing 123 arguments to the creation functions
27 * (one for each possible XML attribute), we pass structures containing them all. It removes the
28 * chances of switching arguments by error, and reduce the burden when we add a new attribute:
29 * old models can just continue to ignore it without having to update their headers.
31 * It shouldn't be too costly at runtime, provided that structures living on the stack are
32 * used, instead of malloced structures.
35 class HostCreationArgs {
38 std::vector<double> speed_per_pstate;
41 profile::Profile* speed_trace = nullptr;
42 profile::Profile* state_trace = nullptr;
43 std::string coord = "";
46 class HostLinkCreationArgs {
50 std::string link_down;
53 class LinkCreationArgs {
56 std::vector<double> bandwidths;
57 profile::Profile* bandwidth_trace = nullptr;
59 profile::Profile* latency_trace = nullptr;
60 profile::Profile* state_trace = nullptr;
61 s4u::Link::SharingPolicy policy = s4u::Link::SharingPolicy::FATPIPE;
62 std::unordered_map<std::string, std::string> properties;
65 class PeerCreationArgs {
72 profile::Profile* speed_trace;
73 profile::Profile* state_trace;
76 class RouteCreationArgs {
78 bool symmetrical = false;
79 NetPoint* src = nullptr;
80 NetPoint* dst = nullptr;
81 NetPoint* gw_src = nullptr;
82 NetPoint* gw_dst = nullptr;
83 std::vector<resource::LinkImpl*> link_list;
86 enum class ClusterTopology { DRAGONFLY = 3, FAT_TREE = 2, FLAT = 1, TORUS = 0 };
88 class ClusterCreationArgs {
93 std::vector<int> radicals;
94 std::vector<double> speeds;
100 double loopback_bw = 0;
101 double loopback_lat = 0;
102 double limiter_link = 0;
103 ClusterTopology topology = ClusterTopology::FLAT;
104 std::string topo_parameters;
105 std::unordered_map<std::string, std::string> properties;
106 std::string router_id;
107 s4u::Link::SharingPolicy sharing_policy = s4u::Link::SharingPolicy::SPLITDUPLEX;
108 s4u::Link::SharingPolicy bb_sharing_policy = s4u::Link::SharingPolicy::SHARED;
111 class CabinetCreationArgs {
116 std::vector<int> radicals;
122 class ClusterZoneCreationArgs {
125 std::vector<HostLinkCreationArgs> host_links;
126 std::vector<CabinetCreationArgs> cabinets;
127 std::unique_ptr<LinkCreationArgs> backbone;
130 class DiskCreationArgs {
133 std::unordered_map<std::string, std::string> properties;
138 class ProfileCreationArgs {
146 enum class TraceConnectKind { HOST_AVAIL, SPEED, LINK_AVAIL, BANDWIDTH, LATENCY };
148 class TraceConnectCreationArgs {
150 TraceConnectKind kind;
155 class ActorCreationArgs {
157 std::vector<std::string> args;
158 std::unordered_map<std::string, std::string> properties;
159 const char* host = nullptr;
160 const char* function = nullptr;
161 double start_time = 0.0;
162 double kill_time = 0.0;
163 bool restart_on_failure = false;
166 class ZoneCreationArgs {
172 extern XBT_PRIVATE xbt::signal<void(ClusterCreationArgs const&)> on_cluster_creation;
174 } // namespace routing
175 } // namespace kernel
176 } // namespace simgrid
178 /********** Routing **********/
179 void routing_cluster_add_backbone(std::unique_ptr<simgrid::kernel::routing::LinkCreationArgs> link);
180 /*** END of the parsing cruft ***/
182 XBT_PUBLIC simgrid::kernel::routing::NetZoneImpl*
183 sg_platf_new_Zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone); // Begin description of new Zone
184 XBT_PUBLIC void sg_platf_new_Zone_set_properties(const std::unordered_map<std::string, std::string>& props);
185 XBT_PUBLIC void sg_platf_new_Zone_seal(); // That Zone is fully described
188 sg_platf_new_host_begin(const simgrid::kernel::routing::HostCreationArgs* host); // Add a host to the current Zone
189 XBT_PUBLIC void sg_platf_new_host_set_properties(const std::unordered_map<std::string, std::string>& props);
190 XBT_PUBLIC void sg_platf_new_host_seal(int pstate); // That Host is fully described
193 sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone
195 sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone
197 sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host
199 sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer); // Add a peer to the current Zone
200 XBT_PUBLIC void sg_platf_new_tag_cluster(
201 simgrid::kernel::routing::ClusterCreationArgs* clust); // Add a regular cluster to the current Zone
202 XBT_PUBLIC simgrid::kernel::routing::NetPoint* // Add a router to the current Zone
203 sg_platf_new_router(const std::string&, const std::string& coords);
205 sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone
206 XBT_PUBLIC void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route); // Add a route
207 XBT_PUBLIC void sg_platf_new_bypassRoute(simgrid::kernel::routing::RouteCreationArgs* bypassroute); // Add a bypassRoute
209 XBT_PUBLIC void sg_platf_new_trace(simgrid::kernel::routing::ProfileCreationArgs* trace);
212 XBT_PUBLIC void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor);
213 XBT_PRIVATE void sg_platf_trace_connect(simgrid::kernel::routing::TraceConnectCreationArgs* trace_connect);
215 /* Prototypes of the functions offered by flex */
216 XBT_PUBLIC int surf_parse_lex();
217 XBT_PUBLIC int surf_parse_get_lineno();
218 XBT_PUBLIC FILE* surf_parse_get_in();
219 XBT_PUBLIC FILE* surf_parse_get_out();
220 XBT_PUBLIC int surf_parse_get_leng();
221 XBT_PUBLIC char* surf_parse_get_text();
222 XBT_PUBLIC void surf_parse_set_lineno(int line_number);
223 XBT_PUBLIC void surf_parse_set_in(FILE* in_str);
224 XBT_PUBLIC void surf_parse_set_out(FILE* out_str);
225 XBT_PUBLIC int surf_parse_get_debug();
226 XBT_PUBLIC void surf_parse_set_debug(int bdebug);
227 XBT_PUBLIC int surf_parse_lex_destroy();
229 #endif /* SG_PLATF_H */