1 /* platf_private.h - Interface to the SimGrid platforms which visibility should be limited to this directory */
3 /* Copyright (c) 2004-2018. The SimGrid Team.
4 * All rights reserved. */
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. */
12 #include "simgrid/host.h"
13 #include "src/surf/xml/platf.hpp"
14 #include "src/surf/xml/simgrid_dtd.h"
22 /* ***************************************** */
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.
29 * It shouldn't be too costly at runtime, provided that structures living on the stack are
30 * used, instead of malloced structures.
33 struct HostCreationArgs {
34 const char* id = nullptr;
35 std::vector<double> speed_per_pstate;
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;
44 class HostLinkCreationArgs {
48 std::string link_down;
51 class LinkCreationArgs {
55 tmgr_trace_t bandwidth_trace = nullptr;
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;
63 class PeerCreationArgs {
70 tmgr_trace_t speed_trace;
71 tmgr_trace_t state_trace;
74 class RouteCreationArgs {
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;
84 enum class ClusterTopology { DRAGONFLY = 3, FAT_TREE = 2, FLAT = 1, TORUS = 0 };
86 class ClusterCreationArgs {
91 std::vector<int>* radicals = nullptr;
92 std::vector<double> speeds;
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;
109 class CabinetCreationArgs {
114 std::vector<int>* radicals;
120 class StorageCreationArgs {
125 std::map<std::string, std::string>* properties;
129 class StorageTypeCreationArgs {
134 std::map<std::string, std::string>* properties;
135 std::map<std::string, std::string>* model_properties;
139 class MountCreationArgs {
141 std::string storageId;
145 class TraceCreationArgs {
153 enum class TraceConnectKind { HOST_AVAIL, SPEED, LINK_AVAIL, BANDWIDTH, LATENCY };
155 class TraceConnectCreationArgs {
157 TraceConnectKind kind;
162 enum class ActorOnFailure { DIE, RESTART }; // FIXME: move to a better namespace
164 class ActorCreationArgs {
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;
175 class ZoneCreationArgs {
184 /********** Routing **********/
185 void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb);
186 /*** END of the parsing cruft ***/
188 XBT_PUBLIC void sg_platf_begin(); // Start a new platform
189 XBT_PUBLIC void sg_platf_end(); // Finish the creation of the platform
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
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);
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
206 XBT_PUBLIC void sg_platf_new_trace(simgrid::kernel::routing::TraceCreationArgs* trace);
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);
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);
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();
233 extern XBT_PRIVATE simgrid::xbt::signal<void(kernel::routing::ClusterCreationArgs*)> on_cluster;
237 #endif /* SG_PLATF_H */