current_host = nullptr;
}
+void sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* args)
+{
+ auto* zone = dynamic_cast<simgrid::kernel::routing::VivaldiZone*>(current_routing);
+ xbt_assert(zone, "<peer> tag can only be used in Vivaldi netzones.");
+
+ const auto* peer = zone->create_host(args->id, std::vector<double>{args->speed})
+ ->set_state_profile(args->state_trace)
+ ->set_speed_profile(args->speed_trace)
+ ->set_coordinates(args->coord)
+ ->seal();
+
+ zone->set_peer_link(peer->get_netpoint(), args->bw_in, args->bw_out);
+}
+
/** @brief Add a "router" to the network element list */
simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name, const std::string& coords)
{
void sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk)
{
- simgrid::s4u::Disk* new_disk = routing_get_current()
- ->create_disk(disk->id, disk->read_bw, disk->write_bw)
- ->set_host(current_host)
- ->set_properties(disk->properties)
- ->seal();
+ const simgrid::s4u::Disk* new_disk = routing_get_current()
+ ->create_disk(disk->id, disk->read_bw, disk->write_bw)
+ ->set_host(current_host)
+ ->set_properties(disk->properties)
+ ->seal();
current_host->add_disk(new_disk);
}
-void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster)
+/** @brief Auxiliary function to create hosts */
+static std::pair<simgrid::kernel::routing::NetPoint*, simgrid::kernel::routing::NetPoint*>
+sg_platf_cluster_create_host(const simgrid::kernel::routing::ClusterCreationArgs* cluster, simgrid::s4u::NetZone* zone,
+ const std::vector<unsigned int>& /*coord*/, int id)
{
- using simgrid::kernel::routing::ClusterZone;
+ xbt_assert(static_cast<unsigned long>(id) < cluster->radicals.size(),
+ "Zone(%s): error when creating host number %d in the zone. Insufficient number of radicals available "
+ "(total = %zu). Check the 'radical' parameter in XML",
+ cluster->id.c_str(), id, cluster->radicals.size());
+
+ std::string host_id = std::string(cluster->prefix) + std::to_string(cluster->radicals[id]) + cluster->suffix;
+ XBT_DEBUG("Cluster: creating host=%s speed=%f", host_id.c_str(), cluster->speeds.front());
+ const simgrid::s4u::Host* host = zone->create_host(host_id, cluster->speeds)
+ ->set_core_count(cluster->core_amount)
+ ->set_properties(cluster->properties)
+ ->seal();
+ return std::make_pair(host->get_netpoint(), nullptr);
+}
+
+/** @brief Auxiliary function to create loopback links */
+static simgrid::s4u::Link*
+sg_platf_cluster_create_loopback(const simgrid::kernel::routing::ClusterCreationArgs* cluster,
+ simgrid::s4u::NetZone* zone, const std::vector<unsigned int>& /*coord*/, int id)
+{
+ xbt_assert(static_cast<unsigned long>(id) < cluster->radicals.size(),
+ "Zone(%s): error when creating loopback for host number %d in the zone. Insufficient number of radicals "
+ "available "
+ "(total = %zu). Check the 'radical' parameter in XML",
+ cluster->id.c_str(), id, cluster->radicals.size());
+
+ std::string link_id = std::string(cluster->id) + "_link_" + std::to_string(cluster->radicals[id]) + "_loopback";
+ XBT_DEBUG("Cluster: creating loopback link=%s bw=%f", link_id.c_str(), cluster->loopback_bw);
+
+ simgrid::s4u::Link* loopback = zone->create_link(link_id, cluster->loopback_bw)
+ ->set_sharing_policy(simgrid::s4u::Link::SharingPolicy::FATPIPE)
+ ->set_latency(cluster->loopback_lat)
+ ->seal();
+ return loopback;
+}
+
+/** @brief Auxiliary function to create limiter links */
+static simgrid::s4u::Link* sg_platf_cluster_create_limiter(const simgrid::kernel::routing::ClusterCreationArgs* cluster,
+ simgrid::s4u::NetZone* zone,
+ const std::vector<unsigned int>& /*coord*/, int id)
+{
+ std::string link_id = std::string(cluster->id) + "_link_" + std::to_string(id) + "_limiter";
+ XBT_DEBUG("Cluster: creating limiter link=%s bw=%f", link_id.c_str(), cluster->limiter_link);
+
+ simgrid::s4u::Link* limiter = zone->create_link(link_id, cluster->limiter_link)->seal();
+ return limiter;
+}
+
+/** @brief Create Torus, Fat-Tree and Dragonfly clusters */
+static void sg_platf_new_cluster_hierarchical(const simgrid::kernel::routing::ClusterCreationArgs* cluster)
+{
+ using namespace std::placeholders;
using simgrid::kernel::routing::DragonflyZone;
using simgrid::kernel::routing::FatTreeZone;
using simgrid::kernel::routing::TorusZone;
- int rankId = 0;
+ auto set_host = std::bind(sg_platf_cluster_create_host, cluster, _1, _2, _3);
+ std::function<simgrid::s4u::ClusterCallbacks::ClusterLinkCb> set_loopback{};
+ std::function<simgrid::s4u::ClusterCallbacks::ClusterLinkCb> set_limiter{};
- // What an inventive way of initializing the NetZone that I have as ancestor :-(
- simgrid::kernel::routing::ZoneCreationArgs zone;
- zone.id = cluster->id;
+ if (cluster->loopback_bw > 0 || cluster->loopback_lat > 0) {
+ set_loopback = std::bind(sg_platf_cluster_create_loopback, cluster, _1, _2, _3);
+ }
+
+ if (cluster->limiter_link > 0) {
+ set_limiter = std::bind(sg_platf_cluster_create_limiter, cluster, _1, _2, _3);
+ }
+
+ simgrid::s4u::NetZone const* parent = routing_get_current() ? routing_get_current()->get_iface() : nullptr;
+ simgrid::s4u::NetZone* zone;
switch (cluster->topology) {
case simgrid::kernel::routing::ClusterTopology::TORUS:
- zone.routing = "ClusterTorus";
+ zone = simgrid::s4u::create_torus_zone(
+ cluster->id, parent, TorusZone::parse_topo_parameters(cluster->topo_parameters),
+ {set_host, set_loopback, set_limiter}, cluster->bw, cluster->lat, cluster->sharing_policy);
break;
case simgrid::kernel::routing::ClusterTopology::DRAGONFLY:
- zone.routing = "ClusterDragonfly";
+ zone = simgrid::s4u::create_dragonfly_zone(
+ cluster->id, parent, DragonflyZone::parse_topo_parameters(cluster->topo_parameters),
+ {set_host, set_loopback, set_limiter}, cluster->bw, cluster->lat, cluster->sharing_policy);
break;
case simgrid::kernel::routing::ClusterTopology::FAT_TREE:
- zone.routing = "ClusterFatTree";
+ zone = simgrid::s4u::create_fatTree_zone(
+ cluster->id, parent, FatTreeZone::parse_topo_parameters(cluster->topo_parameters),
+ {set_host, set_loopback, set_limiter}, cluster->bw, cluster->lat, cluster->sharing_policy);
break;
default:
- zone.routing = "Cluster";
- break;
+ THROW_IMPOSSIBLE;
}
+ zone->seal();
+}
+
+/** @brief Create regular Cluster */
+static void sg_platf_new_cluster_flat(simgrid::kernel::routing::ClusterCreationArgs* cluster)
+{
+ using simgrid::kernel::routing::ClusterZone;
+
+ int rankId = 0;
+
+ // What an inventive way of initializing the NetZone that I have as ancestor :-(
+ simgrid::kernel::routing::ZoneCreationArgs zone;
+ zone.id = cluster->id;
+ zone.routing = "Cluster";
sg_platf_new_Zone_begin(&zone);
auto* current_zone = static_cast<ClusterZone*>(routing_get_current());
- current_zone->parse_specific_arguments(cluster);
for (auto const& elm : cluster->properties)
current_zone->get_iface()->set_property(elm.first, elm.second);
current_zone->add_private_link_at(current_zone->node_pos_with_loopback(rankId), {limiter, limiter});
}
+ current_zone->set_link_characteristics(cluster->bw, cluster->lat, cluster->sharing_policy);
// call the cluster function that adds the others links
- if (cluster->topology == simgrid::kernel::routing::ClusterTopology::FAT_TREE) {
- static_cast<FatTreeZone*>(current_zone)->add_processing_node(i, limiter, loopback);
- } else {
- current_zone->create_links_for_node(cluster, i, rankId, current_zone->node_pos_with_loopback_limiter(rankId));
- }
+ current_zone->create_links(i, rankId);
rankId++;
}
auto* backbone = current_zone->create_link(bb_name, std::vector<double>{cluster->bb_bw})
->set_sharing_policy(cluster->bb_sharing_policy)
->set_latency(cluster->bb_lat)
- ->seal();
- current_zone->set_backbone(backbone->get_impl());
+ ->seal()
+ ->get_impl();
+ current_zone->set_backbone(backbone);
}
XBT_DEBUG("</zone>");
sg_platf_new_Zone_seal();
+}
+
+void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster)
+{
+ switch (cluster->topology) {
+ case simgrid::kernel::routing::ClusterTopology::TORUS:
+ case simgrid::kernel::routing::ClusterTopology::DRAGONFLY:
+ case simgrid::kernel::routing::ClusterTopology::FAT_TREE:
+ sg_platf_new_cluster_hierarchical(cluster);
+ break;
+ default:
+ sg_platf_new_cluster_flat(cluster);
+ break;
+ }
simgrid::kernel::routing::on_cluster_creation(*cluster);
}
XBT_DEBUG("Add a backbone to zone '%s'", current_routing->get_cname());
}
-void sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet)
+void sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* args)
{
auto* zone = static_cast<simgrid::kernel::routing::ClusterZone*>(routing_get_current());
- for (int const& radical : cabinet->radicals) {
- std::string id = cabinet->prefix + std::to_string(radical) + cabinet->suffix;
- simgrid::s4u::Host* host = zone->create_host(id, std::vector<double>{cabinet->speed})->seal();
+ for (int const& radical : args->radicals) {
+ std::string id = args->prefix + std::to_string(radical) + args->suffix;
+ auto const* host = zone->create_host(id, std::vector<double>{args->speed})->seal();
+
+ const auto* link_up =
+ zone->create_link("link_" + id + "_UP", std::vector<double>{args->bw})->set_latency(args->lat)->seal();
- simgrid::s4u::Link* link_up =
- zone->create_link("link_" + id + "_UP", std::vector<double>{cabinet->bw})->set_latency(cabinet->lat)->seal();
- simgrid::s4u::Link* link_down =
- zone->create_link("link_" + id + "_DOWN", std::vector<double>{cabinet->bw})->set_latency(cabinet->lat)->seal();
+ const auto* link_down =
+ zone->create_link("link_" + id + "_DOWN", std::vector<double>{args->bw})->set_latency(args->lat)->seal();
zone->add_private_link_at(host->get_netpoint()->id(), {link_up->get_impl(), link_down->get_impl()});
}
}
}
-void sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer)
-{
- auto* zone = dynamic_cast<simgrid::kernel::routing::VivaldiZone*>(current_routing);
- xbt_assert(zone, "<peer> tag can only be used in Vivaldi netzones.");
-
- simgrid::s4u::Host* host = zone->create_host(peer->id, std::vector<double>{peer->speed})
- ->set_state_profile(peer->state_trace)
- ->set_speed_profile(peer->speed_trace)
- ->set_coordinates(peer->coord)
- ->seal();
-
- zone->set_peer_link(host->get_netpoint(), peer->bw_in, peer->bw_out);
-}
/**
* @brief Auxiliary function to build the object NetZoneImpl
*
*/
simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone)
{
- /* First create the zone.
- * This order is important to assure that root netzone is set when models are setting
- * the default mode for each resource (CPU, network, etc)
- */
- auto* new_zone = sg_platf_create_zone(zone);
+ current_routing = sg_platf_create_zone(zone);
- _sg_cfg_init_status = 2; /* HACK: direct access to the global controlling the level of configuration to prevent
- * any further config now that we created some real content */
-
- /* set the new current component of the tree */
- current_routing = new_zone;
- simgrid::s4u::NetZone::on_creation(*new_zone->get_iface()); // notify the signal
-
- return new_zone;
+ return current_routing;
}
void sg_platf_new_Zone_set_properties(const std::unordered_map<std::string, std::string>& props)
{
xbt_assert(current_routing, "Cannot seal the current Zone: none under construction");
current_routing->seal();
- simgrid::s4u::NetZone::on_seal(*current_routing->get_iface());
current_routing = current_routing->get_parent();
}
cluster_zone->add_private_link_at(netpoint->id(), {linkUp->get_impl(), linkDown->get_impl()});
}
-void sg_platf_new_trace(simgrid::kernel::routing::ProfileCreationArgs* profile)
+void sg_platf_new_trace(simgrid::kernel::routing::ProfileCreationArgs* args)
{
- simgrid::kernel::profile::Profile* mgr_profile;
- if (not profile->file.empty()) {
- mgr_profile = simgrid::kernel::profile::Profile::from_file(profile->file);
+ simgrid::kernel::profile::Profile* profile;
+ if (not args->file.empty()) {
+ profile = simgrid::kernel::profile::Profile::from_file(args->file);
} else {
- xbt_assert(not profile->pc_data.empty(), "Trace '%s' must have either a content, or point to a file on disk.",
- profile->id.c_str());
- mgr_profile = simgrid::kernel::profile::Profile::from_string(profile->id, profile->pc_data, profile->periodicity);
+ xbt_assert(not args->pc_data.empty(), "Trace '%s' must have either a content, or point to a file on disk.",
+ args->id.c_str());
+ profile = simgrid::kernel::profile::Profile::from_string(args->id, args->pc_data, args->periodicity);
}
- traces_set_list.insert({profile->id, mgr_profile});
+ traces_set_list.insert({args->id, profile});
}