Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
FatTreeZone: Add limiters for switches
[simgrid.git] / src / kernel / routing / ClusterZone.cpp
index 5d31b78..43651e2 100644 (file)
@@ -7,7 +7,6 @@
 #include "simgrid/kernel/routing/NetPoint.hpp"
 #include "simgrid/kernel/routing/RoutedZone.hpp"
 #include "src/surf/network_interface.hpp"
-#include "src/surf/xml/platf_private.hpp" // FIXME: RouteCreationArgs and friends
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf");
 
@@ -35,12 +34,19 @@ void ClusterZone::set_limiter()
   }
 }
 
+void ClusterZone::set_link_characteristics(double bw, double lat, s4u::Link::SharingPolicy sharing_policy)
+{
+  link_sharing_policy_ = sharing_policy;
+  link_bw_             = bw;
+  link_lat_            = lat;
+}
+
 void ClusterZone::add_private_link_at(unsigned int position, std::pair<resource::LinkImpl*, resource::LinkImpl*> link)
 {
   private_links_.insert({position, link});
 }
 
-void ClusterZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat)
+void ClusterZone::get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* lat)
 {
   XBT_VERB("cluster getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
   xbt_assert(not private_links_.empty(),
@@ -51,7 +57,7 @@ void ClusterZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg
       XBT_WARN("Routing from a cluster private router to itself is meaningless");
     } else {
       std::pair<resource::LinkImpl*, resource::LinkImpl*> info = private_links_.at(node_pos(src->id()));
-      route->link_list.push_back(info.first);
+      route->link_list_.push_back(info.first);
       if (lat)
         *lat += info.first->get_latency();
     }
@@ -61,20 +67,20 @@ void ClusterZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg
   if (not src->is_router()) { // No private link for the private router
     if (has_limiter_) {       // limiter for sender
       std::pair<resource::LinkImpl*, resource::LinkImpl*> info = private_links_.at(node_pos_with_loopback(src->id()));
-      route->link_list.push_back(info.first);
+      route->link_list_.push_back(info.first);
     }
 
     std::pair<resource::LinkImpl*, resource::LinkImpl*> info =
         private_links_.at(node_pos_with_loopback_limiter(src->id()));
     if (info.first) { // link up
-      route->link_list.push_back(info.first);
+      route->link_list_.push_back(info.first);
       if (lat)
         *lat += info.first->get_latency();
     }
   }
 
   if (backbone_) {
-    route->link_list.push_back(backbone_);
+    route->link_list_.push_back(backbone_);
     if (lat)
       *lat += backbone_->get_latency();
   }
@@ -84,13 +90,13 @@ void ClusterZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg
         private_links_.at(node_pos_with_loopback_limiter(dst->id()));
 
     if (info.second) { // link down
-      route->link_list.push_back(info.second);
+      route->link_list_.push_back(info.second);
       if (lat)
         *lat += info.second->get_latency();
     }
     if (has_limiter_) { // limiter for receiver
       info = private_links_.at(node_pos_with_loopback(dst->id()));
-      route->link_list.push_back(info.first);
+      route->link_list_.push_back(info.first);
     }
   }
 }
@@ -141,20 +147,20 @@ void ClusterZone::get_graph(const s_xbt_graph_t* graph, std::map<std::string, xb
   }
 }
 
-void ClusterZone::create_links_for_node(const ClusterCreationArgs* cluster, int id, int /*rank*/, unsigned int position)
+void ClusterZone::create_links(int id, int rank)
 {
-  std::string link_id = cluster->id + "_link_" + std::to_string(id);
+  std::string link_id = get_name() + "_link_" + std::to_string(id);
 
   const s4u::Link* linkUp;
   const s4u::Link* linkDown;
-  if (cluster->sharing_policy == simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX) {
-    linkUp   = create_link(link_id + "_UP", std::vector<double>{cluster->bw})->set_latency(cluster->lat)->seal();
-    linkDown = create_link(link_id + "_DOWN", std::vector<double>{cluster->bw})->set_latency(cluster->lat)->seal();
+  if (link_sharing_policy_ == simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX) {
+    linkUp   = create_link(link_id + "_UP", std::vector<double>{link_bw_})->set_latency(link_lat_)->seal();
+    linkDown = create_link(link_id + "_DOWN", std::vector<double>{link_bw_})->set_latency(link_lat_)->seal();
   } else {
-    linkUp   = create_link(link_id, std::vector<double>{cluster->bw})->set_latency(cluster->lat)->seal();
+    linkUp   = create_link(link_id, std::vector<double>{link_bw_})->set_latency(link_lat_)->seal();
     linkDown = linkUp;
   }
-  private_links_.insert({position, {linkUp->get_impl(), linkDown->get_impl()}});
+  private_links_.insert({node_pos_with_loopback_limiter(rank), {linkUp->get_impl(), linkDown->get_impl()}});
 }
 
 void ClusterZone::set_gateway(unsigned int position, NetPoint* gateway)