From b2f3150048cd87c9e16e251fea65c40221fd56ea Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 16 Nov 2016 08:28:21 +0100 Subject: [PATCH] rename As::getRouteAndLatency into As::getLocalRoute + many small cleanups --- src/kernel/routing/AsCluster.cpp | 16 ++--- src/kernel/routing/AsCluster.hpp | 2 +- src/kernel/routing/AsClusterDragonfly.cpp | 28 ++++----- src/kernel/routing/AsClusterDragonfly.hpp | 2 +- src/kernel/routing/AsClusterFatTree.cpp | 44 ++++++------- src/kernel/routing/AsClusterFatTree.hpp | 4 +- src/kernel/routing/AsClusterTorus.cpp | 7 ++- src/kernel/routing/AsClusterTorus.hpp | 2 +- src/kernel/routing/AsDijkstra.cpp | 7 +-- src/kernel/routing/AsDijkstra.hpp | 2 +- src/kernel/routing/AsFloyd.cpp | 5 +- src/kernel/routing/AsFloyd.hpp | 2 +- src/kernel/routing/AsFull.cpp | 15 ++--- src/kernel/routing/AsFull.hpp | 2 +- src/kernel/routing/AsImpl.cpp | 4 +- src/kernel/routing/AsImpl.hpp | 5 +- src/kernel/routing/AsNone.cpp | 3 +- src/kernel/routing/AsNone.hpp | 2 +- src/kernel/routing/AsRoutedGraph.cpp | 4 +- src/kernel/routing/AsVivaldi.cpp | 75 ++++++++++++----------- src/kernel/routing/AsVivaldi.hpp | 2 +- 21 files changed, 106 insertions(+), 127 deletions(-) diff --git a/src/kernel/routing/AsCluster.cpp b/src/kernel/routing/AsCluster.cpp index 9782f36747..7d90a512bf 100644 --- a/src/kernel/routing/AsCluster.cpp +++ b/src/kernel/routing/AsCluster.cpp @@ -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); diff --git a/src/kernel/routing/AsCluster.hpp b/src/kernel/routing/AsCluster.hpp index f631d29307..9dd3d090e0 100644 --- a/src/kernel/routing/AsCluster.hpp +++ b/src/kernel/routing/AsCluster.hpp @@ -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); diff --git a/src/kernel/routing/AsClusterDragonfly.cpp b/src/kernel/routing/AsClusterDragonfly.cpp index 70fa371044..9fb2d04302 100644 --- a/src/kernel/routing/AsClusterDragonfly.cpp +++ b/src/kernel/routing/AsClusterDragonfly.cpp @@ -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); diff --git a/src/kernel/routing/AsClusterDragonfly.hpp b/src/kernel/routing/AsClusterDragonfly.hpp index 4f58c53c6b..04aec20365 100644 --- a/src/kernel/routing/AsClusterDragonfly.hpp +++ b/src/kernel/routing/AsClusterDragonfly.hpp @@ -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(); diff --git a/src/kernel/routing/AsClusterFatTree.cpp b/src/kernel/routing/AsClusterFatTree.cpp index 6ec9a50a36..169497d99b 100644 --- a/src/kernel/routing/AsClusterFatTree.cpp +++ b/src/kernel/routing/AsClusterFatTree.cpp @@ -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::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); diff --git a/src/kernel/routing/AsClusterFatTree.hpp b/src/kernel/routing/AsClusterFatTree.hpp index 9898e5b105..8f37d0de5b 100644 --- a/src/kernel/routing/AsClusterFatTree.hpp +++ b/src/kernel/routing/AsClusterFatTree.hpp @@ -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 * diff --git a/src/kernel/routing/AsClusterTorus.cpp b/src/kernel/routing/AsClusterTorus.cpp index 5b5f76eb84..9bbb806ed0 100644 --- a/src/kernel/routing/AsClusterTorus.cpp +++ b/src/kernel/routing/AsClusterTorus.cpp @@ -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; diff --git a/src/kernel/routing/AsClusterTorus.hpp b/src/kernel/routing/AsClusterTorus.hpp index b5b9aa4f57..8229fcc55d 100644 --- a/src/kernel/routing/AsClusterTorus.hpp +++ b/src/kernel/routing/AsClusterTorus.hpp @@ -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; diff --git a/src/kernel/routing/AsDijkstra.cpp b/src/kernel/routing/AsDijkstra.cpp index cf697f0b8a..eaf1b27b06 100644 --- a/src/kernel/routing/AsDijkstra.cpp +++ b/src/kernel/routing/AsDijkstra.cpp @@ -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; diff --git a/src/kernel/routing/AsDijkstra.hpp b/src/kernel/routing/AsDijkstra.hpp index ea334139e2..95e89b734b 100644 --- a/src/kernel/routing/AsDijkstra.hpp +++ b/src/kernel/routing/AsDijkstra.hpp @@ -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 */ diff --git a/src/kernel/routing/AsFloyd.cpp b/src/kernel/routing/AsFloyd.cpp index 6aa1816f70..8c571b04a0 100644 --- a/src/kernel/routing/AsFloyd.cpp +++ b/src/kernel/routing/AsFloyd.cpp @@ -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 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)); diff --git a/src/kernel/routing/AsFloyd.hpp b/src/kernel/routing/AsFloyd.hpp index c507f81aa7..b5580e4ac7 100644 --- a/src/kernel/routing/AsFloyd.hpp +++ b/src/kernel/routing/AsFloyd.hpp @@ -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; diff --git a/src/kernel/routing/AsFull.cpp b/src/kernel/routing/AsFull.cpp index 62df1a6b42..95f8f72b40 100644 --- a/src/kernel/routing/AsFull.cpp +++ b/src/kernel/routing/AsFull.cpp @@ -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)->latency(); + *lat += link->latency(); } } } diff --git a/src/kernel/routing/AsFull.hpp b/src/kernel/routing/AsFull.hpp index 0bd7571737..00dc02b9e3 100644 --- a/src/kernel/routing/AsFull.hpp +++ b/src/kernel/routing/AsFull.hpp @@ -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; diff --git a/src/kernel/routing/AsImpl.cpp b/src/kernel/routing/AsImpl.cpp index 0a84c25f83..8025f70b89 100644 --- a/src/kernel/routing/AsImpl.cpp +++ b/src/kernel/routing/AsImpl.cpp @@ -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(); - 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()); diff --git a/src/kernel/routing/AsImpl.hpp b/src/kernel/routing/AsImpl.hpp index 1943e61ebe..ce34fdf50f 100644 --- a/src/kernel/routing/AsImpl.hpp +++ b/src/kernel/routing/AsImpl.hpp @@ -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, diff --git a/src/kernel/routing/AsNone.cpp b/src/kernel/routing/AsNone.cpp index cb56c3670b..5544222b95 100644 --- a/src/kernel/routing/AsNone.cpp +++ b/src/kernel/routing/AsNone.cpp @@ -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*/) diff --git a/src/kernel/routing/AsNone.hpp b/src/kernel/routing/AsNone.hpp index de11e29be4..94dfa9a735 100644 --- a/src/kernel/routing/AsNone.hpp +++ b/src/kernel/routing/AsNone.hpp @@ -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; }; diff --git a/src/kernel/routing/AsRoutedGraph.cpp b/src/kernel/routing/AsRoutedGraph.cpp index c98c6b066a..8dc559fbd7 100644 --- a/src/kernel/routing/AsRoutedGraph.cpp +++ b/src/kernel/routing/AsRoutedGraph.cpp @@ -90,7 +90,7 @@ void AsRoutedGraph::getOneLinkRoutes(std::vector* 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(); - 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()); diff --git a/src/kernel/routing/AsVivaldi.cpp b/src/kernel/routing/AsVivaldi.cpp index a3764cfe80..915e8077f1 100644 --- a/src/kernel/routing/AsVivaldi.cpp +++ b/src/kernel/routing/AsVivaldi.cpp @@ -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 + } } }}} diff --git a/src/kernel/routing/AsVivaldi.hpp b/src/kernel/routing/AsVivaldi.hpp index 8477b6eb21..c51d6786ca 100644 --- a/src/kernel/routing/AsVivaldi.hpp +++ b/src/kernel/routing/AsVivaldi.hpp @@ -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 { -- 2.20.1