Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
do not use RouteCreationArgs outside of XML parsing
[simgrid.git] / src / kernel / routing / FatTreeZone.cpp
index a848e8d..b7df0d1 100644 (file)
@@ -51,7 +51,7 @@ bool FatTreeZone::is_in_sub_tree(FatTreeNode* root, FatTreeNode* node) const
   return true;
 }
 
-void FatTreeZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency)
+void FatTreeZone::get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency)
 {
   if (dst->is_router() || src->is_router())
     return;
@@ -72,7 +72,7 @@ void FatTreeZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg
 
   /* In case destination is the source, and there is a loopback, let's use it instead of going up to a switch */
   if (source->id == destination->id && has_loopback()) {
-    into->link_list.push_back(source->loopback_);
+    into->link_list_.push_back(source->loopback_);
     if (latency)
       *latency += source->loopback_->get_latency();
     return;
@@ -89,13 +89,13 @@ void FatTreeZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg
 
     int k = this->num_parents_per_node_[currentNode->level];
     d     = d % k;
-    into->link_list.push_back(currentNode->parents[d]->up_link_);
+    into->link_list_.push_back(currentNode->parents[d]->up_link_);
 
     if (latency)
       *latency += currentNode->parents[d]->up_link_->get_latency();
 
     if (currentNode->limiter_link_)
-      into->link_list.push_back(currentNode->limiter_link_);
+      into->link_list_.push_back(currentNode->limiter_link_);
     currentNode = currentNode->parents[d]->up_node_;
   }
 
@@ -106,20 +106,20 @@ void FatTreeZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg
   while (currentNode != destination) {
     for (unsigned int i = 0; i < currentNode->children.size(); i++) {
       if (i % this->num_children_per_node_[currentNode->level - 1] == destination->label[currentNode->level - 1]) {
-        into->link_list.push_back(currentNode->children[i]->down_link_);
+        into->link_list_.push_back(currentNode->children[i]->down_link_);
         if (latency)
           *latency += currentNode->children[i]->down_link_->get_latency();
         currentNode = currentNode->children[i]->down_node_;
         if (currentNode->limiter_link_)
-          into->link_list.push_back(currentNode->limiter_link_);
+          into->link_list_.push_back(currentNode->limiter_link_);
         XBT_DEBUG("%d(%u,%u) is accessible through %d(%u,%u)", destination->id, destination->level,
                   destination->position, currentNode->id, currentNode->level, currentNode->position);
       }
     }
   }
   // set gateways (if any)
-  into->gw_src = get_gateway(src->id());
-  into->gw_dst = get_gateway(dst->id());
+  into->gw_src_ = get_gateway(src->id());
+  into->gw_dst_ = get_gateway(dst->id());
 }
 
 /* This function makes the assumption that parse_specific_arguments() and
@@ -346,11 +346,13 @@ void FatTreeZone::add_link(FatTreeNode* parent, unsigned int parentPort, FatTree
   std::string id =
       "link_from_" + std::to_string(child->id) + "_" + std::to_string(parent->id) + "_" + std::to_string(uniqueId);
 
-  if (link_sharing_policy_ == s4u::Link::SharingPolicy::SPLITDUPLEX) {
-    linkup   = create_link(id + "_UP", std::vector<double>{link_bw_})->set_latency(link_lat_)->seal();
-    linkdown = create_link(id + "_DOWN", std::vector<double>{link_bw_})->set_latency(link_lat_)->seal();
+  if (get_link_sharing_policy() == s4u::Link::SharingPolicy::SPLITDUPLEX) {
+    linkup =
+        create_link(id + "_UP", std::vector<double>{get_link_bandwidth()})->set_latency(get_link_latency())->seal();
+    linkdown =
+        create_link(id + "_DOWN", std::vector<double>{get_link_bandwidth()})->set_latency(get_link_latency())->seal();
   } else {
-    linkup   = create_link(id, std::vector<double>{link_bw_})->set_latency(link_lat_)->seal();
+    linkup   = create_link(id, std::vector<double>{get_link_bandwidth()})->set_latency(get_link_latency())->seal();
     linkdown = linkup;
   }
   uniqueId++;
@@ -388,13 +390,6 @@ void FatTreeZone::check_topology(unsigned int n_levels, const std::vector<unsign
   check_vector(link_count, "link count");
 }
 
-void FatTreeZone::set_link_characteristics(double bw, double lat, s4u::Link::SharingPolicy sharing_policy)
-{
-  link_sharing_policy_ = sharing_policy;
-  link_bw_             = bw;
-  link_lat_            = lat;
-}
-
 void FatTreeZone::set_topology(unsigned int n_levels, const std::vector<unsigned int>& down_links,
                                const std::vector<unsigned int>& up_links, const std::vector<unsigned int>& link_count)
 {
@@ -404,7 +399,7 @@ void FatTreeZone::set_topology(unsigned int n_levels, const std::vector<unsigned
   num_port_lower_level_  = link_count;
 }
 
-void FatTreeZone::parse_specific_arguments(ClusterCreationArgs* cluster)
+s4u::FatTreeParams FatTreeZone::parse_topo_parameters(const std::string& topo_parameters)
 {
   std::vector<std::string> parameters;
   std::vector<std::string> tmp;
@@ -412,7 +407,7 @@ void FatTreeZone::parse_specific_arguments(ClusterCreationArgs* cluster)
   std::vector<unsigned int> down;
   std::vector<unsigned int> up;
   std::vector<unsigned int> count;
-  boost::split(parameters, cluster->topo_parameters, boost::is_any_of(";"));
+  boost::split(parameters, topo_parameters, boost::is_any_of(";"));
 
   surf_parse_assert(
       parameters.size() == 4,
@@ -464,12 +459,7 @@ void FatTreeZone::parse_specific_arguments(ClusterCreationArgs* cluster)
       throw std::invalid_argument(std::string("Invalid lower level port number:") + port);
     }
   }
-
-  /* set topology */
-  FatTreeZone::check_topology(n_lev, down, up, count);
-  set_topology(n_lev, down, up, count);
-  /* saving internal links properties */
-  set_link_characteristics(cluster->bw, cluster->lat, cluster->sharing_policy);
+  return s4u::FatTreeParams(n_lev, down, up, count);
 }
 
 void FatTreeZone::generate_dot_file(const std::string& filename) const
