From 29dbba02d775b87908c34d8233290331b67d02b3 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 7 Dec 2016 19:16:37 +0100 Subject: [PATCH 1/1] cosmetics --- src/kernel/routing/AsCluster.cpp | 7 ++- src/kernel/routing/AsImpl.cpp | 6 +-- src/kernel/routing/AsRoutedGraph.cpp | 70 ++++++++++++---------------- src/surf/surf_routing.hpp | 2 +- 4 files changed, 37 insertions(+), 48 deletions(-) diff --git a/src/kernel/routing/AsCluster.cpp b/src/kernel/routing/AsCluster.cpp index 879429231d..095b80cc16 100644 --- a/src/kernel/routing/AsCluster.cpp +++ b/src/kernel/routing/AsCluster.cpp @@ -21,8 +21,7 @@ AsCluster::AsCluster(As* father, const char* name) : AsImpl(father, name) void AsCluster::getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t route, double* lat) { - XBT_VERB("cluster getLocalRoute 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->cname(), src->id(), dst->cname(), dst->id()); xbt_assert(!privateLinks_.empty(), "Cluster routing: no links attached to the source node - did you use host_link tag?"); @@ -80,7 +79,7 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) xbt_assert(router_,"Malformed cluster. This may be because your platform file is a hypergraph while it must be a graph."); /* create the router */ - xbt_node_t routerNode = new_xbt_graph_node(graph, router_->name().c_str(), nodes); + xbt_node_t routerNode = new_xbt_graph_node(graph, router_->cname(), nodes); if(backbone_) { const char *link_nameR = backbone_->getName(); @@ -91,7 +90,7 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) for (auto src: vertices_){ if (! src->isRouter()) { - previous = new_xbt_graph_node(graph, src->name().c_str(), nodes); + previous = new_xbt_graph_node(graph, src->cname(), nodes); info = privateLinks_.at(src->id()); diff --git a/src/kernel/routing/AsImpl.cpp b/src/kernel/routing/AsImpl.cpp index 31b9e016bc..86c782b7b6 100644 --- a/src/kernel/routing/AsImpl.cpp +++ b/src/kernel/routing/AsImpl.cpp @@ -119,8 +119,8 @@ namespace simgrid { AsImpl* src_as = src->containingAS(); AsImpl* dst_as = dst->containingAS(); - xbt_assert(src_as, "Host %s must be in an AS", src->name().c_str()); - xbt_assert(dst_as, "Host %s must be in an AS", dst->name().c_str()); + xbt_assert(src_as, "Host %s must be in an AS", src->cname()); + xbt_assert(dst_as, "Host %s must be in an AS", dst->cname()); /* (2) find the path to the root routing component */ std::vector path_src; @@ -298,7 +298,7 @@ namespace simgrid { 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()); + src->cname(), dst->cname()); /* If source gateway is not our source, we have to recursively find our way up to this point */ if (src != route.gw_src) diff --git a/src/kernel/routing/AsRoutedGraph.cpp b/src/kernel/routing/AsRoutedGraph.cpp index 6e56149618..e0c289d346 100644 --- a/src/kernel/routing/AsRoutedGraph.cpp +++ b/src/kernel/routing/AsRoutedGraph.cpp @@ -23,16 +23,6 @@ void routing_route_free(sg_platf_route_cbarg_t route) } } -namespace simgrid { -namespace kernel { -namespace routing { - -AsRoutedGraph::AsRoutedGraph(As* father, const char* name) : AsImpl(father, name) -{ -} - -}}} // namespace simgrid::kernel::routing - /* ************************************************************************** */ /* *********************** GENERIC BUSINESS METHODS ************************* */ @@ -80,6 +70,10 @@ namespace simgrid { namespace kernel { namespace routing { +AsRoutedGraph::AsRoutedGraph(As* father, const char* name) : AsImpl(father, name) +{ +} + void AsRoutedGraph::getOneLinkRoutes(std::vector* accumulator) { sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1); @@ -91,18 +85,16 @@ void AsRoutedGraph::getOneLinkRoutes(std::vector* accumulator) route->link_list->clear(); NetCard* src_elm = vertices_.at(src); NetCard* dst_elm = vertices_.at(dst); - this->getLocalRoute(src_elm, dst_elm, route, nullptr); + getLocalRoute(src_elm, dst_elm, route, nullptr); if (route->link_list->size() == 1) { Link* link = route->link_list->at(0); - Onelink* onelink; if (hierarchy_ == RoutingMode::base) - onelink = new Onelink(link, src_elm, dst_elm); + accumulator->push_back(new Onelink(link, src_elm, dst_elm)); else if (hierarchy_ == RoutingMode::recursive) - onelink = new Onelink(link, route->gw_src, route->gw_dst); + accumulator->push_back(new Onelink(link, route->gw_src, route->gw_dst)); else - onelink = new Onelink(link, nullptr, nullptr); - accumulator->push_back(onelink); + accumulator->push_back(new Onelink(link, nullptr, nullptr)); } } } @@ -121,17 +113,17 @@ void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg 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()); + XBT_DEBUG("get_route_and_latency %s -> %s", my_src->cname(), my_dst->cname()); xbt_node_t current, previous; const char *previous_name, *current_name; if (route->gw_src) { - previous = new_xbt_graph_node(graph, route->gw_src->name().c_str(), nodes); - previous_name = route->gw_src->name().c_str(); + previous = new_xbt_graph_node(graph, route->gw_src->cname(), nodes); + previous_name = route->gw_src->cname(); } else { - previous = new_xbt_graph_node(graph, my_src->name().c_str(), nodes); - previous_name = my_src->name().c_str(); + previous = new_xbt_graph_node(graph, my_src->cname(), nodes); + previous_name = my_src->cname(); } for (auto link: *route->link_list) { @@ -145,11 +137,11 @@ void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg } if (route->gw_dst) { - current = new_xbt_graph_node(graph, route->gw_dst->name().c_str(), nodes); - current_name = route->gw_dst->name().c_str(); + current = new_xbt_graph_node(graph, route->gw_dst->cname(), nodes); + current_name = route->gw_dst->cname(); } else { - current = new_xbt_graph_node(graph, my_dst->name().c_str(), nodes); - current_name = my_dst->name().c_str(); + current = new_xbt_graph_node(graph, my_dst->cname(), nodes); + current_name = my_dst->cname(); } new_xbt_graph_edge(graph, previous, current, edges); XBT_DEBUG (" %s -> %s", previous_name, current_name); @@ -192,25 +184,25 @@ sg_platf_route_cbarg_t AsRoutedGraph::newExtendedRoute(RoutingMode hierarchy, sg void AsRoutedGraph::getRouteCheckParams(NetCard *src, NetCard *dst) { - xbt_assert(src, "Cannot find a route from nullptr to %s", dst->name().c_str()); - xbt_assert(dst, "Cannot find a route from %s to nullptr", src->name().c_str()); + xbt_assert(src, "Cannot find a route from nullptr to %s", dst->cname()); + xbt_assert(dst, "Cannot find a route from %s to nullptr", src->cname()); As *src_as = src->containingAS(); As *dst_as = dst->containingAS(); xbt_assert(src_as == dst_as, "Internal error: %s@%s and %s@%s are not in the same AS as expected. Please report that bug.", - src->name().c_str(), src_as->name(), dst->name().c_str(), dst_as->name()); + src->cname(), src_as->name(), dst->cname(), dst_as->name()); xbt_assert(this == dst_as, "Internal error: route destination %s@%s is not in AS %s as expected (route source: " "%s@%s). Please report that bug.", - src->name().c_str(), dst->name().c_str(), src_as->name(), dst_as->name(), name()); + src->cname(), dst->cname(), src_as->name(), dst_as->name(), name()); } void AsRoutedGraph::addRouteCheckParams(sg_platf_route_cbarg_t route) { NetCard *src = route->src; NetCard *dst = route->dst; - const char* srcName = src->name().c_str(); - const char* dstName = dst->name().c_str(); + const char* srcName = src->cname(); + const char* dstName = dst->cname(); if(!route->gw_dst && !route->gw_src) { XBT_DEBUG("Load Route from \"%s\" to \"%s\"", srcName, dstName); @@ -220,8 +212,7 @@ void AsRoutedGraph::addRouteCheckParams(sg_platf_route_cbarg_t route) { xbt_assert(! src->isAS(), "When defining a route, src cannot be an AS such as '%s'. Did you meant to have an ASroute?", srcName); xbt_assert(! dst->isAS(), "When defining a route, dst cannot be an AS such as '%s'. Did you meant to have an ASroute?", dstName); } else { - XBT_DEBUG("Load ASroute from %s@%s to %s@%s", srcName, route->gw_src->name().c_str(), dstName, - route->gw_dst->name().c_str()); + XBT_DEBUG("Load ASroute from %s@%s to %s@%s", srcName, route->gw_src->cname(), dstName, route->gw_dst->cname()); xbt_assert(src->isAS(), "When defining an ASroute, src must be an AS but '%s' is not", srcName); xbt_assert(dst->isAS(), "When defining an ASroute, dst must be an AS but '%s' is not", dstName); @@ -230,15 +221,14 @@ void AsRoutedGraph::addRouteCheckParams(sg_platf_route_cbarg_t route) { xbt_assert(route->gw_dst->isHost() || route->gw_dst->isRouter(), "When defining an ASroute, gw_dst must be an host or a router but '%s' is not.", dstName); - xbt_assert(route->gw_src != route->gw_dst, "Cannot define an ASroute from '%s' to itself", - route->gw_src->name().c_str()); + xbt_assert(route->gw_src != route->gw_dst, "Cannot define an ASroute from '%s' to itself", route->gw_src->cname()); - xbt_assert(src, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName, - route->gw_src->name().c_str(), dstName, route->gw_dst->name().c_str(), srcName); - xbt_assert(dst, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName, - route->gw_src->name().c_str(), dstName, route->gw_dst->name().c_str(), dstName); + xbt_assert(src, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName, route->gw_src->cname(), + dstName, route->gw_dst->cname(), srcName); + xbt_assert(dst, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName, route->gw_src->cname(), + dstName, route->gw_dst->cname(), dstName); xbt_assert(!route->link_list->empty(), "Empty route (between %s@%s and %s@%s) forbidden.", srcName, - route->gw_src->name().c_str(), dstName, route->gw_dst->name().c_str()); + route->gw_src->cname(), dstName, route->gw_dst->cname()); } } diff --git a/src/surf/surf_routing.hpp b/src/surf/surf_routing.hpp index 6f570ba767..a0c2e3ba24 100644 --- a/src/surf/surf_routing.hpp +++ b/src/surf/surf_routing.hpp @@ -46,7 +46,7 @@ public: */ class Onelink { public: - Onelink(Link* link, NetCard* src, NetCard* dst) : src_(src), dst_(dst), link_(link){}; + Onelink(Link* link, NetCard* src, NetCard* dst) : src_(src), dst_(dst), link_(link) {} NetCard* src_; NetCard* dst_; Link* link_; -- 2.20.1