Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Concatenate nested namespaces (sonar).
[simgrid.git] / src / surf / 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-2022. The SimGrid Team.
4  * All rights reserved.                                                     */
5
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. */
8
9 #ifndef SG_PLATF_H
10 #define SG_PLATF_H
11
12 #include "simgrid/host.h"
13 #include "simgrid/s4u/Link.hpp"
14 #include "src/surf/xml/simgrid_dtd.h"
15
16 #include <map>
17 #include <string>
18 #include <vector>
19
20 namespace simgrid::kernel::routing {
21 /* ***************************************** */
22 /*
23  * Platform creation functions. Instead of passing 123 arguments to the creation functions
24  * (one for each possible XML attribute), we pass structures containing them all. It removes the
25  * chances of switching arguments by error, and reduce the burden when we add a new attribute:
26  * old models can just continue to ignore it without having to update their headers.
27  *
28  * It shouldn't be too costly at runtime, provided that structures living on the stack are
29  * used, instead of malloced structures.
30  */
31
32 class HostCreationArgs {
33 public:
34   std::string id;
35   std::vector<double> speed_per_pstate;
36   int pstate               = 0;
37   int core_amount          = 0;
38   profile::Profile* speed_trace                            = nullptr;
39   profile::Profile* state_trace                            = nullptr;
40   std::string coord                                        = "";
41 };
42
43 class HostLinkCreationArgs {
44 public:
45   std::string id;
46   std::string link_up;
47   std::string link_down;
48 };
49
50 class LinkCreationArgs {
51 public:
52   std::string id;
53   std::vector<double> bandwidths;
54   profile::Profile* bandwidth_trace                        = nullptr;
55   double latency                                           = 0;
56   profile::Profile* latency_trace                          = nullptr;
57   profile::Profile* state_trace                            = nullptr;
58   s4u::Link::SharingPolicy policy                          = s4u::Link::SharingPolicy::FATPIPE;
59   std::unordered_map<std::string, std::string> properties;
60 };
61
62 class PeerCreationArgs {
63 public:
64   std::string id;
65   double speed;
66   double bw_in;
67   double bw_out;
68   std::string coord;
69   profile::Profile* speed_trace;
70   profile::Profile* state_trace;
71 };
72
73 class RouteCreationArgs {
74 public:
75   bool symmetrical = false;
76   NetPoint* src    = nullptr;
77   NetPoint* dst    = nullptr;
78   NetPoint* gw_src = nullptr;
79   NetPoint* gw_dst = nullptr;
80   std::vector<simgrid::s4u::LinkInRoute> link_list;
81 };
82
83 enum class ClusterTopology { DRAGONFLY = 3, FAT_TREE = 2, FLAT = 1, TORUS = 0 };
84
85 class ClusterCreationArgs {
86 public:
87   std::string id;
88   std::string prefix;
89   std::string suffix;
90   std::vector<int> radicals;
91   std::vector<double> speeds;
92   int core_amount     = 0;
93   double bw           = 0;
94   double lat          = 0;
95   double bb_bw        = 0;
96   double bb_lat       = 0;
97   double loopback_bw  = 0;
98   double loopback_lat = 0;
99   double limiter_link = 0;
100   ClusterTopology topology = ClusterTopology::FLAT;
101   std::string topo_parameters;
102   std::unordered_map<std::string, std::string> properties;
103   std::string router_id;
104   s4u::Link::SharingPolicy sharing_policy    = s4u::Link::SharingPolicy::SPLITDUPLEX;
105   s4u::Link::SharingPolicy bb_sharing_policy = s4u::Link::SharingPolicy::SHARED;
106 };
107
108 class CabinetCreationArgs {
109 public:
110   std::string id;
111   std::string prefix;
112   std::string suffix;
113   std::vector<int> radicals;
114   double speed;
115   double bw;
116   double lat;
117 };
118
119 class ClusterZoneCreationArgs {
120 public:
121   std::string routing;
122   std::vector<HostLinkCreationArgs> host_links;
123   std::vector<CabinetCreationArgs> cabinets;
124   std::unique_ptr<LinkCreationArgs> backbone;
125 };
126
127 class DiskCreationArgs {
128 public:
129   std::string id;
130   std::unordered_map<std::string, std::string> properties;
131   double read_bw;
132   double write_bw;
133 };
134
135 class ProfileCreationArgs {
136 public:
137   std::string id;
138   std::string file;
139   double periodicity;
140   std::string pc_data;
141 };
142
143 enum class TraceConnectKind { HOST_AVAIL, SPEED, LINK_AVAIL, BANDWIDTH, LATENCY };
144
145 class TraceConnectCreationArgs {
146 public:
147   TraceConnectKind kind;
148   std::string trace;
149   std::string element;
150 };
151
152 class ActorCreationArgs {
153 public:
154   std::vector<std::string> args;
155   std::unordered_map<std::string, std::string> properties;
156   const char* host                       = nullptr;
157   const char* function                   = nullptr;
158   double start_time                      = 0.0;
159   double kill_time                       = 0.0;
160   bool restart_on_failure                                  = false;
161 };
162
163 class ZoneCreationArgs {
164 public:
165   std::string id;
166   std::string routing;
167 };
168
169 extern XBT_PRIVATE xbt::signal<void(ClusterCreationArgs const&)> on_cluster_creation;
170
171 } // namespace simgrid::kernel::routing
172
173 /********** Routing **********/
174 void routing_cluster_add_backbone(std::unique_ptr<simgrid::kernel::routing::LinkCreationArgs> link);
175 /*** END of the parsing cruft ***/
176
177 XBT_PUBLIC simgrid::kernel::routing::NetZoneImpl*
178 sg_platf_new_zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone); // Begin description of new Zone
179 XBT_PUBLIC void sg_platf_new_zone_set_properties(const std::unordered_map<std::string, std::string>& props);
180 XBT_PUBLIC void sg_platf_new_zone_seal(); // That Zone is fully described
181
182 XBT_PUBLIC void
183 sg_platf_new_host_begin(const simgrid::kernel::routing::HostCreationArgs* host); // Add a host to the current Zone
184 XBT_PUBLIC void sg_platf_new_host_set_properties(const std::unordered_map<std::string, std::string>& props);
185 XBT_PUBLIC void sg_platf_new_host_seal(int pstate); // That Host is fully described
186
187 XBT_PUBLIC void
188 sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone
189 XBT_PUBLIC void
190 sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone
191 XBT_PUBLIC void
192 sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host
193 XBT_PUBLIC void
194 sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer); // Add a peer to the current Zone
195 XBT_PUBLIC void sg_platf_new_tag_cluster(
196     simgrid::kernel::routing::ClusterCreationArgs* clust); // Add a regular cluster  to the current Zone
197 XBT_PUBLIC simgrid::kernel::routing::NetPoint*                                      // Add a router to the current Zone
198 sg_platf_new_router(const std::string&, const std::string& coords);
199 XBT_PUBLIC void
200 sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone
201 XBT_PUBLIC void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route);             // Add a route
202 XBT_PUBLIC void sg_platf_new_bypass_route(simgrid::kernel::routing::RouteCreationArgs* route); // Add a bypass route
203
204 XBT_PUBLIC void sg_platf_new_trace(const simgrid::kernel::routing::ProfileCreationArgs* trace);
205
206 XBT_PUBLIC void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor);
207 XBT_PRIVATE void sg_platf_trace_connect(simgrid::kernel::routing::TraceConnectCreationArgs* trace_connect);
208
209 /* Prototypes of the functions offered by flex */
210 XBT_PUBLIC int surf_parse_lex();
211 XBT_PUBLIC int surf_parse_get_lineno();
212 XBT_PUBLIC FILE* surf_parse_get_in();
213 XBT_PUBLIC FILE* surf_parse_get_out();
214 XBT_PUBLIC int surf_parse_get_leng();
215 XBT_PUBLIC char* surf_parse_get_text();
216 XBT_PUBLIC void surf_parse_set_lineno(int line_number);
217 XBT_PUBLIC void surf_parse_set_in(FILE* in_str);
218 XBT_PUBLIC void surf_parse_set_out(FILE* out_str);
219 XBT_PUBLIC int surf_parse_get_debug();
220 XBT_PUBLIC void surf_parse_set_debug(int bdebug);
221 XBT_PUBLIC int surf_parse_lex_destroy();
222
223 #endif                          /* SG_PLATF_H */