Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[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-2021. 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/platf.hpp"
15 #include "src/surf/xml/simgrid_dtd.h"
16
17 #include <map>
18 #include <string>
19 #include <vector>
20
21 namespace simgrid {
22 namespace kernel {
23 namespace routing {
24 /* ***************************************** */
25 /*
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.
30  *
31  * It shouldn't be too costly at runtime, provided that structures living on the stack are
32  * used, instead of malloced structures.
33  */
34
35 class HostCreationArgs {
36 public:
37   std::string id;
38   std::vector<double> speed_per_pstate;
39   int pstate               = 0;
40   int core_amount          = 0;
41   profile::Profile* speed_trace                            = nullptr;
42   profile::Profile* state_trace                            = nullptr;
43   std::string coord                                        = "";
44   std::unordered_map<std::string, std::string>* properties = nullptr;
45   std::vector<simgrid::kernel::resource::DiskImpl*> disks;
46 };
47
48 class HostLinkCreationArgs {
49 public:
50   std::string id;
51   std::string link_up;
52   std::string link_down;
53 };
54
55 class LinkCreationArgs {
56 public:
57   std::string id;
58   std::vector<double> bandwidths;
59   profile::Profile* bandwidth_trace                        = nullptr;
60   double latency                      = 0;
61   profile::Profile* latency_trace                          = nullptr;
62   profile::Profile* state_trace                            = nullptr;
63   simgrid::s4u::Link::SharingPolicy policy       = simgrid::s4u::Link::SharingPolicy::FATPIPE;
64   std::unordered_map<std::string, std::string>* properties = nullptr;
65 };
66
67 class PeerCreationArgs {
68 public:
69   std::string id;
70   double speed;
71   double bw_in;
72   double bw_out;
73   std::string coord;
74   profile::Profile* speed_trace;
75   profile::Profile* state_trace;
76 };
77
78 class RouteCreationArgs {
79 public:
80   bool symmetrical = false;
81   NetPoint* src    = nullptr;
82   NetPoint* dst    = nullptr;
83   NetPoint* gw_src = nullptr;
84   NetPoint* gw_dst = nullptr;
85   std::vector<simgrid::kernel::resource::LinkImpl*> link_list;
86 };
87
88 enum class ClusterTopology { DRAGONFLY = 3, FAT_TREE = 2, FLAT = 1, TORUS = 0 };
89
90 class ClusterCreationArgs {
91 public:
92   std::string id;
93   std::string prefix;
94   std::string suffix;
95   std::vector<int>* radicals = nullptr;
96   std::vector<double> speeds;
97   int core_amount     = 0;
98   double bw           = 0;
99   double lat          = 0;
100   double bb_bw        = 0;
101   double bb_lat       = 0;
102   double loopback_bw  = 0;
103   double loopback_lat = 0;
104   double limiter_link = 0;
105   ClusterTopology topology = ClusterTopology::FLAT;
106   std::string topo_parameters;
107   std::unordered_map<std::string, std::string>* properties = nullptr;
108   std::string router_id;
109   simgrid::s4u::Link::SharingPolicy sharing_policy    = simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX;
110   simgrid::s4u::Link::SharingPolicy bb_sharing_policy = simgrid::s4u::Link::SharingPolicy::SHARED;
111 };
112
113 class CabinetCreationArgs {
114 public:
115   std::string id;
116   std::string prefix;
117   std::string suffix;
118   std::vector<int>* radicals;
119   double speed;
120   double bw;
121   double lat;
122 };
123
124 class StorageCreationArgs {
125 public:
126   std::string filename;
127   int lineno;
128   std::string id;
129   std::string type_id;
130   std::string content;
131   std::unordered_map<std::string, std::string>* properties;
132   std::string attach;
133 };
134
135 class StorageTypeCreationArgs {
136 public:
137   std::string id;
138   std::string model;
139   std::string content;
140   std::unordered_map<std::string, std::string>* properties;
141   std::unordered_map<std::string, std::string>* model_properties;
142   sg_size_t size;
143 };
144
145 class DiskCreationArgs {
146 public:
147   std::string id;
148   std::unordered_map<std::string, std::string>* properties;
149   double read_bw;
150   double write_bw;
151 };
152
153 class MountCreationArgs {
154 public:
155   std::string storageId;
156   std::string name;
157 };
158
159 class ProfileCreationArgs {
160 public:
161   std::string id;
162   std::string file;
163   double periodicity;
164   std::string pc_data;
165 };
166
167 enum class TraceConnectKind { HOST_AVAIL, SPEED, LINK_AVAIL, BANDWIDTH, LATENCY };
168
169 class TraceConnectCreationArgs {
170 public:
171   TraceConnectKind kind;
172   std::string trace;
173   std::string element;
174 };
175
176 class ActorCreationArgs {
177 public:
178   std::vector<std::string> args;
179   std::unordered_map<std::string, std::string>* properties = nullptr;
180   const char* host                       = nullptr;
181   const char* function                   = nullptr;
182   double start_time                      = 0.0;
183   double kill_time                       = 0.0;
184   bool restart_on_failure                                  = false;
185 };
186
187 class ZoneCreationArgs {
188 public:
189   std::string id;
190   std::string routing;
191 };
192
193 extern XBT_PRIVATE xbt::signal<void(ClusterCreationArgs const&)> on_cluster_creation;
194
195 } // namespace routing
196 } // namespace kernel
197 } // namespace simgrid
198
199 /********** Routing **********/
200 void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb);
201 /*** END of the parsing cruft ***/
202
203 XBT_PUBLIC simgrid::kernel::routing::NetZoneImpl*
204 sg_platf_new_Zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone); // Begin description of new Zone
205 XBT_PUBLIC void sg_platf_new_Zone_set_properties(const std::unordered_map<std::string, std::string>* props);
206 XBT_PUBLIC void sg_platf_new_Zone_seal();                                          // That Zone is fully described
207
208 XBT_PUBLIC void
209 sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* host); // Add a host to the current Zone
210 XBT_PUBLIC void
211 sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone
212 XBT_PUBLIC void
213 sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone
214 XBT_PUBLIC void
215 sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer); // Add a peer to the current Zone
216 XBT_PUBLIC void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* clust);   // Add a cluster   to the current Zone
217 XBT_PUBLIC void
218 sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone
219 XBT_PUBLIC simgrid::kernel::routing::NetPoint* // Add a router    to the current Zone
220     sg_platf_new_router(const std::string&, const char* coords);
221
222 XBT_PUBLIC void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route);             // Add a route
223 XBT_PUBLIC void sg_platf_new_bypassRoute(simgrid::kernel::routing::RouteCreationArgs* bypassroute); // Add a bypassRoute
224
225 XBT_PUBLIC void sg_platf_new_trace(simgrid::kernel::routing::ProfileCreationArgs* trace);
226
227 XBT_PUBLIC simgrid::kernel::resource::DiskImpl*
228 sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host
229
230 XBT_PUBLIC void sg_platf_new_storage(simgrid::kernel::routing::StorageCreationArgs* storage); // Add a storage to the current Zone
231 XBT_PUBLIC void sg_platf_new_storage_type(const simgrid::kernel::routing::StorageTypeCreationArgs* storage_type);
232 XBT_PUBLIC void sg_platf_new_mount(simgrid::kernel::routing::MountCreationArgs* mount);
233
234 XBT_PUBLIC void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor);
235 XBT_PRIVATE void sg_platf_trace_connect(simgrid::kernel::routing::TraceConnectCreationArgs* trace_connect);
236
237 /* Prototypes of the functions offered by flex */
238 XBT_PUBLIC int surf_parse_lex();
239 XBT_PUBLIC int surf_parse_get_lineno();
240 XBT_PUBLIC FILE* surf_parse_get_in();
241 XBT_PUBLIC FILE* surf_parse_get_out();
242 XBT_PUBLIC int surf_parse_get_leng();
243 XBT_PUBLIC char* surf_parse_get_text();
244 XBT_PUBLIC void surf_parse_set_lineno(int line_number);
245 XBT_PUBLIC void surf_parse_set_in(FILE* in_str);
246 XBT_PUBLIC void surf_parse_set_out(FILE* out_str);
247 XBT_PUBLIC int surf_parse_get_debug();
248 XBT_PUBLIC void surf_parse_set_debug(int bdebug);
249 XBT_PUBLIC int surf_parse_lex_destroy();
250
251 #endif                          /* SG_PLATF_H */