Logo AND Algorithmique Numérique Distribuée

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