From: Martin Quinson Date: Tue, 15 Nov 2016 23:02:38 +0000 (+0100) Subject: reduce the amount of dynars created by getOneLinkRoutes() X-Git-Tag: v3_14~204 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b035f4fba1852d16bb9316bb0b23329b108b605b?ds=sidebyside reduce the amount of dynars created by getOneLinkRoutes() --- diff --git a/src/kernel/routing/AsImpl.cpp b/src/kernel/routing/AsImpl.cpp index 3bd9c9e080..33688aca30 100644 --- a/src/kernel/routing/AsImpl.cpp +++ b/src/kernel/routing/AsImpl.cpp @@ -41,9 +41,8 @@ namespace simgrid { return res; } - xbt_dynar_t AsImpl::getOneLinkRoutes() + void AsImpl::getOneLinkRoutes(xbt_dynar_t accumulator) { - return nullptr; } /** @brief Get the common ancestor and its first children in each line leading to src and dst diff --git a/src/kernel/routing/AsImpl.hpp b/src/kernel/routing/AsImpl.hpp index 8530695984..dd3b26d9e5 100644 --- a/src/kernel/routing/AsImpl.hpp +++ b/src/kernel/routing/AsImpl.hpp @@ -59,7 +59,7 @@ public: */ virtual void getRouteAndLatency(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) */ - virtual xbt_dynar_t getOneLinkRoutes(); + virtual void getOneLinkRoutes(xbt_dynar_t accumulator); /* returns whether we found a bypass path */ bool getBypassRoute(routing::NetCard * src, routing::NetCard * dst, /* OUT */ std::vector * links, double* latency); diff --git a/src/kernel/routing/AsRoutedGraph.cpp b/src/kernel/routing/AsRoutedGraph.cpp index a574eca707..b45087ff7f 100644 --- a/src/kernel/routing/AsRoutedGraph.cpp +++ b/src/kernel/routing/AsRoutedGraph.cpp @@ -81,34 +81,32 @@ namespace simgrid { namespace kernel { namespace routing { - xbt_dynar_t AsRoutedGraph::getOneLinkRoutes() - { - xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f); - sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1); - route->link_list = new std::vector(); - - int table_size = static_cast(vertices_.size()); - for(int src=0; src < table_size; src++) { - for(int dst=0; dst< table_size; dst++) { - route->link_list->clear(); - NetCard *src_elm = vertices_.at(src); - NetCard *dst_elm = vertices_.at(dst); - this->getRouteAndLatency(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); - else if (hierarchy_ == RoutingMode::recursive) - onelink = new Onelink(link, route->gw_src, route->gw_dst); - else - onelink = new Onelink(link, nullptr, nullptr); - xbt_dynar_push(ret, &onelink); - } +void AsRoutedGraph::getOneLinkRoutes(xbt_dynar_t accumulator) +{ + sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1); + route->link_list = new std::vector(); + + int table_size = static_cast(vertices_.size()); + for (int src = 0; src < table_size; src++) { + for (int dst = 0; dst < table_size; dst++) { + route->link_list->clear(); + NetCard* src_elm = vertices_.at(src); + NetCard* dst_elm = vertices_.at(dst); + this->getRouteAndLatency(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); + else if (hierarchy_ == RoutingMode::recursive) + onelink = new Onelink(link, route->gw_src, route->gw_dst); + else + onelink = new Onelink(link, nullptr, nullptr); + xbt_dynar_push(accumulator, &onelink); } } - return ret; + } } void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) diff --git a/src/kernel/routing/AsRoutedGraph.hpp b/src/kernel/routing/AsRoutedGraph.hpp index 9990166566..7dd239c0ea 100644 --- a/src/kernel/routing/AsRoutedGraph.hpp +++ b/src/kernel/routing/AsRoutedGraph.hpp @@ -17,7 +17,7 @@ public: explicit AsRoutedGraph(As* father, const char* name); ~AsRoutedGraph() override; - xbt_dynar_t getOneLinkRoutes() override; + void getOneLinkRoutes(xbt_dynar_t accumulator) override; void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) override; virtual sg_platf_route_cbarg_t newExtendedRoute(RoutingMode hierarchy, sg_platf_route_cbarg_t routearg, int change_order); diff --git a/src/kernel/routing/AsVivaldi.hpp b/src/kernel/routing/AsVivaldi.hpp index 65f4d523a7..42f3372ce9 100644 --- a/src/kernel/routing/AsVivaldi.hpp +++ b/src/kernel/routing/AsVivaldi.hpp @@ -18,7 +18,6 @@ public: explicit AsVivaldi(As* father, const char* name); ~AsVivaldi() override; - xbt_dynar_t getOneLinkRoutes() override {return nullptr;}; void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override; }; diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index aa867591ec..596ccee010 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -100,29 +100,24 @@ void RoutingPlatf::getRouteAndLatency(NetCard *src, NetCard *dst, std::vector
  • getOneLinkRoutes(); - if (onelink_mine) - xbt_dynar_merge(&ret,&onelink_mine); + as->getOneLinkRoutes(accumulator); //recursing char *key; xbt_dict_cursor_t cursor = nullptr; AsImpl *rc_child; xbt_dict_foreach(as->children(), cursor, key, rc_child) { - xbt_dynar_t onelink_child = _recursiveGetOneLinkRoutes(rc_child); - if (onelink_child) - xbt_dynar_merge(&ret,&onelink_child); + _recursiveGetOneLinkRoutes(rc_child, accumulator); } - return ret; } xbt_dynar_t RoutingPlatf::getOneLinkRoutes(){ - return _recursiveGetOneLinkRoutes(root_); + xbt_dynar_t res = xbt_dynar_new(sizeof(Onelink*), xbt_free_f); + _recursiveGetOneLinkRoutes(root_, res); + return res; } }}}