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/simgrid_dtd.h"
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 routing
174 } // namespace kernel
175 } // namespace simgrid
177 /********** Routing **********/
178 void routing_cluster_add_backbone(std::unique_ptr<simgrid::kernel::routing::LinkCreationArgs> link);
179 /*** END of the parsing cruft ***/
181 XBT_PUBLIC simgrid::kernel::routing::NetZoneImpl*
182 sg_platf_new_zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone); // Begin description of new Zone
183 XBT_PUBLIC void sg_platf_new_zone_set_properties(const std::unordered_map<std::string, std::string>& props);
184 XBT_PUBLIC void sg_platf_new_zone_seal(); // That Zone is fully described
187 sg_platf_new_host_begin(const simgrid::kernel::routing::HostCreationArgs* host); // Add a host to the current Zone
188 XBT_PUBLIC void sg_platf_new_host_set_properties(const std::unordered_map<std::string, std::string>& props);
189 XBT_PUBLIC void sg_platf_new_host_seal(int pstate); // That Host is fully described
192 sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone
194 sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone
196 sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host
198 sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer); // Add a peer to the current Zone
199 XBT_PUBLIC void sg_platf_new_tag_cluster(
200 simgrid::kernel::routing::ClusterCreationArgs* clust); // Add a regular cluster to the current Zone
201 XBT_PUBLIC simgrid::kernel::routing::NetPoint* // Add a router to the current Zone
202 sg_platf_new_router(const std::string&, const std::string& coords);
204 sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone
205 XBT_PUBLIC void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route); // Add a route
206 XBT_PUBLIC void sg_platf_new_bypass_route(simgrid::kernel::routing::RouteCreationArgs* route); // Add a bypass route
208 XBT_PUBLIC void sg_platf_new_trace(simgrid::kernel::routing::ProfileCreationArgs* trace);
211 XBT_PUBLIC void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor);
212 XBT_PRIVATE void sg_platf_trace_connect(simgrid::kernel::routing::TraceConnectCreationArgs* trace_connect);
214 /* Prototypes of the functions offered by flex */
215 XBT_PUBLIC int surf_parse_lex();
216 XBT_PUBLIC int surf_parse_get_lineno();
217 XBT_PUBLIC FILE* surf_parse_get_in();
218 XBT_PUBLIC FILE* surf_parse_get_out();
219 XBT_PUBLIC int surf_parse_get_leng();
220 XBT_PUBLIC char* surf_parse_get_text();
221 XBT_PUBLIC void surf_parse_set_lineno(int line_number);
222 XBT_PUBLIC void surf_parse_set_in(FILE* in_str);
223 XBT_PUBLIC void surf_parse_set_out(FILE* out_str);
224 XBT_PUBLIC int surf_parse_get_debug();
225 XBT_PUBLIC void surf_parse_set_debug(int bdebug);
226 XBT_PUBLIC int surf_parse_lex_destroy();
228 #endif /* SG_PLATF_H */