Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use enum class for trace connect kind
[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-2017. 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 extern "C" {
19 #include "src/surf/xml/simgrid_dtd.h"
20
21 #ifndef YY_TYPEDEF_YY_SIZE_T
22 #define YY_TYPEDEF_YY_SIZE_T
23 typedef size_t yy_size_t;
24 #endif
25
26 enum e_surf_cluster_topology_t {
27   SURF_CLUSTER_DRAGONFLY = 3,
28   SURF_CLUSTER_FAT_TREE  = 2,
29   SURF_CLUSTER_FLAT      = 1,
30   SURF_CLUSTER_TORUS     = 0
31 };
32
33 /* ***************************************** */
34 /*
35  * Platform creation functions. Instead of passing 123 arguments to the creation functions
36  * (one for each possible XML attribute), we pass structures containing them all. It removes the
37  * chances of switching arguments by error, and reduce the burden when we add a new attribute:
38  * old models can just continue to ignore it without having to update their headers.
39  *
40  * It shouldn't be too costly at runtime, provided that structures living on the stack are
41  * used, instead of malloced structures.
42  */
43
44 struct s_sg_platf_host_cbarg_t {
45   const char* id = nullptr;
46   std::vector<double> speed_per_pstate;
47   int pstate               = 0;
48   int core_amount          = 0;
49   tmgr_trace_t speed_trace = nullptr;
50   tmgr_trace_t state_trace = nullptr;
51   const char* coord        = nullptr;
52   std::map<std::string, std::string>* properties = nullptr;
53 };
54 typedef s_sg_platf_host_cbarg_t* sg_platf_host_cbarg_t;
55
56 class HostLinkCreationArgs {
57 public:
58   std::string id;
59   std::string link_up;
60   std::string link_down;
61 };
62
63 class LinkCreationArgs {
64 public:
65   std::string id;
66   double bandwidth                    = 0;
67   tmgr_trace_t bandwidth_trace        = nullptr;
68   double latency                      = 0;
69   tmgr_trace_t latency_trace          = nullptr;
70   tmgr_trace_t state_trace            = nullptr;
71   e_surf_link_sharing_policy_t policy = SURF_LINK_FATPIPE;
72   std::map<std::string, std::string>* properties = nullptr;
73 };
74
75 class PeerCreationArgs {
76 public:
77   std::string id;
78   double speed;
79   double bw_in;
80   double bw_out;
81   std::string coord;
82   tmgr_trace_t speed_trace;
83   tmgr_trace_t state_trace;
84 };
85
86 struct s_sg_platf_route_cbarg_t {
87   bool symmetrical     = false;
88   sg_netpoint_t src    = nullptr;
89   sg_netpoint_t dst    = nullptr;
90   sg_netpoint_t gw_src = nullptr;
91   sg_netpoint_t gw_dst = nullptr;
92   std::vector<simgrid::surf::LinkImpl*> link_list;
93 };
94 typedef s_sg_platf_route_cbarg_t* sg_platf_route_cbarg_t;
95
96 class ClusterCreationArgs {
97 public:
98   std::string id;
99   std::string prefix;
100   std::string suffix;
101   std::vector<int>* radicals = nullptr;
102   std::vector<double> speeds;
103   int core_amount     = 0;
104   double bw           = 0;
105   double lat          = 0;
106   double bb_bw        = 0;
107   double bb_lat       = 0;
108   double loopback_bw  = 0;
109   double loopback_lat = 0;
110   double limiter_link = 0;
111   e_surf_cluster_topology_t topology;
112   std::string topo_parameters;
113   std::map<std::string, std::string>* properties;
114   std::string router_id;
115   e_surf_link_sharing_policy_t sharing_policy;
116   e_surf_link_sharing_policy_t bb_sharing_policy;
117 };
118
119 class CabinetCreationArgs {
120 public:
121   std::string id;
122   std::string prefix;
123   std::string suffix;
124   std::vector<int>* radicals;
125   double speed;
126   double bw;
127   double lat;
128 };
129
130 class StorageCreationArgs {
131 public:
132   std::string id;
133   std::string type_id;
134   std::string content;
135   std::map<std::string, std::string>* properties;
136   std::string attach;
137 };
138
139 class StorageTypeCreationArgs {
140 public:
141   std::string id;
142   std::string model;
143   std::string content;
144   std::map<std::string, std::string>* properties;
145   std::map<std::string, std::string>* model_properties;
146   sg_size_t size;
147 };
148
149 class MountCreationArgs {
150 public:
151   std::string storageId;
152   std::string name;
153 };
154
155 struct s_sg_platf_prop_cbarg_t {
156   const char *id;
157   const char *value;
158 };
159 typedef s_sg_platf_prop_cbarg_t* sg_platf_prop_cbarg_t;
160
161 class TraceCreationArgs {
162 public:
163   std::string id;
164   std::string file;
165   double periodicity;
166   std::string pc_data;
167 };
168
169 enum class TraceConnectKind { HOST_AVAIL, SPEED, LINK_AVAIL, BANDWIDTH, LATENCY };
170
171 class TraceConnectCreationArgs {
172 public:
173   TraceConnectKind kind;
174   std::string trace;
175   std::string element;
176 };
177
178 struct s_sg_platf_process_cbarg_t {
179   std::vector<std::string> args;
180   std::map<std::string, std::string>* properties = nullptr;
181   const char* host                       = nullptr;
182   const char* function                   = nullptr;
183   double start_time                      = 0.0;
184   double kill_time                       = 0.0;
185   e_surf_process_on_failure_t on_failure = {};
186 };
187 typedef s_sg_platf_process_cbarg_t* sg_platf_process_cbarg_t;
188
189 class ZoneCreationArgs {
190 public:
191   std::string id;
192   int routing;
193 };
194
195 /********** Routing **********/
196 void routing_cluster_add_backbone(simgrid::surf::LinkImpl* bb);
197 /*** END of the parsing cruft ***/
198
199 XBT_PUBLIC(void) sg_platf_begin();  // Start a new platform
200 XBT_PUBLIC(void) sg_platf_end(); // Finish the creation of the platform
201
202 XBT_PUBLIC(simgrid::s4u::NetZone*) sg_platf_new_Zone_begin(ZoneCreationArgs* zone); // Begin description of new Zone
203 XBT_PUBLIC(void) sg_platf_new_Zone_seal();                                          // That Zone is fully described
204
205 XBT_PUBLIC(void) sg_platf_new_host(sg_platf_host_cbarg_t host);        // Add a host      to the current Zone
206 XBT_PUBLIC(void) sg_platf_new_hostlink(HostLinkCreationArgs* h);       // Add a host_link to the current Zone
207 XBT_PUBLIC(void) sg_platf_new_link(LinkCreationArgs* link);            // Add a link      to the current Zone
208 XBT_PUBLIC(void) sg_platf_new_peer(PeerCreationArgs* peer);            // Add a peer      to the current Zone
209 XBT_PUBLIC(void) sg_platf_new_cluster(ClusterCreationArgs* clust);     // Add a cluster   to the current Zone
210 XBT_PUBLIC(void) sg_platf_new_cabinet(CabinetCreationArgs* cabinet);   // Add a cabinet   to the current Zone
211 XBT_PUBLIC(simgrid::kernel::routing::NetPoint*)                        // Add a router    to the current Zone
212 sg_platf_new_router(std::string, const char* coords);
213
214 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
215 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
216
217 XBT_PUBLIC(void) sg_platf_new_trace(TraceCreationArgs* trace);
218
219 XBT_PUBLIC(void) sg_platf_new_storage(StorageCreationArgs* storage); // Add a storage to the current Zone
220 XBT_PUBLIC(void) sg_platf_new_storage_type(StorageTypeCreationArgs* storage_type);
221 XBT_PUBLIC(void) sg_platf_new_mount(MountCreationArgs* mount);
222
223 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
224 XBT_PRIVATE void sg_platf_trace_connect(TraceConnectCreationArgs* trace_connect);
225
226 /* Prototypes of the functions offered by flex */
227 XBT_PUBLIC(int) surf_parse_lex();
228 XBT_PUBLIC(int) surf_parse_get_lineno();
229 XBT_PUBLIC(FILE *) surf_parse_get_in();
230 XBT_PUBLIC(FILE *) surf_parse_get_out();
231 XBT_PUBLIC(int) surf_parse_get_leng();
232 XBT_PUBLIC(char *) surf_parse_get_text();
233 XBT_PUBLIC(void) surf_parse_set_lineno(int line_number);
234 XBT_PUBLIC(void) surf_parse_set_in(FILE * in_str);
235 XBT_PUBLIC(void) surf_parse_set_out(FILE * out_str);
236 XBT_PUBLIC(int) surf_parse_get_debug();
237 XBT_PUBLIC(void) surf_parse_set_debug(int bdebug);
238 XBT_PUBLIC(int) surf_parse_lex_destroy();
239 }
240
241 namespace simgrid {
242 namespace surf {
243
244 extern XBT_PRIVATE simgrid::xbt::signal<void(ClusterCreationArgs*)> on_cluster;
245 }
246 }
247
248 #endif                          /* SG_PLATF_H */