@@ -505,10 +495,8 @@ FatTreeParams::FatTreeParams(unsigned int n_levels, const std::vector<unsigned i
 }
 
 NetZone* create_fatTree_zone(const std::string& name, const NetZone* parent, const FatTreeParams& params,
-                             double bandwidth, double latency, Link::SharingPolicy sharing_policy,
-                             const std::function<ClusterNetPointCb>& set_netpoint,
-                             const std::function<ClusterLinkCb>& set_loopback,
-                             const std::function<ClusterLinkCb>& set_limiter)
+                             const ClusterCallbacks& set_callbacks, double bandwidth, double latency,
+                             Link::SharingPolicy sharing_policy)
 {
   /* initial checks */
   if (bandwidth <= 0)
@@ -531,7 +519,7 @@ NetZone* create_fatTree_zone(const std::string& name, const NetZone* parent, con
     kernel::routing::NetPoint* netpoint;
     Link* limiter;
     Link* loopback;
-    zone->fill_leaf_from_cb(i, params.down, set_netpoint, set_loopback, set_limiter, &netpoint, &loopback, &limiter);
+    zone->fill_leaf_from_cb(i, params.down, set_callbacks, &netpoint, &loopback, &limiter);
     zone->add_processing_node(i, limiter ? limiter->get_impl() : nullptr, loopback ? loopback->get_impl() : nullptr);
   }