Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Respect member order according to the initialisation order
[simgrid.git] / src / kernel / xml / platf_private.hpp
1 /* platf_private.h - Interface to the SimGrid platforms which visibility should be limited to this directory */
2
3 /* Copyright (c) 2004-2023. The SimGrid Team. All rights reserved.          */
4
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. */
7
8 #ifndef SG_PLATF_H
9 #define SG_PLATF_H
10
11 #include "simgrid/host.h"
12 #include "simgrid/s4u/Link.hpp"
13 #include "src/kernel/xml/simgrid_dtd.h"
14
15 #include <map>
16 #include <memory>
17 #include <string>
18 #include <vector>
19
20 extern XBT_PRIVATE std::unordered_map<std::string, simgrid::kernel::profile::Profile*> traces_set_list;
21
22 namespace simgrid::kernel::routing {
23 /* ***************************************** */
24 /*
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.
29  *
30  * It shouldn't be too costly at runtime, provided that structures living on the stack are
31  * used, instead of malloced structures.
32  */
33
34 class HostCreationArgs {
35 public:
36   std::string id;
37   std::vector<double> speed_per_pstate;
38   int pstate               = 0;
39   int core_amount          = 0;
40   profile::Profile* speed_trace                            = nullptr;
41   profile::Profile* state_trace                            = nullptr;
42   std::string coord                                        = "";
43 };
44
45 class HostLinkCreationArgs {
46 public:
47   std::string id;
48   std::string link_up;
49   std::string link_down;
50 };
51
52 class LinkCreationArgs {
53 public:
54   std::string id;
55   std::vector<double> bandwidths;
56   profile::Profile* bandwidth_trace                        = nullptr;
57   double latency                                           = 0;
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;
62 };
63
64 class PeerCreationArgs {
65 public:
66   std::string id;
67   double speed;
68   double bw_in;
69   double bw_out;
70   std::string coord;
71   profile::Profile* speed_trace;
72   profile::Profile* state_trace;
73 };
74
75 class RouteCreationArgs {
76 public:
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;
83 };
84
85 enum class ClusterTopology { DRAGONFLY = 3, FAT_TREE = 2, FLAT = 1, TORUS = 0 };
86
87 class ClusterCreationArgs {
88 public:
89   std::string id;
90   std::string prefix;
91   std::string suffix;
92   std::vector<int> radicals;
93   std::vector<double> speeds;
94   int core_amount     = 0;
95   double bw           = 0;
96   double lat          = 0;
97   double bb_bw        = 0;
98   double bb_lat       = 0;
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;
108 };
109
110 class CabinetCreationArgs {
111 public:
112   std::string id;
113   std::string prefix;
114   std::string suffix;
115   std::vector<int> radicals;
116   double speed;
117   double bw;
118   double lat;
119 };
120
121 class ClusterZoneCreationArgs {
122 public:
123   std::string routing;
124   std::vector<HostLinkCreationArgs> host_links;
125   std::vector<CabinetCreationArgs> cabinets;
126   std::unique_ptr<LinkCreationArgs> backbone;
127 };
128
129 class DiskCreationArgs {
130 public:
131   std::string id;
132   std::unordered_map<std::string, std::string> properties;
133   double read_bw;
134   double write_bw;
135 };
136
137 class ProfileCreationArgs {
138 public:
139   std::string id;
140   std::string file;
141   double periodicity;
142   std::string pc_data;
143 };
144
145 enum class TraceConnectKind { HOST_AVAIL, SPEED, LINK_AVAIL, BANDWIDTH, LATENCY };
146
147 class TraceConnectCreationArgs {
148 public:
149   TraceConnectKind kind;
150   std::string trace;
151   std::string element;
152 };
153
154 class ActorCreationArgs {
155 public:
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;
163 };
164
165 class ZoneCreationArgs {
166 public:
167   std::string id;
168   std::string routing;
169 };
170
171 extern XBT_PRIVATE xbt::signal<void(ClusterCreationArgs const&)> on_cluster_creation;
172
173 } // namespace simgrid::kernel::routing
174
175 /********** Routing **********/
176 void routing_cluster_add_backbone(std::unique_ptr<simgrid::kernel::routing::LinkCreationArgs> link);
177 /*** END of the parsing cruft ***/
178
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
183
184 XBT_PUBLIC void
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
188
189 XBT_PUBLIC void
190 sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone
191 XBT_PUBLIC void
192 sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone
193 XBT_PUBLIC void
194 sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host
195 XBT_PUBLIC void
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);
201 XBT_PUBLIC void
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
205
206 XBT_PUBLIC void sg_platf_new_trace(const simgrid::kernel::routing::ProfileCreationArgs* trace);
207
208 XBT_PUBLIC void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor);
209
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();
223
224 #endif                          /* SG_PLATF_H */