}
int console_add_backbone(lua_State *L) {
- simgrid::kernel::routing::LinkCreationArgs link;
+ auto link = std::make_unique<simgrid::kernel::routing::LinkCreationArgs>();
lua_Debug ar;
lua_getstack(L, 1, &ar);
lua_getinfo(L, "Sl", &ar);
lua_pushstring(L, "id");
int type = lua_gettable(L, -2);
lua_ensure(type == LUA_TSTRING, "Attribute 'id' must be specified for backbone and must be a string.");
- link.id = lua_tostring(L, -1);
+ link->id = lua_tostring(L, -1);
lua_pop(L, 1);
lua_pushstring(L, "bandwidth");
type = lua_gettable(L, -2);
lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER,
"Attribute 'bandwidth' must be specified for backbone and must either be a string (in the right format; see docs) or a number.");
- link.bandwidths.push_back(xbt_parse_get_bandwidth(ar.short_src, ar.currentline, lua_tostring(L, -1),
- "bandwidth of backbone", link.id.c_str()));
+ link->bandwidths.push_back(xbt_parse_get_bandwidth(ar.short_src, ar.currentline, lua_tostring(L, -1),
+ "bandwidth of backbone", link->id.c_str()));
lua_pop(L, 1);
lua_pushstring(L, "lat");
type = lua_gettable(L, -2);
lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER,
"Attribute 'lat' must be specified for backbone and must either be a string (in the right format; see docs) or a number.");
- link.latency =
- xbt_parse_get_time(ar.short_src, ar.currentline, lua_tostring(L, -1), "latency of backbone", link.id.c_str());
+ link->latency =
+ xbt_parse_get_time(ar.short_src, ar.currentline, lua_tostring(L, -1), "latency of backbone", link->id.c_str());
lua_pop(L, 1);
lua_pushstring(L, "sharing_policy");
lua_gettable(L, -2);
const char* policy = lua_tostring(L, -1);
lua_pop(L, 1);
- link.policy = link_policy_get_by_name(policy);
+ link->policy = link_policy_get_by_name(policy);
- sg_platf_new_link(&link);
- routing_cluster_add_backbone(simgrid::s4u::Link::by_name(link.id)->get_impl());
+ routing_cluster_add_backbone(std::move(link));
return 0;
}
} // namespace kernel
} // namespace simgrid
+simgrid::kernel::routing::ClusterZoneCreationArgs
+ zone_cluster; /* temporary store data for irregular clusters, created with <zone routing="Cluster"> */
+
/** The current NetZone in the parsing */
static simgrid::kernel::routing::NetZoneImpl* current_routing = nullptr;
static simgrid::kernel::routing::NetZoneImpl* routing_get_current()
}
/** @brief Add a link connecting a host to the rest of its StarZone */
-static void sg_platf_new_hostlink(simgrid::kernel::routing::StarZone* zone,
- const simgrid::kernel::routing::HostLinkCreationArgs* hostlink,
- simgrid::kernel::resource::LinkImpl* backbone)
+static void sg_platf_build_hostlink(simgrid::kernel::routing::StarZone* zone,
+ const simgrid::kernel::routing::HostLinkCreationArgs* hostlink,
+ simgrid::kernel::resource::LinkImpl* backbone)
{
simgrid::kernel::routing::NetPoint* netpoint = simgrid::s4u::Host::by_name(hostlink->id)->get_netpoint();
xbt_assert(netpoint, "Host '%s' not found!", hostlink->id.c_str());
}
/** @brief Create a cabinet (set of hosts) inside a Cluster(StarZone) */
-static void sg_platf_new_cabinet(simgrid::kernel::routing::StarZone* zone,
- const simgrid::kernel::routing::CabinetCreationArgs* args,
- simgrid::kernel::resource::LinkImpl* backbone)
+static void sg_platf_build_cabinet(simgrid::kernel::routing::StarZone* zone,
+ const simgrid::kernel::routing::CabinetCreationArgs* args,
+ simgrid::kernel::resource::LinkImpl* backbone)
{
for (int const& radical : args->radicals) {
std::string id = args->prefix + std::to_string(radical) + args->suffix;
/* create host_links for hosts */
for (auto const& hostlink : cluster->host_links) {
- sg_platf_new_hostlink(zone, &hostlink, backbone);
+ sg_platf_build_hostlink(zone, &hostlink, backbone);
}
/* create cabinets */
for (auto const& cabinet : cluster->cabinets) {
- sg_platf_new_cabinet(zone, &cabinet, backbone);
+ sg_platf_build_cabinet(zone, &cabinet, backbone);
}
}
+void routing_cluster_add_backbone(std::unique_ptr<simgrid::kernel::routing::LinkCreationArgs> link)
+{
+ zone_cluster.backbone = std::move(link);
+}
+
+void sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* args)
+{
+ xbt_assert(args, "Invalid nullptr argument");
+ zone_cluster.cabinets.emplace_back(*args);
+}
+
/*************************************************************************************************/
void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route)
{
*/
simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone)
{
+ zone_cluster.routing = zone->routing;
current_routing = sg_platf_create_zone(zone);
return current_routing;
void sg_platf_new_Zone_seal()
{
xbt_assert(current_routing, "Cannot seal the current Zone: none under construction");
+ if (strcasecmp(zone_cluster.routing.c_str(), "Cluster") == 0) {
+ sg_platf_zone_cluster_populate(&zone_cluster);
+ zone_cluster.routing = "";
+ zone_cluster.host_links.clear();
+ zone_cluster.cabinets.clear();
+ zone_cluster.backbone.reset();
+ }
current_routing->seal();
current_routing = current_routing->get_parent();
}
+/** @brief Add a link connecting a host to the rest of its Zone (which must be cluster or vivaldi) */
+void sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* hostlink)
+{
+ xbt_assert(hostlink, "Invalid nullptr parameter");
+ zone_cluster.host_links.emplace_back(*hostlink);
+}
+
void sg_platf_new_trace(simgrid::kernel::routing::ProfileCreationArgs* args)
{
simgrid::kernel::profile::Profile* profile;
class ClusterZoneCreationArgs {
public:
+ std::string routing;
std::vector<HostLinkCreationArgs> host_links;
std::vector<CabinetCreationArgs> cabinets;
std::unique_ptr<LinkCreationArgs> backbone;
} // namespace kernel
} // namespace simgrid
+/********** Routing **********/
+void routing_cluster_add_backbone(std::unique_ptr<simgrid::kernel::routing::LinkCreationArgs> link);
/*** END of the parsing cruft ***/
XBT_PUBLIC simgrid::kernel::routing::NetZoneImpl*
XBT_PUBLIC void sg_platf_new_host_set_properties(const std::unordered_map<std::string, std::string>& props);
XBT_PUBLIC void sg_platf_new_host_seal(int pstate); // That Host is fully described
+XBT_PUBLIC void
+sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone
XBT_PUBLIC void
sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone
XBT_PUBLIC void
simgrid::kernel::routing::ClusterZoneCreationArgs* clust); // Add a routing cluster to the current Zone
XBT_PUBLIC simgrid::kernel::routing::NetPoint* // Add a router to the current Zone
sg_platf_new_router(const std::string&, const std::string& coords);
-
+XBT_PUBLIC void
+sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone
XBT_PUBLIC void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route); // Add a route
XBT_PUBLIC void sg_platf_new_bypassRoute(simgrid::kernel::routing::RouteCreationArgs* bypassroute); // Add a bypassRoute
std::string surf_parsed_filename; // Currently parsed file (for the error messages)
std::vector<simgrid::kernel::resource::LinkImpl*>
parsed_link_list; /* temporary store of current link list of a route */
-simgrid::kernel::routing::ClusterZoneCreationArgs
- zone_cluster; /* temporary store data for irregular clusters, created with <zone routing="Cluster"> */
/* Helping functions */
void surf_parse_assert(bool cond, const std::string& msg)
host_link.id = A_surfxml_host___link_id;
host_link.link_up = A_surfxml_host___link_up;
host_link.link_down = A_surfxml_host___link_down;
- zone_cluster.host_links.emplace_back(host_link);
+ sg_platf_new_hostlink(&host_link);
}
void STag_surfxml_router(){
cabinet.id.c_str());
explodesRadical(A_surfxml_cabinet_radical, &cabinet.radicals);
- zone_cluster.cabinets.emplace_back(cabinet);
+ sg_platf_new_cabinet(&cabinet);
}
void STag_surfxml_peer(){
"latency of backbone", link->id.c_str());
link->policy = simgrid::s4u::Link::SharingPolicy::SHARED;
- zone_cluster.backbone = std::move(link);
+ routing_cluster_add_backbone(std::move(link));
}
void STag_surfxml_route(){
zone.id = A_surfxml_zone_id;
zone.routing = A_surfxml_zone_routing;
sg_platf_new_Zone_begin(&zone);
- /* new cluster zone, clear temp structures */
- if (strcasecmp(A_surfxml_zone_routing, "Cluster") == 0) {
- zone_cluster.host_links.clear();
- zone_cluster.cabinets.clear();
- zone_cluster.backbone.reset();
- }
}
void ETag_surfxml_zone()
{
sg_platf_new_Zone_set_properties(property_sets.back());
property_sets.pop_back();
- if (strcasecmp(A_surfxml_zone_routing, "Cluster") == 0) {
- sg_platf_zone_cluster_populate(&zone_cluster);
- }
sg_platf_new_Zone_seal();
}