Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Minor Sonar smells (const, etc).
[simgrid.git] / src / kernel / routing / DragonflyZone.cpp
index 850ed0e..ce0f59b 100644 (file)
@@ -141,25 +141,18 @@ void DragonflyZone::generate_routers()
 }
 
 void DragonflyZone::generate_link(const std::string& id, int numlinks, resource::LinkImpl** linkup,
-                                  resource::LinkImpl** linkdown) const
+                                  resource::LinkImpl** linkdown)
 {
+  XBT_DEBUG("Generating link %s", id.c_str());
   *linkup   = nullptr;
   *linkdown = nullptr;
-  LinkCreationArgs linkTemplate;
-  linkTemplate.bandwidths.push_back(this->bw_ * numlinks);
-  linkTemplate.latency = this->lat_;
-  linkTemplate.policy  = this->sharing_policy_;
-  linkTemplate.id      = id;
-  sg_platf_new_link(&linkTemplate);
-  XBT_DEBUG("Generating link %s", linkTemplate.id.c_str());
-  resource::LinkImpl* link;
-  if (this->sharing_policy_ == s4u::Link::SharingPolicy::SPLITDUPLEX) {
-    *linkup   = s4u::Link::by_name(linkTemplate.id + "_UP")->get_impl();   // check link?
-    *linkdown = s4u::Link::by_name(linkTemplate.id + "_DOWN")->get_impl(); // check link ?
+  if (sharing_policy_ == s4u::Link::SharingPolicy::SPLITDUPLEX) {
+    *linkup   = create_link(id + "_UP", std::vector<double>{bw_ * numlinks})->set_latency(lat_)->seal()->get_impl();
+    *linkdown = create_link(id + "_DOWN", std::vector<double>{bw_ * numlinks})->set_latency(lat_)->seal()->get_impl();
+
   } else {
-    link      = s4u::Link::by_name(linkTemplate.id)->get_impl();
-    *linkup   = link;
-    *linkdown = link;
+    *linkup   = create_link(id, std::vector<double>{bw_ * numlinks})->set_latency(lat_)->seal()->get_impl();
+    *linkdown = *linkup;
   }
 }
 
@@ -255,12 +248,12 @@ void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationA
   XBT_VERB("dragonfly getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(),
            dst->id());
 
-  if ((src->id() == dst->id()) && has_loopback_) {
-    std::pair<resource::LinkImpl*, resource::LinkImpl*> info = private_links_.at(node_pos(src->id()));
+  if ((src->id() == dst->id()) && has_loopback()) {
+    resource::LinkImpl* uplink = get_uplink_from(node_pos(src->id()));
 
-    route->link_list.push_back(info.first);
+    route->link_list.push_back(uplink);
     if (latency)
-      *latency += info.first->get_latency();
+      *latency += uplink->get_latency();
     return;
   }
 
@@ -282,9 +275,8 @@ void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationA
   if (latency)
     *latency += myRouter->my_nodes_[myCoords.node * num_links_per_link_]->get_latency();
 
-  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);
+  if (has_limiter()) { // limiter for sender
+    route->link_list.push_back(get_uplink_from(node_pos_with_loopback(src->id())));
   }
 
   if (targetRouter != myRouter) {
@@ -334,9 +326,8 @@ void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationA
     }
   }
 
-  if (has_limiter_) { // limiter for receiver
-    std::pair<resource::LinkImpl*, resource::LinkImpl*> info = private_links_.at(node_pos_with_loopback(dst->id()));
-    route->link_list.push_back(info.first);
+  if (has_limiter()) { // limiter for receiver
+    route->link_list.push_back(get_downlink_to(node_pos_with_loopback(dst->id())));
   }
 
   // router->node local link
@@ -348,4 +339,12 @@ void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationA
 }
 } // namespace routing
 } // namespace kernel
+
+namespace s4u {
+NetZone* create_dragonfly_zone(const std::string& name)
+{
+  return (new kernel::routing::DragonflyZone(name))->get_iface();
+}
+} // namespace s4u
+
 } // namespace simgrid