Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
FatTreeZone: Add limiters for switches
[simgrid.git] / src / surf / sg_platf.cpp
index 62b4c4d..e63fc05 100644 (file)
@@ -157,7 +157,7 @@ sg_platf_cluster_create_host(const simgrid::kernel::routing::ClusterCreationArgs
 {
   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 = %lu). Check the 'radical' parameter in XML",
+             "(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;
@@ -177,7 +177,7 @@ sg_platf_cluster_create_loopback(const simgrid::kernel::routing::ClusterCreation
   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 = %lu). Check the 'radical' parameter in XML",
+             "(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";
@@ -195,13 +195,7 @@ static simgrid::s4u::Link* sg_platf_cluster_create_limiter(const simgrid::kernel
                                                            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 limiter for host number %d in the zone. Insufficient number of radicals "
-             "available "
-             "(total = %lu). 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]) + "_limiter";
+  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();
@@ -217,8 +211,8 @@ static void sg_platf_new_cluster_hierarchical(const simgrid::kernel::routing::Cl
   using simgrid::kernel::routing::TorusZone;
 
   auto set_host = std::bind(sg_platf_cluster_create_host, cluster, _1, _2, _3);
-  std::function<simgrid::s4u::ClusterLinkCb> set_loopback{};
-  std::function<simgrid::s4u::ClusterLinkCb> set_limiter{};
+  std::function<simgrid::s4u::ClusterCallbacks::ClusterLinkCb> set_loopback{};
+  std::function<simgrid::s4u::ClusterCallbacks::ClusterLinkCb> set_limiter{};
 
   if (cluster->loopback_bw > 0 || cluster->loopback_lat > 0) {
     set_loopback = std::bind(sg_platf_cluster_create_loopback, cluster, _1, _2, _3);
@@ -228,27 +222,26 @@ static void sg_platf_new_cluster_hierarchical(const simgrid::kernel::routing::Cl
     set_limiter = std::bind(sg_platf_cluster_create_limiter, cluster, _1, _2, _3);
   }
 
-  simgrid::s4u::NetZone* parent = routing_get_current() ? routing_get_current()->get_iface() : nullptr;
+  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 = simgrid::s4u::create_torus_zone(
-          cluster->id, parent, TorusZone::parse_topo_parameters(cluster->topo_parameters), cluster->bw, cluster->lat,
-          cluster->sharing_policy, set_host, set_loopback, set_limiter);
+          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 = simgrid::s4u::create_dragonfly_zone(
-          cluster->id, parent, DragonflyZone::parse_topo_parameters(cluster->topo_parameters), cluster->bw,
-          cluster->lat, cluster->sharing_policy, set_host, set_loopback, set_limiter);
+          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 = simgrid::s4u::create_fatTree_zone(
-          cluster->id, parent, FatTreeZone::parse_topo_parameters(cluster->topo_parameters), cluster->bw, cluster->lat,
-          cluster->sharing_policy, set_host, set_loopback, set_limiter);
+          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:
       THROW_IMPOSSIBLE;
-      break;
   }
   zone->seal();
 }
@@ -323,8 +316,9 @@ static void sg_platf_new_cluster_flat(simgrid::kernel::routing::ClusterCreationA
       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
-    current_zone->create_links_for_node(cluster, i, rankId, current_zone->node_pos_with_loopback_limiter(rankId));
+    current_zone->create_links(i, rankId);
     rankId++;
   }