#include "src/surf/HostImpl.hpp"
#include "src/surf/xml/platf_private.hpp"
+#include <algorithm>
#include <string>
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse);
} // namespace kernel
} // namespace simgrid
+static 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()
/* adding routes */
std::vector<simgrid::s4u::Link*> links_up{limiter, link_up, backbone};
- links_up.erase(std::remove(links_up.begin(), links_up.end(), nullptr), links_up.end());
std::vector<simgrid::s4u::Link*> links_down{backbone, link_down, limiter};
+ links_up.erase(std::remove(links_up.begin(), links_up.end(), nullptr), links_up.end());
links_down.erase(std::remove(links_down.begin(), links_down.end(), nullptr), links_down.end());
zone->add_route(host->get_netpoint(), nullptr, nullptr, nullptr, links_up, false);
auto* router = zone->create_router(cluster->router_id);
zone->add_route(router, nullptr, nullptr, nullptr, {});
+ zone->seal();
simgrid::kernel::routing::on_cluster_creation(*cluster);
}
/*************************************************************************************************/
/** @brief Set the links for internal node inside a Cluster(Star) */
static void sg_platf_cluster_set_hostlink(simgrid::kernel::routing::StarZone* zone,
- simgrid::kernel::routing::NetPoint* netpoint, simgrid::s4u::Link* link_up,
- simgrid::s4u::Link* link_down, simgrid::kernel::resource::LinkImpl* backbone)
+ simgrid::kernel::routing::NetPoint* netpoint,
+ const simgrid::s4u::Link* link_up, const simgrid::s4u::Link* link_down,
+ simgrid::kernel::resource::LinkImpl* backbone)
{
XBT_DEBUG("Push Host_link for host '%s' to position %u", netpoint->get_cname(), netpoint->id());
if (backbone) {
}
/** @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;
}
}
-void sg_platf_zone_cluster_populate(simgrid::kernel::routing::ClusterZoneCreationArgs* cluster)
+static void sg_platf_zone_cluster_populate(const simgrid::kernel::routing::ClusterZoneCreationArgs* cluster)
{
auto* zone = dynamic_cast<simgrid::kernel::routing::StarZone*>(current_routing);
xbt_assert(zone, "Host_links are only valid for Cluster(Star)");
/* 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)
{
- current_routing = sg_platf_create_zone(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;