From 28f758f3ac685281f048a22a99405f48163be169 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 19 Dec 2017 17:46:22 +0100 Subject: [PATCH] don't load a private header from s4u/NetZone.hpp The later is a public header, that our users can load. --- include/simgrid/s4u/NetZone.hpp | 15 +++++-- src/instr/jedule/jedule_platform.cpp | 1 + src/kernel/routing/DijkstraZone.cpp | 32 +++++++------- src/kernel/routing/DijkstraZone.hpp | 3 +- src/kernel/routing/FloydZone.cpp | 65 +++++++++++++++------------- src/kernel/routing/FloydZone.hpp | 4 +- src/kernel/routing/FullZone.cpp | 34 ++++++++------- src/kernel/routing/FullZone.hpp | 4 +- src/kernel/routing/NetZoneImpl.cpp | 37 ++++++++-------- src/kernel/routing/NetZoneImpl.hpp | 4 +- src/kernel/routing/RoutedZone.cpp | 50 ++++++++++----------- src/kernel/routing/RoutedZone.hpp | 9 ++-- src/s4u/s4u_netzone.cpp | 3 +- src/surf/sg_platf.cpp | 6 ++- 14 files changed, 145 insertions(+), 122 deletions(-) diff --git a/include/simgrid/s4u/NetZone.hpp b/include/simgrid/s4u/NetZone.hpp index 8e7429c505..a226bfa129 100644 --- a/include/simgrid/s4u/NetZone.hpp +++ b/include/simgrid/s4u/NetZone.hpp @@ -13,16 +13,19 @@ #include #include +#include #include -#include "src/surf/xml/platf_private.hpp" // FIXME: kill sg_platf_route_cbarg_t to remove that UGLY include - namespace simgrid { namespace kernel { namespace routing { class NetZoneImpl; +class NetPoint; +} } +namespace surf { +class LinkImpl; } namespace s4u { @@ -62,8 +65,12 @@ public: /* Add content to the netzone, at parsing time. It should be sealed afterward. */ virtual int addComponent(kernel::routing::NetPoint * elm); /* A host, a router or a netzone, whatever */ - virtual void addRoute(sg_platf_route_cbarg_t route); - virtual void addBypassRoute(sg_platf_route_cbarg_t e_route) = 0; + virtual void addRoute(kernel::routing::NetPoint * src, kernel::routing::NetPoint * dst, + kernel::routing::NetPoint * gw_src, kernel::routing::NetPoint * gw_dst, + std::vector & link_list, bool symmetrical); + virtual void addBypassRoute(kernel::routing::NetPoint * src, kernel::routing::NetPoint * dst, + kernel::routing::NetPoint * gw_src, kernel::routing::NetPoint * gw_dst, + std::vector & link_list, bool symmetrical) = 0; /*** Called on each newly created regular route (not on bypass routes) */ static simgrid::xbt::signal diff --git a/src/kernel/routing/DijkstraZone.cpp b/src/kernel/routing/DijkstraZone.cpp index 85dfd1a640..5fe8bd7f04 100644 --- a/src/kernel/routing/DijkstraZone.cpp +++ b/src/kernel/routing/DijkstraZone.cpp @@ -270,14 +270,14 @@ DijkstraZone::DijkstraZone(NetZone* father, std::string name, bool cached) : Rou { } -void DijkstraZone::addRoute(sg_platf_route_cbarg_t route) +void DijkstraZone::addRoute(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, + kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst, + std::vector& link_list, bool symmetrical) { - NetPoint* src = route->src; - NetPoint* dst = route->dst; const char* srcName = src->getCname(); const char* dstName = dst->getCname(); - addRouteCheckParams(route); + addRouteCheckParams(src, dst, gw_src, gw_dst, link_list, symmetrical); /* Create the topology graph */ if (not routeGraph_) @@ -287,35 +287,35 @@ void DijkstraZone::addRoute(sg_platf_route_cbarg_t route) * nodes */ /* Add the route to the base */ - sg_platf_route_cbarg_t e_route = newExtendedRoute(hierarchy_, route, 1); + sg_platf_route_cbarg_t e_route = newExtendedRoute(hierarchy_, src, dst, gw_src, gw_dst, link_list, symmetrical, 1); newRoute(src->id(), dst->id(), e_route); // Symmetrical YES - if (route->symmetrical == true) { + if (symmetrical == true) { xbt_dynar_t nodes = xbt_graph_get_nodes(routeGraph_); xbt_node_t node_s_v = xbt_dynar_get_as(nodes, src->id(), xbt_node_t); xbt_node_t node_e_v = xbt_dynar_get_as(nodes, dst->id(), xbt_node_t); xbt_edge_t edge = xbt_graph_get_edge(routeGraph_, node_e_v, node_s_v); - if (not route->gw_dst || not route->gw_src){ + if (not gw_dst || not gw_src) { XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dstName, srcName); if (edge) THROWF(arg_error, 0, "Route from %s to %s already exists", dstName, srcName); } else { - XBT_DEBUG("Load NetzoneRoute from %s@%s to %s@%s", dstName, route->gw_dst->getCname(), srcName, - route->gw_src->getCname()); + XBT_DEBUG("Load NetzoneRoute from %s@%s to %s@%s", dstName, gw_dst->getCname(), srcName, gw_src->getCname()); if (edge) - THROWF(arg_error, 0, "Route from %s@%s to %s@%s already exists", dstName, route->gw_dst->getCname(), srcName, - route->gw_src->getCname()); + THROWF(arg_error, 0, "Route from %s@%s to %s@%s already exists", dstName, gw_dst->getCname(), srcName, + gw_src->getCname()); } - if (route->gw_dst && route->gw_src) { - NetPoint* gw_tmp = route->gw_src; - route->gw_src = route->gw_dst; - route->gw_dst = gw_tmp; + if (gw_dst && gw_src) { + NetPoint* gw_tmp = gw_src; + gw_src = gw_dst; + gw_dst = gw_tmp; } - sg_platf_route_cbarg_t link_route_back = newExtendedRoute(hierarchy_, route, 0); + sg_platf_route_cbarg_t link_route_back = + newExtendedRoute(hierarchy_, src, dst, gw_src, gw_dst, link_list, symmetrical, 0); newRoute(dst->id(), src->id(), link_route_back); } } diff --git a/src/kernel/routing/DijkstraZone.hpp b/src/kernel/routing/DijkstraZone.hpp index f7fc503c5e..0f7f10d24c 100644 --- a/src/kernel/routing/DijkstraZone.hpp +++ b/src/kernel/routing/DijkstraZone.hpp @@ -51,7 +51,8 @@ public: * will have a loopback attached to it. */ void getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t route, double* lat) override; - void addRoute(sg_platf_route_cbarg_t route) override; + void addRoute(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, + std::vector& link_list, bool symmetrical) override; xbt_graph_t routeGraph_ = nullptr; /* xbt_graph */ std::map graphNodeMap_; /* map */ diff --git a/src/kernel/routing/FloydZone.cpp b/src/kernel/routing/FloydZone.cpp index 354f13d761..9eca6d6fdc 100644 --- a/src/kernel/routing/FloydZone.cpp +++ b/src/kernel/routing/FloydZone.cpp @@ -84,12 +84,14 @@ void FloydZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg } } -void FloydZone::addRoute(sg_platf_route_cbarg_t route) +void FloydZone::addRoute(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, + kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst, + std::vector& link_list, bool symmetrical) { /* set the size of table routing */ unsigned int table_size = getTableSize(); - addRouteCheckParams(route); + addRouteCheckParams(src, dst, gw_src, gw_dst, link_list, symmetrical); if (not linkTable_) { /* Create Cost, Predecessor and Link tables */ @@ -107,47 +109,48 @@ void FloydZone::addRoute(sg_platf_route_cbarg_t route) } /* Check that the route does not already exist */ - if (route->gw_dst) // netzone route (to adapt the error message, if any) - xbt_assert(nullptr == TO_FLOYD_LINK(route->src->id(), route->dst->id()), + if (gw_dst) // netzone route (to adapt the error message, if any) + xbt_assert(nullptr == TO_FLOYD_LINK(src->id(), dst->id()), "The route between %s@%s and %s@%s already exists (Rq: routes are symmetrical by default).", - route->src->getCname(), route->gw_src->getCname(), route->dst->getCname(), route->gw_dst->getCname()); + src->getCname(), gw_src->getCname(), dst->getCname(), gw_dst->getCname()); else - xbt_assert(nullptr == TO_FLOYD_LINK(route->src->id(), route->dst->id()), - "The route between %s and %s already exists (Rq: routes are symmetrical by default).", - route->src->getCname(), route->dst->getCname()); + xbt_assert(nullptr == TO_FLOYD_LINK(src->id(), dst->id()), + "The route between %s and %s already exists (Rq: routes are symmetrical by default).", src->getCname(), + dst->getCname()); - TO_FLOYD_LINK(route->src->id(), route->dst->id()) = newExtendedRoute(hierarchy_, route, 1); - TO_FLOYD_PRED(route->src->id(), route->dst->id()) = route->src->id(); - TO_FLOYD_COST(route->src->id(), route->dst->id()) = - (TO_FLOYD_LINK(route->src->id(), route->dst->id()))->link_list.size(); + TO_FLOYD_LINK(src->id(), dst->id()) = + newExtendedRoute(hierarchy_, src, dst, gw_src, gw_dst, link_list, symmetrical, 1); + TO_FLOYD_PRED(src->id(), dst->id()) = src->id(); + TO_FLOYD_COST(src->id(), dst->id()) = (TO_FLOYD_LINK(src->id(), dst->id()))->link_list.size(); - if (route->symmetrical == true) { - if (route->gw_dst) // netzone route (to adapt the error message, if any) + if (symmetrical == true) { + if (gw_dst) // netzone route (to adapt the error message, if any) xbt_assert( - nullptr == TO_FLOYD_LINK(route->dst->id(), route->src->id()), + nullptr == TO_FLOYD_LINK(dst->id(), src->id()), "The route between %s@%s and %s@%s already exists. You should not declare the reverse path as symmetrical.", - route->dst->getCname(), route->gw_dst->getCname(), route->src->getCname(), route->gw_src->getCname()); + dst->getCname(), gw_dst->getCname(), src->getCname(), gw_src->getCname()); else - xbt_assert(nullptr == TO_FLOYD_LINK(route->dst->id(), route->src->id()), + xbt_assert(nullptr == TO_FLOYD_LINK(dst->id(), src->id()), "The route between %s and %s already exists. You should not declare the reverse path as symmetrical.", - route->dst->getCname(), route->src->getCname()); + dst->getCname(), src->getCname()); - if (route->gw_dst && route->gw_src) { - NetPoint* gw_tmp = route->gw_src; - route->gw_src = route->gw_dst; - route->gw_dst = gw_tmp; + if (gw_dst && gw_src) { + NetPoint* gw_tmp = gw_src; + gw_src = gw_dst; + gw_dst = gw_tmp; } - if (not route->gw_src || not route->gw_dst) - XBT_DEBUG("Load Route from \"%s\" to \"%s\"", route->dst->getCname(), route->src->getCname()); + if (not gw_src || not gw_dst) + XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dst->getCname(), src->getCname()); else - XBT_DEBUG("Load NetzoneRoute from \"%s(%s)\" to \"%s(%s)\"", route->dst->getCname(), route->gw_src->getCname(), - route->src->getCname(), route->gw_dst->getCname()); - - TO_FLOYD_LINK(route->dst->id(), route->src->id()) = newExtendedRoute(hierarchy_, route, 0); - TO_FLOYD_PRED(route->dst->id(), route->src->id()) = route->dst->id(); - TO_FLOYD_COST(route->dst->id(), route->src->id()) = - (TO_FLOYD_LINK(route->dst->id(), route->src->id()))->link_list.size(); /* count of links, old model assume 1 */ + XBT_DEBUG("Load NetzoneRoute from \"%s(%s)\" to \"%s(%s)\"", dst->getCname(), gw_src->getCname(), src->getCname(), + gw_dst->getCname()); + + TO_FLOYD_LINK(dst->id(), src->id()) = + newExtendedRoute(hierarchy_, src, dst, gw_src, gw_dst, link_list, symmetrical, 0); + TO_FLOYD_PRED(dst->id(), src->id()) = dst->id(); + TO_FLOYD_COST(dst->id(), src->id()) = + (TO_FLOYD_LINK(dst->id(), src->id()))->link_list.size(); /* count of links, old model assume 1 */ } } diff --git a/src/kernel/routing/FloydZone.hpp b/src/kernel/routing/FloydZone.hpp index a612425422..69ead53607 100644 --- a/src/kernel/routing/FloydZone.hpp +++ b/src/kernel/routing/FloydZone.hpp @@ -27,7 +27,9 @@ public: ~FloydZone() override; void getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t into, double* latency) override; - void addRoute(sg_platf_route_cbarg_t route) override; + void addRoute(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src, + kernel::routing::NetPoint* gw_dst, std::vector& link_list, + bool symmetrical) override; void seal() override; private: diff --git a/src/kernel/routing/FullZone.cpp b/src/kernel/routing/FullZone.cpp index a05458a3f0..bedc0cfcf6 100644 --- a/src/kernel/routing/FullZone.cpp +++ b/src/kernel/routing/FullZone.cpp @@ -71,11 +71,11 @@ void FullZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_ } } -void FullZone::addRoute(sg_platf_route_cbarg_t route) +void FullZone::addRoute(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, + kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst, + std::vector& link_list, bool symmetrical) { - NetPoint* src = route->src; - NetPoint* dst = route->dst; - addRouteCheckParams(route); + addRouteCheckParams(src, dst, gw_src, gw_dst, link_list, symmetrical); unsigned int table_size = getTableSize(); @@ -83,35 +83,37 @@ void FullZone::addRoute(sg_platf_route_cbarg_t route) routingTable_ = new sg_platf_route_cbarg_t[table_size * table_size](); /* Check that the route does not already exist */ - if (route->gw_dst) // inter-zone route (to adapt the error message, if any) + if (gw_dst) // inter-zone route (to adapt the error message, if any) xbt_assert(nullptr == TO_ROUTE_FULL(src->id(), dst->id()), "The route between %s@%s and %s@%s already exists (Rq: routes are symmetrical by default).", - src->getCname(), route->gw_src->getCname(), dst->getCname(), route->gw_dst->getCname()); + src->getCname(), gw_src->getCname(), dst->getCname(), gw_dst->getCname()); else xbt_assert(nullptr == TO_ROUTE_FULL(src->id(), dst->id()), "The route between %s and %s already exists (Rq: routes are symmetrical by default).", src->getCname(), dst->getCname()); /* Add the route to the base */ - TO_ROUTE_FULL(src->id(), dst->id()) = newExtendedRoute(hierarchy_, route, true); - - if (route->symmetrical == true && src != dst) { - if (route->gw_dst && route->gw_src) { - NetPoint* gw_tmp = route->gw_src; - route->gw_src = route->gw_dst; - route->gw_dst = gw_tmp; + TO_ROUTE_FULL(src->id(), dst->id()) = + newExtendedRoute(hierarchy_, src, dst, gw_src, gw_dst, link_list, symmetrical, true); + + if (symmetrical == true && src != dst) { + if (gw_dst && gw_src) { + NetPoint* gw_tmp = gw_src; + gw_src = gw_dst; + gw_dst = gw_tmp; } - if (route->gw_dst && route->gw_src) // inter-zone route (to adapt the error message, if any) + if (gw_dst && gw_src) // inter-zone route (to adapt the error message, if any) xbt_assert( nullptr == TO_ROUTE_FULL(dst->id(), src->id()), "The route between %s@%s and %s@%s already exists. You should not declare the reverse path as symmetrical.", - dst->getCname(), route->gw_dst->getCname(), src->getCname(), route->gw_src->getCname()); + dst->getCname(), gw_dst->getCname(), src->getCname(), gw_src->getCname()); else xbt_assert(nullptr == TO_ROUTE_FULL(dst->id(), src->id()), "The route between %s and %s already exists. You should not declare the reverse path as symmetrical.", dst->getCname(), src->getCname()); - TO_ROUTE_FULL(dst->id(), src->id()) = newExtendedRoute(hierarchy_, route, false); + TO_ROUTE_FULL(dst->id(), src->id()) = + newExtendedRoute(hierarchy_, src, dst, gw_src, gw_dst, link_list, symmetrical, false); } } } diff --git a/src/kernel/routing/FullZone.hpp b/src/kernel/routing/FullZone.hpp index ab13bc5bb4..d40709dd15 100644 --- a/src/kernel/routing/FullZone.hpp +++ b/src/kernel/routing/FullZone.hpp @@ -25,7 +25,9 @@ public: ~FullZone() override; void getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t into, double* latency) override; - void addRoute(sg_platf_route_cbarg_t route) override; + void addRoute(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src, + kernel::routing::NetPoint* gw_dst, std::vector& link_list, + bool symmetrical) override; sg_platf_route_cbarg_t* routingTable_ = nullptr; }; diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index 08b74dfc9e..309469509f 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -64,34 +64,33 @@ simgrid::s4u::Host* NetZoneImpl::createHost(const char* name, std::vector& link_list, bool symmetrical) { /* Argument validity checks */ - if (e_route->gw_dst) { - XBT_DEBUG("Load bypassNetzoneRoute from %s@%s to %s@%s", e_route->src->getCname(), e_route->gw_src->getCname(), - e_route->dst->getCname(), e_route->gw_dst->getCname()); - xbt_assert(not e_route->link_list.empty(), "Bypass route between %s@%s and %s@%s cannot be empty.", - e_route->src->getCname(), e_route->gw_src->getCname(), e_route->dst->getCname(), - e_route->gw_dst->getCname()); - xbt_assert(bypassRoutes_.find({e_route->src, e_route->dst}) == bypassRoutes_.end(), - "The bypass route between %s@%s and %s@%s already exists.", e_route->src->getCname(), - e_route->gw_src->getCname(), e_route->dst->getCname(), e_route->gw_dst->getCname()); + if (gw_dst) { + XBT_DEBUG("Load bypassNetzoneRoute from %s@%s to %s@%s", src->getCname(), gw_src->getCname(), dst->getCname(), + gw_dst->getCname()); + xbt_assert(not link_list.empty(), "Bypass route between %s@%s and %s@%s cannot be empty.", src->getCname(), + gw_src->getCname(), dst->getCname(), gw_dst->getCname()); + xbt_assert(bypassRoutes_.find({src, dst}) == bypassRoutes_.end(), + "The bypass route between %s@%s and %s@%s already exists.", src->getCname(), gw_src->getCname(), + dst->getCname(), gw_dst->getCname()); } else { - XBT_DEBUG("Load bypassRoute from %s to %s", e_route->src->getCname(), e_route->dst->getCname()); - xbt_assert(not e_route->link_list.empty(), "Bypass route between %s and %s cannot be empty.", - e_route->src->getCname(), e_route->dst->getCname()); - xbt_assert(bypassRoutes_.find({e_route->src, e_route->dst}) == bypassRoutes_.end(), - "The bypass route between %s and %s already exists.", e_route->src->getCname(), - e_route->dst->getCname()); + XBT_DEBUG("Load bypassRoute from %s to %s", src->getCname(), dst->getCname()); + xbt_assert(not link_list.empty(), "Bypass route between %s and %s cannot be empty.", src->getCname(), + dst->getCname()); + xbt_assert(bypassRoutes_.find({src, dst}) == bypassRoutes_.end(), + "The bypass route between %s and %s already exists.", src->getCname(), dst->getCname()); } /* Build a copy that will be stored in the dict */ - kernel::routing::BypassRoute* newRoute = new kernel::routing::BypassRoute(e_route->gw_src, e_route->gw_dst); - for (auto const& link : e_route->link_list) + kernel::routing::BypassRoute* newRoute = new kernel::routing::BypassRoute(gw_src, gw_dst); + for (auto const& link : link_list) newRoute->links.push_back(link); /* Store it */ - bypassRoutes_.insert({{e_route->src, e_route->dst}, newRoute}); + bypassRoutes_.insert({{src, dst}, newRoute}); } /** @brief Get the common ancestor and its first children in each line leading to src and dst diff --git a/src/kernel/routing/NetZoneImpl.hpp b/src/kernel/routing/NetZoneImpl.hpp index c2d77382aa..4a3e5ec262 100644 --- a/src/kernel/routing/NetZoneImpl.hpp +++ b/src/kernel/routing/NetZoneImpl.hpp @@ -12,6 +12,7 @@ #include "simgrid/s4u/NetZone.hpp" #include "simgrid/s4u/forward.hpp" +#include "src/surf/xml/platf_private.hpp" // FIXME: kill sg_platf_route_cbarg_t to remove that UGLY include namespace simgrid { namespace kernel { @@ -61,7 +62,8 @@ public: simgrid::s4u::Host* createHost(const char* name, std::vector* speedPerPstate, int coreAmount, std::map* props); /** @brief Creates a new route in this NetZone */ - void addBypassRoute(sg_platf_route_cbarg_t e_route) override; + void addBypassRoute(NetPoint * src, NetPoint * dst, NetPoint * gw_src, NetPoint * gw_dst, + std::vector & link_list, bool symmetrical) override; protected: /** diff --git a/src/kernel/routing/RoutedZone.cpp b/src/kernel/routing/RoutedZone.cpp index dab2e4ed09..6d41cbc786 100644 --- a/src/kernel/routing/RoutedZone.cpp +++ b/src/kernel/routing/RoutedZone.cpp @@ -120,24 +120,24 @@ void RoutedZone::getGraph(xbt_graph_t graph, std::map* /* ************************************************************************** */ /* ************************* GENERIC AUX FUNCTIONS ************************** */ /* change a route containing link names into a route containing link entities */ -sg_platf_route_cbarg_t RoutedZone::newExtendedRoute(RoutingMode hierarchy, sg_platf_route_cbarg_t routearg, +sg_platf_route_cbarg_t RoutedZone::newExtendedRoute(RoutingMode hierarchy, NetPoint* src, NetPoint* dst, + NetPoint* gw_src, NetPoint* gw_dst, + std::vector& link_list, bool symmetrical, bool change_order) { - sg_platf_route_cbarg_t result; - - result = new s_sg_platf_route_cbarg_t; + sg_platf_route_cbarg_t result = new s_sg_platf_route_cbarg_t; xbt_assert(hierarchy == RoutingMode::base || hierarchy == RoutingMode::recursive, "The hierarchy of this netzone is neither BASIC nor RECURSIVE, I'm lost here."); if (hierarchy == RoutingMode::recursive) { - xbt_assert(routearg->gw_src && routearg->gw_dst, "nullptr is obviously a deficient gateway"); + xbt_assert(gw_src && gw_dst, "nullptr is obviously a deficient gateway"); - result->gw_src = routearg->gw_src; - result->gw_dst = routearg->gw_dst; + result->gw_src = gw_src; + result->gw_dst = gw_dst; } - for (auto const& link : routearg->link_list) { + for (auto const& link : link_list) { if (change_order) result->link_list.push_back(link); else @@ -164,18 +164,18 @@ void RoutedZone::getRouteCheckParams(NetPoint* src, NetPoint* dst) "%s@%s). Please report that bug.", src->getCname(), dst->getCname(), src_as->getCname(), dst_as->getCname(), getCname()); } -void RoutedZone::addRouteCheckParams(sg_platf_route_cbarg_t route) +void RoutedZone::addRouteCheckParams(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, + kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst, + std::vector& link_list, bool symmetrical) { - NetPoint* src = route->src; - NetPoint* dst = route->dst; const char* srcName = src->getCname(); const char* dstName = dst->getCname(); - if (not route->gw_dst || not route->gw_src) { + if (not gw_dst || not gw_src) { XBT_DEBUG("Load Route from \"%s\" to \"%s\"", srcName, dstName); xbt_assert(src, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, srcName); xbt_assert(dst, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, dstName); - xbt_assert(not route->link_list.empty(), "Empty route (between %s and %s) forbidden.", srcName, dstName); + xbt_assert(not link_list.empty(), "Empty route (between %s and %s) forbidden.", srcName, dstName); xbt_assert(not src->isNetZone(), "When defining a route, src cannot be a netzone such as '%s'. Did you meant to have an NetzoneRoute?", srcName); @@ -183,28 +183,26 @@ void RoutedZone::addRouteCheckParams(sg_platf_route_cbarg_t route) "When defining a route, dst cannot be a netzone such as '%s'. Did you meant to have an NetzoneRoute?", dstName); } else { - XBT_DEBUG("Load NetzoneRoute from %s@%s to %s@%s", srcName, route->gw_src->getCname(), dstName, - route->gw_dst->getCname()); + XBT_DEBUG("Load NetzoneRoute from %s@%s to %s@%s", srcName, gw_src->getCname(), dstName, gw_dst->getCname()); xbt_assert(src->isNetZone(), "When defining a NetzoneRoute, src must be a netzone but '%s' is not", srcName); xbt_assert(dst->isNetZone(), "When defining a NetzoneRoute, dst must be a netzone but '%s' is not", dstName); - xbt_assert(route->gw_src->isHost() || route->gw_src->isRouter(), + xbt_assert(gw_src->isHost() || gw_src->isRouter(), "When defining a NetzoneRoute, gw_src must be an host or a router but '%s' is not.", srcName); - xbt_assert(route->gw_dst->isHost() || route->gw_dst->isRouter(), + xbt_assert(gw_dst->isHost() || gw_dst->isRouter(), "When defining a NetzoneRoute, 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 NetzoneRoute from '%s' to itself", - route->gw_src->getCname()); + xbt_assert(gw_src != gw_dst, "Cannot define an NetzoneRoute from '%s' to itself", gw_src->getCname()); - xbt_assert(src, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName, route->gw_src->getCname(), - dstName, route->gw_dst->getCname(), srcName); - xbt_assert(dst, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName, route->gw_src->getCname(), - dstName, route->gw_dst->getCname(), dstName); - xbt_assert(not route->link_list.empty(), "Empty route (between %s@%s and %s@%s) forbidden.", srcName, - route->gw_src->getCname(), dstName, route->gw_dst->getCname()); + xbt_assert(src, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName, gw_src->getCname(), dstName, + gw_dst->getCname(), srcName); + xbt_assert(dst, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName, gw_src->getCname(), dstName, + gw_dst->getCname(), dstName); + xbt_assert(not link_list.empty(), "Empty route (between %s@%s and %s@%s) forbidden.", srcName, gw_src->getCname(), + dstName, gw_dst->getCname()); } - onRouteCreation(route->symmetrical, route->src, route->dst, route->gw_src, route->gw_dst, route->link_list); + onRouteCreation(symmetrical, src, dst, gw_src, gw_dst, link_list); } } } diff --git a/src/kernel/routing/RoutedZone.hpp b/src/kernel/routing/RoutedZone.hpp index 62ebe810f6..c1117fc413 100644 --- a/src/kernel/routing/RoutedZone.hpp +++ b/src/kernel/routing/RoutedZone.hpp @@ -54,12 +54,15 @@ public: void getGraph(xbt_graph_t graph, std::map* nodes, std::map* edges) override; - virtual sg_platf_route_cbarg_t newExtendedRoute(RoutingMode hierarchy, sg_platf_route_cbarg_t routearg, - bool change_order); + virtual sg_platf_route_cbarg_t newExtendedRoute(RoutingMode hierarchy, NetPoint* src, NetPoint* dst, NetPoint* gw_src, + NetPoint* gw_dst, std::vector& link_list, + bool symmetrical, bool change_order); protected: void getRouteCheckParams(NetPoint* src, NetPoint* dst); - void addRouteCheckParams(sg_platf_route_cbarg_t route); + void addRouteCheckParams(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, + kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst, + std::vector& link_list, bool symmetrical); }; } } diff --git a/src/s4u/s4u_netzone.cpp b/src/s4u/s4u_netzone.cpp index 52e401458b..7a6f5f2f1c 100644 --- a/src/s4u/s4u_netzone.cpp +++ b/src/s4u/s4u_netzone.cpp @@ -87,7 +87,8 @@ int NetZone::addComponent(kernel::routing::NetPoint* elm) return vertices_.size() - 1; // The rank of the newly created object } -void NetZone::addRoute(sg_platf_route_cbarg_t /*route*/) +void NetZone::addRoute(sg_netpoint_t /*src*/, sg_netpoint_t /*dst*/, sg_netpoint_t /*gw_src*/, sg_netpoint_t /*gw_dst*/, + std::vector& /*link_list*/, bool /*symmetrical*/) { xbt_die("NetZone '%s' does not accept new routes (wrong class).", name_.c_str()); } diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 81a15d0189..3b968a4f07 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -406,12 +406,14 @@ void sg_platf_new_mount(MountCreationArgs* mount) void sg_platf_new_route(sg_platf_route_cbarg_t route) { - routing_get_current()->addRoute(route); + routing_get_current()->addRoute(route->src, route->dst, route->gw_src, route->gw_dst, route->link_list, + route->symmetrical); } void sg_platf_new_bypassRoute(sg_platf_route_cbarg_t bypassRoute) { - routing_get_current()->addBypassRoute(bypassRoute); + routing_get_current()->addBypassRoute(bypassRoute->src, bypassRoute->dst, bypassRoute->gw_src, bypassRoute->gw_dst, + bypassRoute->link_list, bypassRoute->symmetrical); } void sg_platf_new_process(sg_platf_process_cbarg_t process) -- 2.20.1