Logo AND Algorithmique Numérique Distribuée

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