Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill the s_surf_parsing_link_up_down_t datatype
[simgrid.git] / src / kernel / routing / AsClusterTorus.cpp
index a65bbad..017dbc0 100644 (file)
@@ -4,8 +4,9 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/kernel/routing/AsClusterTorus.hpp"
+#include "src/kernel/routing/NetCard.hpp"
+
 #include "src/surf/network_interface.hpp"
-#include "src/surf/xml/platf.hpp" // FIXME: move that back to the parsing area
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster_torus, surf_route_cluster, "Torus Routing part of surf");
 
@@ -61,24 +62,24 @@ namespace simgrid {
         link.latency = cluster->lat;
         link.policy = cluster->sharing_policy;
         sg_platf_new_link(&link);
-        s_surf_parsing_link_up_down_t info;
+        Link *linkUp, *linkDown;
         if (link.policy == SURF_LINK_FULLDUPLEX) {
           char *tmp_link = bprintf("%s_UP", link_id);
-          info.linkUp = Link::byName(tmp_link);
+          linkUp         = Link::byName(tmp_link);
           free(tmp_link);
           tmp_link = bprintf("%s_DOWN", link_id);
-          info.linkDown = Link::byName(tmp_link);
+          linkDown = Link::byName(tmp_link);
           free(tmp_link);
         } else {
-          info.linkUp = Link::byName(link_id);
-          info.linkDown = info.linkUp;
+          linkUp   = Link::byName(link_id);
+          linkDown = linkUp;
         }
         /*
          * Add the link to its appropriate position;
          * note that position rankId*(xbt_dynar_length(dimensions)+has_loopback?+has_limiter?)
          * holds the link "rankId->rankId"
          */
-        privateLinks_.insert({position + j, info});
+        privateLinks_.insert({position + j, {linkUp, linkDown}});
         dim_product *= current_dimension;
         xbt_free(link_id);
       }
@@ -109,20 +110,21 @@ namespace simgrid {
       xbt_dynar_free(&dimensions);
     }
 
-    void AsClusterTorus::getRouteAndLatency(NetCard * src, NetCard * dst, sg_platf_route_cbarg_t route, double *lat) {
+    void AsClusterTorus::getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t route, double* lat)
+    {
 
-      XBT_VERB("torus_get_route_and_latency from '%s'[%d] to '%s'[%d]", src->name().c_str(), src->id(),
-               dst->name().c_str(), dst->id());
+      XBT_VERB("torus getLocalRoute from '%s'[%d] to '%s'[%d]", src->name().c_str(), src->id(), dst->name().c_str(),
+               dst->id());
 
       if (dst->isRouter() || src->isRouter())
         return;
 
-      if ((src->id() == dst->id()) && hasLoopback_) {
-        s_surf_parsing_link_up_down_t info = privateLinks_.at(src->id() * linkCountPerNode_);
+      if (src->id() == dst->id() && hasLoopback_) {
+        std::pair<Link*, Link*> info = privateLinks_.at(src->id() * linkCountPerNode_);
 
-        route->link_list->push_back(info.linkUp);
+        route->link_list->push_back(info.first);
         if (lat)
-          *lat += info.linkUp->latency();
+          *lat += info.first->latency();
         return;
       }
 
@@ -140,9 +142,8 @@ namespace simgrid {
        * both arrays, we can easily assess whether we need to route
        * into this dimension or not.
        */
-      unsigned int *myCoords, *targetCoords;
-      myCoords = rankId_to_coords(src->id(), dimensions_);
-      targetCoords = rankId_to_coords(dst->id(), dimensions_);
+      unsigned int* myCoords     = rankId_to_coords(src->id(), dimensions_);
+      unsigned int* targetCoords = rankId_to_coords(dst->id(), dimensions_);
       /*
        * linkOffset describes the offset where the link
        * we want to use is stored
@@ -197,23 +198,23 @@ namespace simgrid {
           dim_product *= cur_dim;
         }
 
-        s_surf_parsing_link_up_down_t info;
+        std::pair<Link*, Link*> info;
 
         if (hasLimiter_) {    // limiter for sender
           info = privateLinks_.at(nodeOffset + hasLoopback_);
-          route->link_list->push_back(info.linkUp);
+          route->link_list->push_back(info.first);
         }
 
         info = privateLinks_.at(linkOffset);
 
         if (use_lnk_up == false) {
-          route->link_list->push_back(info.linkDown);
+          route->link_list->push_back(info.second);
           if (lat)
-            *lat += info.linkDown->latency();
+            *lat += info.second->latency();
         } else {
-          route->link_list->push_back(info.linkUp);
+          route->link_list->push_back(info.first);
           if (lat)
-            *lat += info.linkUp->latency();
+            *lat += info.first->latency();
         }
         current_node = next_node;
         next_node = 0;