Logo AND Algorithmique Numérique Distribuée

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