Logo AND Algorithmique Numérique Distribuée

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