From: Martin Quinson Date: Wed, 16 Nov 2016 01:28:45 +0000 (+0100) Subject: various small cosmetics in the routing X-Git-Tag: v3_14~194 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/83eed53fd4d95fd1fa0532da3c071f66000f1a6b various small cosmetics in the routing --- diff --git a/src/kernel/routing/AsCluster.cpp b/src/kernel/routing/AsCluster.cpp index 57281c1138..9782f36747 100644 --- a/src/kernel/routing/AsCluster.cpp +++ b/src/kernel/routing/AsCluster.cpp @@ -17,14 +17,15 @@ namespace routing { AsCluster::AsCluster(As* father, const char* name) : AsImpl(father, name) { } -AsCluster::~AsCluster() = default; void AsCluster::getRouteAndLatency(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_assert(!privateLinks_.empty(), "Cluster routing : no links attached to the source node - did you use host_link tag?"); + 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_ ){ @@ -35,10 +36,9 @@ void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb return; } - if (hasLimiter_){ // limiter for sender info = privateLinks_.at(src->id() * linkCountPerNode_ + (hasLoopback_?1:0)); - route->link_list->push_back((Link*)info.linkUp); + route->link_list->push_back(info.linkUp); } info = privateLinks_.at(src->id() * linkCountPerNode_ + (hasLoopback_?1:0) + (hasLimiter_?1:0)); diff --git a/src/kernel/routing/AsCluster.hpp b/src/kernel/routing/AsCluster.hpp index 452684926d..f631d29307 100644 --- a/src/kernel/routing/AsCluster.hpp +++ b/src/kernel/routing/AsCluster.hpp @@ -17,7 +17,6 @@ namespace routing { class XBT_PRIVATE AsCluster: public AsImpl { public: explicit AsCluster(As* father, const char* name); - ~AsCluster() override; void getRouteAndLatency(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/AsClusterDragonfly.cpp b/src/kernel/routing/AsClusterDragonfly.cpp index 03e386e386..70fa371044 100644 --- a/src/kernel/routing/AsClusterDragonfly.cpp +++ b/src/kernel/routing/AsClusterDragonfly.cpp @@ -271,8 +271,7 @@ void AsClusterDragonfly::getRouteAndLatency(NetCard * src, NetCard * dst, sg_pla } if (hasLimiter_) { // limiter for sender - s_surf_parsing_link_up_down_t info; - info = privateLinks_.at(src->id() * linkCountPerNode_ + hasLoopback_); + s_surf_parsing_link_up_down_t info = privateLinks_.at(src->id() * linkCountPerNode_ + hasLoopback_); route->link_list->push_back(info.linkUp); } @@ -328,8 +327,7 @@ void AsClusterDragonfly::getRouteAndLatency(NetCard * src, NetCard * dst, sg_pla } if (hasLimiter_) { // limiter for receiver - s_surf_parsing_link_up_down_t info; - info = privateLinks_.at(dst->id() * linkCountPerNode_ + hasLoopback_); + s_surf_parsing_link_up_down_t info = privateLinks_.at(dst->id() * linkCountPerNode_ + hasLoopback_); route->link_list->push_back(info.linkUp); } @@ -341,7 +339,5 @@ void AsClusterDragonfly::getRouteAndLatency(NetCard * src, NetCard * dst, sg_pla xbt_free(myCoords); xbt_free(targetCoords); - - } }}} // namespace diff --git a/src/kernel/routing/AsClusterFatTree.cpp b/src/kernel/routing/AsClusterFatTree.cpp index be82801aad..6ec9a50a36 100644 --- a/src/kernel/routing/AsClusterFatTree.cpp +++ b/src/kernel/routing/AsClusterFatTree.cpp @@ -61,43 +61,33 @@ void AsClusterFatTree::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) { - FatTreeNode *source, *destination, *currentNode; - - std::map::const_iterator tempIter; if (dst->isRouter() || src->isRouter()) return; /* Let's find the source and the destination in our internal structure */ - tempIter = this->computeNodes_.find(src->id()); + 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", + src->name().c_str(), src->id()); + FatTreeNode* source = tempIter->second; - // xbt_die -> assert - if (tempIter == this->computeNodes_.end()) { - xbt_die("Could not find the source %s [%d] in the fat tree", src->name().c_str(), src->id()); - } - source = tempIter->second; tempIter = this->computeNodes_.find(dst->id()); - if (tempIter == this->computeNodes_.end()) { - xbt_die("Could not find the destination %s [%d] in the fat tree", dst->name().c_str(), dst->id()); - } - - - destination = tempIter->second; + xbt_assert(tempIter != this->computeNodes_.end(), "Could not find the destination %s [%d] in the fat tree", + dst->name().c_str(), dst->id()); + FatTreeNode* destination = tempIter->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()); - /* In case destination is the source, and there is a loopback, let's get - through it instead of going up to a switch*/ - if(source->id == destination->id && this->hasLoopback_) { + /* 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 && this->hasLoopback_) { into->link_list->push_back(source->loopback); - if(latency) { + if (latency) *latency += source->loopback->latency(); - } return; } - currentNode = source; + FatTreeNode* currentNode = source; // up part while (!isInSubTree(currentNode, destination)) { @@ -126,7 +116,7 @@ void AsClusterFatTree::getRouteAndLatency(NetCard *src, currentNode->level, currentNode->position); // Down part - while(currentNode != destination) { + 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]) { diff --git a/src/kernel/routing/AsClusterTorus.cpp b/src/kernel/routing/AsClusterTorus.cpp index a65bbadc9f..5b5f76eb84 100644 --- a/src/kernel/routing/AsClusterTorus.cpp +++ b/src/kernel/routing/AsClusterTorus.cpp @@ -117,7 +117,7 @@ namespace simgrid { if (dst->isRouter() || src->isRouter()) return; - if ((src->id() == dst->id()) && hasLoopback_) { + if (src->id() == dst->id() && hasLoopback_) { s_surf_parsing_link_up_down_t info = privateLinks_.at(src->id() * linkCountPerNode_); route->link_list->push_back(info.linkUp); @@ -140,9 +140,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 diff --git a/src/kernel/routing/AsImpl.cpp b/src/kernel/routing/AsImpl.cpp index a0841b9414..0a84c25f83 100644 --- a/src/kernel/routing/AsImpl.cpp +++ b/src/kernel/routing/AsImpl.cpp @@ -25,7 +25,6 @@ namespace simgrid { xbt_lib_set(as_router_lib, name, ROUTING_ASR_LEVEL, static_cast(netcard_)); XBT_DEBUG("AS '%s' created with the id '%d'", name, netcard_->id()); } - AsImpl::~AsImpl() = default; simgrid::s4u::Host* AsImpl::createHost(const char* name, std::vector* speedPerPstate, int coreAmount) { diff --git a/src/kernel/routing/AsImpl.hpp b/src/kernel/routing/AsImpl.hpp index 625aaa0793..1943e61ebe 100644 --- a/src/kernel/routing/AsImpl.hpp +++ b/src/kernel/routing/AsImpl.hpp @@ -30,7 +30,6 @@ namespace routing { protected: explicit AsImpl(As * father, const char* name); - ~AsImpl() override; public: /** @brief Make an host within that AS */ diff --git a/src/kernel/routing/AsNone.cpp b/src/kernel/routing/AsNone.cpp index 66c5097e11..cb56c3670b 100644 --- a/src/kernel/routing/AsNone.cpp +++ b/src/kernel/routing/AsNone.cpp @@ -18,8 +18,7 @@ namespace routing { AsNone::AsNone(As* father, const char* name) : AsImpl(father, name) {} -AsNone::~AsNone() -{} +AsNone::~AsNone() = default; void AsNone::getRouteAndLatency(NetCard * /*src*/, NetCard * /*dst*/, sg_platf_route_cbarg_t /*res*/, double */*lat*/) diff --git a/src/kernel/routing/AsRoutedGraph.cpp b/src/kernel/routing/AsRoutedGraph.cpp index 20b0910b8a..c98c6b066a 100644 --- a/src/kernel/routing/AsRoutedGraph.cpp +++ b/src/kernel/routing/AsRoutedGraph.cpp @@ -30,8 +30,6 @@ AsRoutedGraph::AsRoutedGraph(As* father, const char* name) : AsImpl(father, name { } -AsRoutedGraph::~AsRoutedGraph()=default; - }}} // namespace simgrid::kernel::routing /* ************************************************************************** */ diff --git a/src/kernel/routing/AsRoutedGraph.hpp b/src/kernel/routing/AsRoutedGraph.hpp index b4f5d1f4a5..ad5daa7248 100644 --- a/src/kernel/routing/AsRoutedGraph.hpp +++ b/src/kernel/routing/AsRoutedGraph.hpp @@ -15,7 +15,6 @@ namespace routing { class XBT_PRIVATE AsRoutedGraph : public AsImpl { public: explicit AsRoutedGraph(As* father, const char* name); - ~AsRoutedGraph() override; void getOneLinkRoutes(std::vector* accumulator) override; diff --git a/src/kernel/routing/AsVivaldi.cpp b/src/kernel/routing/AsVivaldi.cpp index 3dd35623d1..a3764cfe80 100644 --- a/src/kernel/routing/AsVivaldi.cpp +++ b/src/kernel/routing/AsVivaldi.cpp @@ -82,14 +82,12 @@ 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) {} -AsVivaldi::~AsVivaldi() {} - 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()) { + 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); diff --git a/src/kernel/routing/AsVivaldi.hpp b/src/kernel/routing/AsVivaldi.hpp index 42f3372ce9..8477b6eb21 100644 --- a/src/kernel/routing/AsVivaldi.hpp +++ b/src/kernel/routing/AsVivaldi.hpp @@ -16,7 +16,6 @@ namespace routing { class XBT_PRIVATE AsVivaldi: public AsCluster { public: explicit AsVivaldi(As* father, const char* name); - ~AsVivaldi() override; void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override; };