Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rename As::getRouteAndLatency into As::getLocalRoute
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 16 Nov 2016 07:28:21 +0000 (08:28 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 16 Nov 2016 07:28:32 +0000 (08:28 +0100)
+ many small cleanups

21 files changed:
src/kernel/routing/AsCluster.cpp
src/kernel/routing/AsCluster.hpp
src/kernel/routing/AsClusterDragonfly.cpp
src/kernel/routing/AsClusterDragonfly.hpp
src/kernel/routing/AsClusterFatTree.cpp
src/kernel/routing/AsClusterFatTree.hpp
src/kernel/routing/AsClusterTorus.cpp
src/kernel/routing/AsClusterTorus.hpp
src/kernel/routing/AsDijkstra.cpp
src/kernel/routing/AsDijkstra.hpp
src/kernel/routing/AsFloyd.cpp
src/kernel/routing/AsFloyd.hpp
src/kernel/routing/AsFull.cpp
src/kernel/routing/AsFull.hpp
src/kernel/routing/AsImpl.cpp
src/kernel/routing/AsImpl.hpp
src/kernel/routing/AsNone.cpp
src/kernel/routing/AsNone.hpp
src/kernel/routing/AsRoutedGraph.cpp
src/kernel/routing/AsVivaldi.cpp
src/kernel/routing/AsVivaldi.hpp

index 9782f36..7d90a51 100644 (file)
@@ -18,18 +18,17 @@ AsCluster::AsCluster(As* father, const char* name) : AsImpl(father, name)
 {
 }
 
-void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
+void AsCluster::getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t route, double* lat)
 {
-  s_surf_parsing_link_up_down_t info;
-  XBT_VERB("cluster_get_route_and_latency from '%s'[%d] to '%s'[%d]", src->name().c_str(), src->id(),
-           dst->name().c_str(), dst->id());
+  XBT_VERB("cluster getLocalRoute from '%s'[%d] to '%s'[%d]", src->name().c_str(), src->id(), dst->name().c_str(),
+           dst->id());
   xbt_assert(!privateLinks_.empty(),
              "Cluster routing: no links attached to the source node - did you use host_link tag?");
 
   if (! src->isRouter()) {    // No specific link for router
 
     if((src->id() == dst->id()) && hasLoopback_ ){
-      info = privateLinks_.at(src->id() * linkCountPerNode_);
+      s_surf_parsing_link_up_down_t info = privateLinks_.at(src->id() * linkCountPerNode_);
       route->link_list->push_back(info.linkUp);
       if (lat)
         *lat += info.linkUp->latency();
@@ -37,11 +36,12 @@ void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb
     }
 
     if (hasLimiter_){          // limiter for sender
-      info = privateLinks_.at(src->id() * linkCountPerNode_ + (hasLoopback_?1:0));
+      s_surf_parsing_link_up_down_t info = privateLinks_.at(src->id() * linkCountPerNode_ + (hasLoopback_ ? 1 : 0));
       route->link_list->push_back(info.linkUp);
     }
 
-    info = privateLinks_.at(src->id() * linkCountPerNode_ + (hasLoopback_?1:0) + (hasLimiter_?1:0));
+    s_surf_parsing_link_up_down_t info =
+        privateLinks_.at(src->id() * linkCountPerNode_ + (hasLoopback_ ? 1 : 0) + (hasLimiter_ ? 1 : 0));
     if (info.linkUp) {         // link up
       route->link_list->push_back(info.linkUp);
       if (lat)
@@ -57,7 +57,7 @@ void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb
   }
 
   if (! dst->isRouter()) {    // No specific link for router
-    info = privateLinks_.at(dst->id() * linkCountPerNode_ + hasLoopback_ + hasLimiter_);
+    s_surf_parsing_link_up_down_t info = privateLinks_.at(dst->id() * linkCountPerNode_ + hasLoopback_ + hasLimiter_);
 
     if (info.linkDown) {       // link down
       route->link_list->push_back(info.linkDown);
index f631d29..9dd3d09 100644 (file)
@@ -18,7 +18,7 @@ class XBT_PRIVATE AsCluster: public AsImpl {
 public:
   explicit AsCluster(As* father, const char* name);
 
-  void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
+  void getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t into, double* latency) override;
   void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) override;
 
   virtual void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position);
index 70fa371..9fb2d04 100644 (file)
@@ -236,15 +236,16 @@ void AsClusterDragonfly::generateLinks() {
   }
 }
 
-void AsClusterDragonfly::getRouteAndLatency(NetCard * src, NetCard * dst, sg_platf_route_cbarg_t route, double *latency) {
+void AsClusterDragonfly::getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t route, double* latency)
+{
   //Minimal routing version.
   // TODO : non-minimal random one, and adaptive ?
 
   if (dst->isRouter() || src->isRouter())
     return;
 
-  XBT_VERB("dragonfly_get_route_and_latency from '%s'[%d] to '%s'[%d]", src->name().c_str(), src->id(),
-           dst->name().c_str(), dst->id());
+  XBT_VERB("dragonfly getLocalRout from '%s'[%d] to '%s'[%d]", src->name().c_str(), src->id(), dst->name().c_str(),
+           dst->id());
 
   if ((src->id() == dst->id()) && hasLoopback_) {
      s_surf_parsing_link_up_down_t info = privateLinks_.at(src->id() * linkCountPerNode_);
@@ -266,9 +267,8 @@ void AsClusterDragonfly::getRouteAndLatency(NetCard * src, NetCard * dst, sg_pla
 
   //node->router local link
   route->link_list->push_back(myRouter->myNodes_[myCoords[3]*numLinksperLink_]);
-  if(latency) {
+  if (latency)
     *latency += myRouter->myNodes_[myCoords[3] * numLinksperLink_]->latency();
-  }
 
   if (hasLimiter_) {    // limiter for sender
     s_surf_parsing_link_up_down_t info = privateLinks_.at(src->id() * linkCountPerNode_ + hasLoopback_);
@@ -283,26 +283,23 @@ void AsClusterDragonfly::getRouteAndLatency(NetCard * src, NetCard * dst, sg_pla
       if(currentRouter->blade_!=targetCoords[0]){
         //go to the nth router in our chassis
         route->link_list->push_back(currentRouter->greenLinks_[targetCoords[0]]);
-        if(latency) {
+        if (latency)
           *latency += currentRouter->greenLinks_[targetCoords[0]]->latency();
-        }
         currentRouter=routers_[myCoords[0]*(numChassisPerGroup_*numBladesPerChassis_)+myCoords[1] * numBladesPerChassis_+targetCoords[0]];
       }
 
       if(currentRouter->chassis_!=0){
         //go to the first chassis of our group
         route->link_list->push_back(currentRouter->blackLinks_[0]);
-        if(latency) {
+        if (latency)
           *latency += currentRouter->blackLinks_[0]->latency();
-        }
         currentRouter=routers_[myCoords[0]*(numChassisPerGroup_*numBladesPerChassis_)+targetCoords[0]];
       }
 
       //go to destination group - the only optical hop 
       route->link_list->push_back(currentRouter->blueLinks_[0]);
-      if(latency) {
+      if (latency)
         *latency += currentRouter->blueLinks_[0]->latency();
-      }
       currentRouter=routers_[targetCoords[0]*(numChassisPerGroup_*numBladesPerChassis_)+myCoords[0]];
     }
 
@@ -310,18 +307,16 @@ void AsClusterDragonfly::getRouteAndLatency(NetCard * src, NetCard * dst, sg_pla
     //same group, but same blade ?
     if(targetRouter->blade_ != currentRouter->blade_){
       route->link_list->push_back(currentRouter->greenLinks_[targetCoords[2]]);
-      if(latency) {
+      if (latency)
         *latency += currentRouter->greenLinks_[targetCoords[2]]->latency();
-      }
       currentRouter=routers_[targetCoords[0]*(numChassisPerGroup_*numBladesPerChassis_)+targetCoords[2]];
     }
 
     //same blade, but same chassis ?
     if(targetRouter->chassis_ != currentRouter->chassis_){
       route->link_list->push_back(currentRouter->blackLinks_[targetCoords[1]]);
-      if(latency) {
+      if (latency)
         *latency += currentRouter->blackLinks_[targetCoords[1]]->latency();
-      }
       currentRouter=routers_[targetCoords[0]*(numChassisPerGroup_*numBladesPerChassis_)+targetCoords[1]*numBladesPerChassis_+targetCoords[2]];
     }
   }
@@ -333,9 +328,8 @@ void AsClusterDragonfly::getRouteAndLatency(NetCard * src, NetCard * dst, sg_pla
 
   //router->node local link
   route->link_list->push_back(targetRouter->myNodes_[targetCoords[3]*numLinksperLink_+numLinksperLink_-1]);
-  if(latency) {
+  if (latency)
     *latency += targetRouter->myNodes_[targetCoords[3] * numLinksperLink_ + numLinksperLink_ - 1]->latency();
-  }
 
   xbt_free(myCoords);
   xbt_free(targetCoords);
index 4f58c53..04aec20 100644 (file)
@@ -66,7 +66,7 @@ class XBT_PRIVATE AsClusterDragonfly
       explicit AsClusterDragonfly(As* father, const char* name);
       ~AsClusterDragonfly() override;
 //      void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position) override;
-      void getRouteAndLatency(NetCard * src, NetCard * dst, sg_platf_route_cbarg_t into, double *latency) override;
+      void getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t into, double* latency) override;
       void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster) override;
       void seal() override;
       void generateRouters();
index 6ec9a50..169497d 100644 (file)
@@ -57,24 +57,22 @@ bool AsClusterFatTree::isInSubTree(FatTreeNode *root, FatTreeNode *node) {
   return true;
 }
 
-void AsClusterFatTree::getRouteAndLatency(NetCard *src,
-                                          NetCard *dst,
-                                          sg_platf_route_cbarg_t into,
-                                          double *latency) {
-  
+void AsClusterFatTree::getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t into, double* latency)
+{
+
   if (dst->isRouter() || src->isRouter())
     return;
 
   /* Let's find the source and the destination in our internal structure */
-  std::map<int, FatTreeNode*>::const_iterator tempIter = this->computeNodes_.find(src->id());
-  xbt_assert(tempIter != this->computeNodes_.end(), "Could not find the source %s [%d] in the fat tree",
+  auto searchedNode = this->computeNodes_.find(src->id());
+  xbt_assert(searchedNode != this->computeNodes_.end(), "Could not find the source %s [%d] in the fat tree",
              src->name().c_str(), src->id());
-  FatTreeNode* source = tempIter->second;
+  FatTreeNode* source = searchedNode->second;
 
-  tempIter = this->computeNodes_.find(dst->id());
-  xbt_assert(tempIter != this->computeNodes_.end(), "Could not find the destination %s [%d] in the fat tree",
+  searchedNode = this->computeNodes_.find(dst->id());
+  xbt_assert(searchedNode != this->computeNodes_.end(), "Could not find the destination %s [%d] in the fat tree",
              dst->name().c_str(), dst->id());
-  FatTreeNode* destination = tempIter->second;
+  FatTreeNode* destination = searchedNode->second;
 
   XBT_VERB("Get route and latency from '%s' [%d] to '%s' [%d] in a fat tree", src->name().c_str(), src->id(),
            dst->name().c_str(), dst->id());
@@ -91,23 +89,20 @@ void AsClusterFatTree::getRouteAndLatency(NetCard *src,
 
   // up part
   while (!isInSubTree(currentNode, destination)) {
-    int d, k; // as in d-mod-k
-    d = destination->position;
+    int d = destination->position; // as in d-mod-k
 
-    for (unsigned int i = 0 ; i < currentNode->level ; i++) {
+    for (unsigned int i = 0; i < currentNode->level; i++)
       d /= this->upperLevelNodesNumber_[i];
-    }
-    k = this->upperLevelNodesNumber_[currentNode->level];
+
+    int k = this->upperLevelNodesNumber_[currentNode->level];
     d = d % k;
     into->link_list->push_back(currentNode->parents[d]->upLink);
 
-    if(latency) {
+    if (latency)
       *latency += currentNode->parents[d]->upLink->latency();
-    }
 
-    if (this->hasLimiter_) {
+    if (this->hasLimiter_)
       into->link_list->push_back(currentNode->limiterLink);
-    }
     currentNode = currentNode->parents[d]->upNode;
   }
 
@@ -118,16 +113,13 @@ void AsClusterFatTree::getRouteAndLatency(NetCard *src,
   // Down part
   while (currentNode != destination) {
     for(unsigned int i = 0 ; i < currentNode->children.size() ; i++) {
-      if(i % this->lowerLevelNodesNumber_[currentNode->level - 1] ==
-         destination->label[currentNode->level - 1]) {
+      if (i % this->lowerLevelNodesNumber_[currentNode->level - 1] == destination->label[currentNode->level - 1]) {
         into->link_list->push_back(currentNode->children[i]->downLink);
-        if(latency) {
+        if (latency)
           *latency += currentNode->children[i]->downLink->latency();
-        }
         currentNode = currentNode->children[i]->downNode;
-        if (this->hasLimiter_) {
+        if (this->hasLimiter_)
           into->link_list->push_back(currentNode->limiterLink);
-        }
         XBT_DEBUG("%d(%u,%u) is accessible through %d(%u,%u)", destination->id,
                   destination->level, destination->position, currentNode->id,
                   currentNode->level, currentNode->position);
index 9898e5b..8f37d0d 100644 (file)
@@ -104,9 +104,7 @@ class XBT_PRIVATE AsClusterFatTree : public AsCluster {
 public:
   explicit AsClusterFatTree(As* father, const char* name);
   ~AsClusterFatTree() override;
-  void getRouteAndLatency(NetCard *src, NetCard *dst,
-                                  sg_platf_route_cbarg_t into,
-                                  double *latency) override;
+  void getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t into, double* latency) override;
 
   /** \brief Generate the fat tree
    * 
index 5b5f76e..9bbb806 100644 (file)
@@ -109,10 +109,11 @@ 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;
index b5b9aa4..8229fcc 100644 (file)
@@ -17,7 +17,7 @@ namespace routing {
       explicit AsClusterTorus(As* father, const char* name);
       ~AsClusterTorus() override;
       void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position) override;
-      void getRouteAndLatency(NetCard * src, NetCard * dst, sg_platf_route_cbarg_t into, double *latency) override;
+      void getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t into, double* latency) override;
       void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster) override;
     private:
       xbt_dynar_t dimensions_ = nullptr;
index cf697f0..eaf1b27 100644 (file)
@@ -138,14 +138,13 @@ void AsDijkstra::newRoute(int src_id, int dst_id, sg_platf_route_cbarg_t e_route
   xbt_graph_new_edge(routeGraph_, src, dst, e_route);
 }
 
-void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
+void AsDijkstra::getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t route, double* lat)
 {
   getRouteCheckParams(src, dst);
   int src_id = src->id();
   int dst_id = dst->id();
 
   int *pred_arr = nullptr;
-  sg_platf_route_cbarg_t e_route;
   int size = 0;
   xbt_dynar_t nodes = xbt_graph_get_nodes(routeGraph_);
 
@@ -166,7 +165,7 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c
     if (edge == nullptr)
       THROWF(arg_error, 0, "No route from '%s' to '%s'", src->name().c_str(), dst->name().c_str());
 
-    e_route = (sg_platf_route_cbarg_t) xbt_graph_edge_get_data(edge);
+    sg_platf_route_cbarg_t e_route = (sg_platf_route_cbarg_t)xbt_graph_edge_get_data(edge);
 
     for (auto link: *e_route->link_list) {
       route->link_list->insert(route->link_list->begin(), link);
@@ -252,7 +251,7 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c
 
     prev_gw_src = gw_src;
 
-    e_route = (sg_platf_route_cbarg_t) xbt_graph_edge_get_data(edge);
+    sg_platf_route_cbarg_t e_route = (sg_platf_route_cbarg_t)xbt_graph_edge_get_data(edge);
     gw_src = e_route->gw_src;
     gw_dst = e_route->gw_dst;
 
index ea33413..95e89b7 100644 (file)
@@ -52,7 +52,7 @@ public:
      * After this function returns, any node in the graph
      * will have a loopback attached to it.
      */
-  void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat) override;
+  void getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t route, double* lat) override;
   void addRoute(sg_platf_route_cbarg_t route) override;
 
   xbt_graph_t routeGraph_ = nullptr;     /* xbt_graph */
index 6aa1816..8c571b0 100644 (file)
@@ -40,7 +40,7 @@ AsFloyd::~AsFloyd(){
   xbt_free(costTable_);
 }
 
-void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
+void AsFloyd::getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t route, double* lat)
 {
   size_t table_size = vertices_.size();
 
@@ -48,10 +48,9 @@ void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbar
 
   /* create a result route */
   std::vector<sg_platf_route_cbarg_t> route_stack;
-  int pred;
   unsigned int cur = dst->id();
   do {
-    pred = TO_FLOYD_PRED(src->id(), cur);
+    int pred = TO_FLOYD_PRED(src->id(), cur);
     if (pred == -1)
       THROWF(arg_error, 0, "No route from '%s' to '%s'", src->name().c_str(), dst->name().c_str());
     route_stack.push_back(TO_FLOYD_LINK(pred, cur));
index c507f81..b5580e4 100644 (file)
@@ -18,7 +18,7 @@ public:
   explicit AsFloyd(As* father, const char* name);
   ~AsFloyd() override;
 
-  void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
+  void getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t into, double* latency) override;
   void addRoute(sg_platf_route_cbarg_t route) override;
   void seal() override;
 
index 62df1a6..95f8f72 100644 (file)
@@ -59,25 +59,20 @@ AsFull::~AsFull(){
   }
 }
 
-void AsFull::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t res, double *lat)
+void AsFull::getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t res, double* lat)
 {
-  XBT_DEBUG("full_get_route_and_latency from %s[%d] to %s[%d]", src->name().c_str(), src->id(), dst->name().c_str(),
-            dst->id());
+  XBT_DEBUG("full getLocalRoute from %s[%d] to %s[%d]", src->name().c_str(), src->id(), dst->name().c_str(), dst->id());
 
-  /* set utils vars */
   size_t table_size = vertices_.size();
+  sg_platf_route_cbarg_t e_route = TO_ROUTE_FULL(src->id(), dst->id());
 
-  sg_platf_route_cbarg_t e_route = nullptr;
-
-  e_route = TO_ROUTE_FULL(src->id(), dst->id());
-
-  if (e_route) {
+  if (e_route != nullptr) {
     res->gw_src = e_route->gw_src;
     res->gw_dst = e_route->gw_dst;
     for (auto link : *e_route->link_list) {
       res->link_list->push_back(link);
       if (lat)
-        *lat += static_cast<Link*>(link)->latency();
+        *lat += link->latency();
     }
   }
 }
index 0bd7571..00dc02b 100644 (file)
@@ -19,7 +19,7 @@ public:
   void seal() override;
   ~AsFull() override;
 
-  void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
+  void getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t into, double* latency) override;
   void addRoute(sg_platf_route_cbarg_t route) override;
 
   sg_platf_route_cbarg_t *routingTable_ = nullptr;
index 0a84c25..8025f70 100644 (file)
@@ -291,7 +291,7 @@ namespace simgrid {
       /* If src and dst are in the same AS, life is good */
       if (src_ancestor == dst_ancestor) {       /* SURF_ROUTING_BASE */
         route.link_list = links;
-        common_ancestor->getRouteAndLatency(src, dst, &route, latency);
+        common_ancestor->getLocalRoute(src, dst, &route, latency);
         return;
       }
 
@@ -299,7 +299,7 @@ namespace simgrid {
 
       route.link_list = new std::vector<surf::Link*>();
 
-      common_ancestor->getRouteAndLatency(src_ancestor->netcard_, dst_ancestor->netcard_, &route, latency);
+      common_ancestor->getLocalRoute(src_ancestor->netcard_, dst_ancestor->netcard_, &route, latency);
       xbt_assert((route.gw_src != nullptr) && (route.gw_dst != nullptr), "bad gateways for route from \"%s\" to \"%s\"",
                  src->name().c_str(), dst->name().c_str());
 
index 1943e61..ce34fdf 100644 (file)
@@ -22,7 +22,8 @@ namespace routing {
   /** @brief Autonomous Systems
    *
    * An AS is a network container, in charge of routing information between elements (hosts) and to the nearby ASes.
-   * In SimGrid, there is a hierarchy of ASes, with a unique root AS (that you can retrieve from the s4u::Engine).
+   * In SimGrid, there is a hierarchy (a tree) of ASes, with a unique root AS (that you can retrieve from the
+   * s4u::Engine).
    */
   XBT_PUBLIC_CLASS AsImpl : public s4u::As
   {
@@ -61,7 +62,7 @@ namespace routing {
      * @param latency Accumulator in which the latencies should be added (caller must set it to 0)
      */
   protected:
-    virtual void getRouteAndLatency(NetCard * src, NetCard * dst, sg_platf_route_cbarg_t into, double* latency) = 0;
+    virtual void getLocalRoute(NetCard * src, NetCard * dst, sg_platf_route_cbarg_t into, double* latency) = 0;
     /** @brief retrieves the list of all routes of size 1 (of type src x dst x Link) */
     /* returns whether we found a bypass path */
     bool getBypassRoute(routing::NetCard * src, routing::NetCard * dst,
index cb56c36..5544222 100644 (file)
@@ -20,8 +20,7 @@ AsNone::AsNone(As* father, const char* name) : AsImpl(father, name)
 
 AsNone::~AsNone() = default;
 
-void AsNone::getRouteAndLatency(NetCard * /*src*/, NetCard * /*dst*/,
-                                sg_platf_route_cbarg_t /*res*/, double */*lat*/)
+void AsNone::getLocalRoute(NetCard* /*src*/, NetCard* /*dst*/, sg_platf_route_cbarg_t /*res*/, double* /*lat*/)
 {}
 
 void AsNone::getGraph(xbt_graph_t /*graph*/, xbt_dict_t /*nodes*/, xbt_dict_t /*edges*/)
index de11e29..94dfa9a 100644 (file)
@@ -18,7 +18,7 @@ public:
   explicit AsNone(As* father, const char* name);
   ~AsNone() override;
 
-  void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
+  void getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t into, double* latency) override;
   void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) override;
 };
 
index c98c6b0..8dc559f 100644 (file)
@@ -90,7 +90,7 @@ void AsRoutedGraph::getOneLinkRoutes(std::vector<Onelink*>* accumulator)
       route->link_list->clear();
       NetCard* src_elm = vertices_.at(src);
       NetCard* dst_elm = vertices_.at(dst);
-      this->getRouteAndLatency(src_elm, dst_elm, route, nullptr);
+      this->getLocalRoute(src_elm, dst_elm, route, nullptr);
 
       if (route->link_list->size() == 1) {
         Link* link = route->link_list->at(0);
@@ -118,7 +118,7 @@ void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg
       sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
       route->link_list = new std::vector<Link*>();
 
-      getRouteAndLatency(my_src, my_dst, route, nullptr);
+      getLocalRoute(my_src, my_dst, route, nullptr);
 
       XBT_DEBUG("get_route_and_latency %s -> %s", my_src->name().c_str(), my_dst->name().c_str());
 
index a3764cf..915e807 100644 (file)
@@ -82,49 +82,50 @@ static inline double euclidean_dist_comp(int index, xbt_dynar_t src, xbt_dynar_t
   AsVivaldi::AsVivaldi(As* father, const char* name) : AsCluster(father, name)
   {}
 
-void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
-{
-  XBT_DEBUG("vivaldi_get_route_and_latency from '%s'[%d] '%s'[%d]", src->name().c_str(), src->id(), dst->name().c_str(),
-            dst->id());
-
-  if (src->isAS()) {
-    char* srcName = bprintf("router_%s", src->name().c_str());
-    char* dstName = bprintf("router_%s", dst->name().c_str());
-    route->gw_src = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib, srcName, ROUTING_ASR_LEVEL);
-    route->gw_dst = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib, dstName, ROUTING_ASR_LEVEL);
-    xbt_free(srcName);
-    xbt_free(dstName);
-  }
+  void AsVivaldi::getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t route, double* lat)
+  {
+    XBT_DEBUG("vivaldi getLocalRoute from '%s'[%d] '%s'[%d]", src->name().c_str(), src->id(), dst->name().c_str(),
+              dst->id());
+
+    if (src->isAS()) {
+      char* srcName = bprintf("router_%s", src->name().c_str());
+      char* dstName = bprintf("router_%s", dst->name().c_str());
+      route->gw_src = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib, srcName, ROUTING_ASR_LEVEL);
+      route->gw_dst = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib, dstName, ROUTING_ASR_LEVEL);
+      xbt_free(srcName);
+      xbt_free(dstName);
+    }
 
-  /* Retrieve the private links */
-  if (privateLinks_.size() > src->id()) {
-    s_surf_parsing_link_up_down_t info = privateLinks_.at(src->id());
-    if(info.linkUp) {
-      route->link_list->push_back(info.linkUp);
-      if (lat)
-        *lat += info.linkUp->latency();
+    /* Retrieve the private links */
+    if (privateLinks_.size() > src->id()) {
+      s_surf_parsing_link_up_down_t info = privateLinks_.at(src->id());
+      if (info.linkUp) {
+        route->link_list->push_back(info.linkUp);
+        if (lat)
+          *lat += info.linkUp->latency();
+      }
     }
-  }
-  if (privateLinks_.size() >dst->id()) {
-    s_surf_parsing_link_up_down_t info = privateLinks_.at(dst->id());
-    if(info.linkDown) {
-      route->link_list->push_back(info.linkDown);
-      if (lat)
-        *lat += info.linkDown->latency();
+    if (privateLinks_.size() > dst->id()) {
+      s_surf_parsing_link_up_down_t info = privateLinks_.at(dst->id());
+      if (info.linkDown) {
+        route->link_list->push_back(info.linkDown);
+        if (lat)
+          *lat += info.linkDown->latency();
+      }
     }
-  }
 
-  /* Compute the extra latency due to the euclidean distance if needed */
-  if (lat){
-    xbt_dynar_t srcCoords = getCoordsFromNetcard(src);
-    xbt_dynar_t dstCoords = getCoordsFromNetcard(dst);
+    /* Compute the extra latency due to the euclidean distance if needed */
+    if (lat) {
+      xbt_dynar_t srcCoords = getCoordsFromNetcard(src);
+      xbt_dynar_t dstCoords = getCoordsFromNetcard(dst);
 
-    double euclidean_dist = sqrt (euclidean_dist_comp(0,srcCoords,dstCoords)+euclidean_dist_comp(1,srcCoords,dstCoords))
-                              + fabs(xbt_dynar_get_as(srcCoords, 2, double))+fabs(xbt_dynar_get_as(dstCoords, 2, double));
+      double euclidean_dist =
+          sqrt(euclidean_dist_comp(0, srcCoords, dstCoords) + euclidean_dist_comp(1, srcCoords, dstCoords)) +
+          fabs(xbt_dynar_get_as(srcCoords, 2, double)) + fabs(xbt_dynar_get_as(dstCoords, 2, double));
 
-    XBT_DEBUG("Updating latency %f += %f",*lat,euclidean_dist);
-    *lat += euclidean_dist / 1000.0; //From .ms to .s
-  }
+      XBT_DEBUG("Updating latency %f += %f", *lat, euclidean_dist);
+      *lat += euclidean_dist / 1000.0; // From .ms to .s
+    }
 }
 
 }}}
index 8477b6e..c51d678 100644 (file)
@@ -17,7 +17,7 @@ class XBT_PRIVATE AsVivaldi: public AsCluster {
 public:
   explicit AsVivaldi(As* father, const char* name);
 
-  void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
+  void getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t into, double* latency) override;
 };
 
 namespace vivaldi {