Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Revert "Please mingw."
[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-2018. 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 "src/surf/xml/platf.hpp"
14 #include <map>
15 #include <string>
16 #include <vector>
17
18 namespace simgrid {
19 namespace kernel {
20 namespace 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 struct HostCreationArgs {
33   const char* id = nullptr;
34   std::vector<double> speed_per_pstate;
35   int pstate               = 0;
36   int core_amount          = 0;
37   tmgr_trace_t speed_trace = nullptr;
38   tmgr_trace_t state_trace = nullptr;
39   const char* coord        = nullptr;
40   std::map<std::string, std::string>* properties = nullptr;
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   double bandwidth                    = 0;
54   tmgr_trace_t bandwidth_trace        = nullptr;
55   double latency                      = 0;
56   tmgr_trace_t latency_trace          = nullptr;
57   tmgr_trace_t state_trace            = nullptr;
58   e_surf_link_sharing_policy_t policy = SURF_LINK_FATPIPE;
59   std::map<std::string, std::string>* properties = nullptr;
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   tmgr_trace_t speed_trace;
70   tmgr_trace_t state_trace;
71 };
72
73 class RouteCreationArgs {
74 public:
75   bool symmetrical     = false;
76   sg_netpoint_t src    = nullptr;
77   sg_netpoint_t dst    = nullptr;
78   sg_netpoint_t gw_src = nullptr;
79   sg_netpoint_t gw_dst = nullptr;
80   std::vector<simgrid::surf::LinkImpl*> 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 = nullptr;
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;
101   std::string topo_parameters;
102   std::map<std::string, std::string>* properties;
103   std::string router_id;
104   e_surf_link_sharing_policy_t sharing_policy;
105   e_surf_link_sharing_policy_t bb_sharing_policy;
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 StorageCreationArgs {
120 public:
121   std::string id;
122   std::string type_id;
123   std::string content;
124   std::map<std::string, std::string>* properties;
125   std::string attach;
126 };
127
128 class StorageTypeCreationArgs {
129 public:
130   std::string id;
131   std::string model;
132   std::string content;
133   std::map<std::string, std::string>* properties;
134   std::map<std::string, std::string>* model_properties;
135   sg_size_t size;
136 };
137
138 class MountCreationArgs {
139 public:
140   std::string storageId;
141   std::string name;
142 };
143
144 class TraceCreationArgs {
145 public:
146   std::string id;
147   std::string file;
148   double periodicity;
149   std::string pc_data;
150 };
151
152 enum class TraceConnectKind { HOST_AVAIL, SPEED, LINK_AVAIL, BANDWIDTH, LATENCY };
153
154 class TraceConnectCreationArgs {
155 public:
156   TraceConnectKind kind;
157   std::string trace;
158   std::string element;
159 };
160
161 enum class ActorOnFailure { DIE, RESTART }; // FIXME: move to a better namespace
162
163 class ActorCreationArgs {
164 public:
165   std::vector<std::string> args;
166   std::map<std::string, std::string>* properties = nullptr;
167   const char* host                       = nullptr;
168   const char* function                   = nullptr;
169   double start_time                      = 0.0;
170   double kill_time                       = 0.0;
171   ActorOnFailure on_failure;
172 };
173
174 class ZoneCreationArgs {
175 public:
176   std::string id;
177   int routing;
178 };
179 }}}
180
181 extern "C" {
182 #include "src/surf/xml/simgrid_dtd.h"
183
184 #ifndef YY_TYPEDEF_YY_SIZE_T
185 #define YY_TYPEDEF_YY_SIZE_T
186 typedef size_t yy_size_t;
187 #endif
188
189 /********** Routing **********/
190 void routing_cluster_add_backbone(simgrid::surf::LinkImpl* bb);
191 /*** END of the parsing cruft ***/
192
193 XBT_PUBLIC void sg_platf_begin(); // Start a new platform
194 XBT_PUBLIC void sg_platf_end();   // Finish the creation of the platform
195
196 XBT_PUBLIC simgrid::s4u::NetZone* sg_platf_new_Zone_begin(simgrid::kernel::routing::ZoneCreationArgs* zone); // Begin description of new Zone
197 XBT_PUBLIC void sg_platf_new_Zone_seal();                                          // That Zone is fully described
198
199 XBT_PUBLIC void sg_platf_new_host(simgrid::kernel::routing::HostCreationArgs* host);      // Add a host      to the current Zone
200 XBT_PUBLIC void sg_platf_new_hostlink(simgrid::kernel::routing::HostLinkCreationArgs* h);     // Add a host_link to the current Zone
201 XBT_PUBLIC void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link);          // Add a link      to the current Zone
202 XBT_PUBLIC void sg_platf_new_peer(simgrid::kernel::routing::PeerCreationArgs* peer);          // Add a peer      to the current Zone
203 XBT_PUBLIC void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* clust);   // Add a cluster   to the current Zone
204 XBT_PUBLIC void sg_platf_new_cabinet(simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet   to the current Zone
205 XBT_PUBLIC simgrid::kernel::routing::NetPoint*                      // Add a router    to the current Zone
206     sg_platf_new_router(std::string, const char* coords);
207
208 XBT_PUBLIC void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route);             // Add a route
209 XBT_PUBLIC void sg_platf_new_bypassRoute(simgrid::kernel::routing::RouteCreationArgs* bypassroute); // Add a bypassRoute
210
211 XBT_PUBLIC void sg_platf_new_trace(simgrid::kernel::routing::TraceCreationArgs* trace);
212
213 XBT_PUBLIC void sg_platf_new_storage(simgrid::kernel::routing::StorageCreationArgs* storage); // Add a storage to the current Zone
214 XBT_PUBLIC void sg_platf_new_storage_type(simgrid::kernel::routing::StorageTypeCreationArgs* storage_type);
215 XBT_PUBLIC void sg_platf_new_mount(simgrid::kernel::routing::MountCreationArgs* mount);
216
217 XBT_PUBLIC void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor);
218 XBT_PRIVATE void sg_platf_trace_connect(simgrid::kernel::routing::TraceConnectCreationArgs* trace_connect);
219
220 /* Prototypes of the functions offered by flex */
221 XBT_PUBLIC int surf_parse_lex();
222 XBT_PUBLIC int surf_parse_get_lineno();
223 XBT_PUBLIC FILE* surf_parse_get_in();
224 XBT_PUBLIC FILE* surf_parse_get_out();
225 XBT_PUBLIC int surf_parse_get_leng();
226 XBT_PUBLIC char* surf_parse_get_text();
227 XBT_PUBLIC void surf_parse_set_lineno(int line_number);
228 XBT_PUBLIC void surf_parse_set_in(FILE* in_str);
229 XBT_PUBLIC void surf_parse_set_out(FILE* out_str);
230 XBT_PUBLIC int surf_parse_get_debug();
231 XBT_PUBLIC void surf_parse_set_debug(int bdebug);
232 XBT_PUBLIC int surf_parse_lex_destroy();
233 }
234
235 namespace simgrid {
236 namespace surf {
237
238 extern XBT_PRIVATE simgrid::xbt::signal<void(kernel::routing::ClusterCreationArgs*)> on_cluster;
239 }
240 }
241
242 #endif                          /* SG_PLATF_H */