From 6a923fd453c6cf3787ae85ebdae7035a46272e03 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 16 Nov 2016 01:19:55 +0100 Subject: [PATCH] unXBTize a bit --- src/kernel/routing/AsImpl.cpp | 2 +- src/kernel/routing/AsImpl.hpp | 112 ++++++++++++++------------- src/kernel/routing/AsRoutedGraph.cpp | 4 +- src/kernel/routing/AsRoutedGraph.hpp | 2 +- src/surf/network_ns3.cpp | 8 +- src/surf/surf_routing.cpp | 7 +- src/surf/surf_routing.hpp | 2 +- 7 files changed, 70 insertions(+), 67 deletions(-) diff --git a/src/kernel/routing/AsImpl.cpp b/src/kernel/routing/AsImpl.cpp index 33688aca30..9fe0cefa82 100644 --- a/src/kernel/routing/AsImpl.cpp +++ b/src/kernel/routing/AsImpl.cpp @@ -41,7 +41,7 @@ namespace simgrid { return res; } - void AsImpl::getOneLinkRoutes(xbt_dynar_t accumulator) + void AsImpl::getOneLinkRoutes(std::vector* accumulator) { } diff --git a/src/kernel/routing/AsImpl.hpp b/src/kernel/routing/AsImpl.hpp index dd3b26d9e5..47478528c1 100644 --- a/src/kernel/routing/AsImpl.hpp +++ b/src/kernel/routing/AsImpl.hpp @@ -17,65 +17,69 @@ namespace simgrid { namespace kernel { namespace routing { class RoutingPlatf; // FIXME: KILLME + class Onelink; -/** @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). - */ -XBT_PUBLIC_CLASS AsImpl : public s4u::As { - friend simgrid::kernel::routing::RoutingPlatf; -protected: - explicit AsImpl(As * father, const char* name); - ~AsImpl() override; - -public: - /** @brief Make an host within that AS */ - simgrid::s4u::Host* createHost(const char* name, std::vector* speedPerPstate, int coreAmount); - - /** - * @brief Probe the routing path between two points - * - * The networking model uses this function when creating a communication - * to retrieve both the list of links that the create communication will use, - * and the summed latency that these links represent. - * - * The network could recompute the latency by itself from the list, but it would - * require an additional link set traversal. This operation being on the critical - * path of SimGrid, the routing computes the latency in behalf of the network. - * - * Things are rather complex here because we have to find the path from ASes to ASes, and within each. - * In addition, the different ASes may use differing routing models. - * Some ASes may be routed in full, others may have only some connection information and use a shortest path on top of that, and so on. - * Some ASes may even not have any predefined links and use only coordinate information to compute the latency. + /** @brief Autonomous Systems * - * So, the path is constructed recursively, with each traversed AS adding its information to the set. - * The algorithm for that is explained in http://hal.inria.fr/hal-00650233/ - * - * @param src Initial point of the routing path - * @param dst Final point of the routing path - * @param into Container into which the traversed links should be pushed - * @param latency Accumulator in which the latencies should be added (caller must set it to 0) + * 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). */ - 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 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); + XBT_PUBLIC_CLASS AsImpl : public s4u::As + { + friend simgrid::kernel::routing::RoutingPlatf; + + protected: + explicit AsImpl(As * father, const char* name); + ~AsImpl() override; + + public: + /** @brief Make an host within that AS */ + simgrid::s4u::Host* createHost(const char* name, std::vector* speedPerPstate, int coreAmount); + + /** + * @brief Probe the routing path between two points + * + * The networking model uses this function when creating a communication + * to retrieve both the list of links that the create communication will use, + * and the summed latency that these links represent. + * + * The network could recompute the latency by itself from the list, but it would + * require an additional link set traversal. This operation being on the critical + * path of SimGrid, the routing computes the latency in behalf of the network. + * + * Things are rather complex here because we have to find the path from ASes to ASes, and within each. + * In addition, the different ASes may use differing routing models. + * Some ASes may be routed in full, others may have only some connection information and use a shortest path on top + * of that, and so on. + * Some ASes may even not have any predefined links and use only coordinate information to compute the latency. + * + * So, the path is constructed recursively, with each traversed AS adding its information to the set. + * The algorithm for that is explained in http://hal.inria.fr/hal-00650233/ + * + * @param src Initial point of the routing path + * @param dst Final point of the routing path + * @param into Container into which the traversed links should be pushed + * @param latency Accumulator in which the latencies should be added (caller must set it to 0) + */ + 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 void getOneLinkRoutes(std::vector * accumulator); + /* returns whether we found a bypass path */ + bool getBypassRoute(routing::NetCard * src, routing::NetCard * dst, + /* OUT */ std::vector * links, double* latency); - virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)=0; - static void getRouteRecursive(routing::NetCard * src, routing::NetCard * dst, - /* OUT */ std::vector * links, double* latency); + virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) = 0; + static void getRouteRecursive(routing::NetCard * src, routing::NetCard * dst, + /* OUT */ std::vector * links, double* latency); - enum class RoutingMode { - unset = 0, /**< Undefined type */ - base, /**< Base case: use simple link lists for routing */ - recursive /**< Recursive case: also return gateway information */ - }; - /* FIXME: protect the following fields once the construction madness is sorted out */ - RoutingMode hierarchy_ = RoutingMode::unset; - routing::NetCard *netcard_ = nullptr; // Our representative in the father AS + enum class RoutingMode { + unset = 0, /**< Undefined type */ + base, /**< Base case: use simple link lists for routing */ + recursive /**< Recursive case: also return gateway information */ + }; + /* FIXME: protect the following fields once the construction madness is sorted out */ + RoutingMode hierarchy_ = RoutingMode::unset; + routing::NetCard* netcard_ = nullptr; // Our representative in the father AS }; }}}; // Namespace simgrid::kernel::routing diff --git a/src/kernel/routing/AsRoutedGraph.cpp b/src/kernel/routing/AsRoutedGraph.cpp index b45087ff7f..592ad3c46d 100644 --- a/src/kernel/routing/AsRoutedGraph.cpp +++ b/src/kernel/routing/AsRoutedGraph.cpp @@ -81,7 +81,7 @@ namespace simgrid { namespace kernel { namespace routing { -void AsRoutedGraph::getOneLinkRoutes(xbt_dynar_t accumulator) +void AsRoutedGraph::getOneLinkRoutes(std::vector* accumulator) { sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1); route->link_list = new std::vector(); @@ -103,7 +103,7 @@ void AsRoutedGraph::getOneLinkRoutes(xbt_dynar_t accumulator) onelink = new Onelink(link, route->gw_src, route->gw_dst); else onelink = new Onelink(link, nullptr, nullptr); - xbt_dynar_push(accumulator, &onelink); + accumulator->push_back(onelink); } } } diff --git a/src/kernel/routing/AsRoutedGraph.hpp b/src/kernel/routing/AsRoutedGraph.hpp index 7dd239c0ea..b4f5d1f4a5 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; - void getOneLinkRoutes(xbt_dynar_t accumulator) override; + void getOneLinkRoutes(std::vector* 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/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index 21325c2e7e..1acad86da7 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -107,14 +107,12 @@ static void create_ns3_topology(void) xbt_dynar_shrink(IPV4addr,0); //get the onelinks from the parsed platform - xbt_dynar_t onelink_routes = routing_platf->getOneLinkRoutes(); + std::vector* onelink_routes = routing_platf->getOneLinkRoutes(); std::unordered_set already_seen = std::unordered_set(); - XBT_DEBUG("There is %ld one-link routes",onelink_routes->used); - simgrid::kernel::routing::Onelink *onelink; - unsigned int iter; - xbt_dynar_foreach(onelink_routes, iter, onelink) { + XBT_DEBUG("There is %ld one-link routes", onelink_routes->size()); + for (simgrid::kernel::routing::Onelink* onelink : *onelink_routes) { const char* src = onelink->src_->name().c_str(); const char* dst = onelink->dst_->name().c_str(); simgrid::surf::LinkNS3 *link = static_cast(onelink->link_); diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index 596ccee010..b1b6a12342 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -100,7 +100,7 @@ void RoutingPlatf::getRouteAndLatency(NetCard *src, NetCard *dst, std::vector
  • * accumulator) { //adding my one link routes as->getOneLinkRoutes(accumulator); @@ -114,8 +114,9 @@ static void _recursiveGetOneLinkRoutes(AsImpl* as, xbt_dynar_t accumulator) } } -xbt_dynar_t RoutingPlatf::getOneLinkRoutes(){ - xbt_dynar_t res = xbt_dynar_new(sizeof(Onelink*), xbt_free_f); +std::vector* RoutingPlatf::getOneLinkRoutes() +{ + std::vector* res = new std::vector(); _recursiveGetOneLinkRoutes(root_, res); return res; } diff --git a/src/surf/surf_routing.hpp b/src/surf/surf_routing.hpp index 926f1a669e..cd1db49b61 100644 --- a/src/surf/surf_routing.hpp +++ b/src/surf/surf_routing.hpp @@ -108,7 +108,7 @@ public: explicit RoutingPlatf(); ~RoutingPlatf(); AsImpl *root_ = nullptr; - xbt_dynar_t getOneLinkRoutes(); + std::vector* getOneLinkRoutes(); void getRouteAndLatency(NetCard *src, NetCard *dst, std::vector * links, double *latency); }; -- 2.20.1