From 737a256dd1d7adf4255c24729ae6069284049d2c Mon Sep 17 00:00:00 2001 From: SUTER Frederic Date: Mon, 3 May 2021 12:49:56 +0200 Subject: [PATCH] do not use RouteCreationArgs outside of XML parsing --- .../simgrid/kernel/routing/ClusterZone.hpp | 2 +- .../simgrid/kernel/routing/DijkstraZone.hpp | 4 +- .../simgrid/kernel/routing/DragonflyZone.hpp | 2 +- include/simgrid/kernel/routing/EmptyZone.hpp | 2 +- .../simgrid/kernel/routing/FatTreeZone.hpp | 2 +- include/simgrid/kernel/routing/FloydZone.hpp | 4 +- include/simgrid/kernel/routing/FullZone.hpp | 9 ++- .../simgrid/kernel/routing/NetZoneImpl.hpp | 16 +++++- include/simgrid/kernel/routing/RoutedZone.hpp | 8 +-- include/simgrid/kernel/routing/StarZone.hpp | 4 +- include/simgrid/kernel/routing/TorusZone.hpp | 2 +- .../simgrid/kernel/routing/VivaldiZone.hpp | 2 +- include/simgrid/kernel/routing/WifiZone.hpp | 2 +- src/kernel/routing/ClusterZone.cpp | 15 +++-- src/kernel/routing/DijkstraZone.cpp | 57 +++++++++---------- src/kernel/routing/DragonflyZone.cpp | 36 ++++++------ src/kernel/routing/FatTreeZone.cpp | 16 +++--- src/kernel/routing/FloydZone.cpp | 39 +++++++------ src/kernel/routing/FullZone.cpp | 19 +++---- src/kernel/routing/NetZoneImpl.cpp | 29 +++++----- src/kernel/routing/RoutedZone.cpp | 34 ++++++----- src/kernel/routing/StarZone.cpp | 27 +++++---- src/kernel/routing/StarZone_test.cpp | 47 ++++++++------- src/kernel/routing/TorusZone.cpp | 16 +++--- src/kernel/routing/VivaldiZone.cpp | 7 +-- src/kernel/routing/WifiZone.cpp | 7 +-- 26 files changed, 204 insertions(+), 204 deletions(-) diff --git a/include/simgrid/kernel/routing/ClusterZone.hpp b/include/simgrid/kernel/routing/ClusterZone.hpp index 2ce7210f09..5e4964e407 100644 --- a/include/simgrid/kernel/routing/ClusterZone.hpp +++ b/include/simgrid/kernel/routing/ClusterZone.hpp @@ -111,7 +111,7 @@ public: return private_links_.find(position) != private_links_.end(); } - void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override; + void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) override; void get_graph(const s_xbt_graph_t* graph, std::map>* nodes, std::map>* edges) override; diff --git a/include/simgrid/kernel/routing/DijkstraZone.hpp b/include/simgrid/kernel/routing/DijkstraZone.hpp index 16a435fd59..ec3992fc74 100644 --- a/include/simgrid/kernel/routing/DijkstraZone.hpp +++ b/include/simgrid/kernel/routing/DijkstraZone.hpp @@ -32,7 +32,7 @@ class XBT_PRIVATE DijkstraZone : public RoutedZone { xbt_node_t route_graph_new_node(int id); xbt_node_t node_map_search(int id); - void new_edge(int src_id, int dst_id, RouteCreationArgs* e_route); + void new_edge(int src_id, int dst_id, Route* e_route); void do_seal() override; public: @@ -49,7 +49,7 @@ public: * After this function returns, any node in the graph * will have a loopback attached to it. */ - void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat) override; + void get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* lat) override; void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, const std::vector& link_list, bool symmetrical) override; }; diff --git a/include/simgrid/kernel/routing/DragonflyZone.hpp b/include/simgrid/kernel/routing/DragonflyZone.hpp index 382c4d1823..fa5fa22b4f 100644 --- a/include/simgrid/kernel/routing/DragonflyZone.hpp +++ b/include/simgrid/kernel/routing/DragonflyZone.hpp @@ -68,7 +68,7 @@ public: }; explicit DragonflyZone(const std::string& name); - void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override; + void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) override; /** * @brief Parse topology parameters from string format * diff --git a/include/simgrid/kernel/routing/EmptyZone.hpp b/include/simgrid/kernel/routing/EmptyZone.hpp index 7f540139f1..4b9114c3f9 100644 --- a/include/simgrid/kernel/routing/EmptyZone.hpp +++ b/include/simgrid/kernel/routing/EmptyZone.hpp @@ -23,7 +23,7 @@ class XBT_PRIVATE EmptyZone : public NetZoneImpl { public: explicit EmptyZone(const std::string& name) : NetZoneImpl(name) {} - void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override + void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) override { /* There can't be route in an Empty zone */ } diff --git a/include/simgrid/kernel/routing/FatTreeZone.hpp b/include/simgrid/kernel/routing/FatTreeZone.hpp index dee249c22b..911f92aedc 100644 --- a/include/simgrid/kernel/routing/FatTreeZone.hpp +++ b/include/simgrid/kernel/routing/FatTreeZone.hpp @@ -135,7 +135,7 @@ public: FatTreeZone(const FatTreeZone&) = delete; FatTreeZone& operator=(const FatTreeZone&) = delete; ~FatTreeZone() override; - void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override; + void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) override; /** * @brief Parse the topology parameters from string format diff --git a/include/simgrid/kernel/routing/FloydZone.hpp b/include/simgrid/kernel/routing/FloydZone.hpp index 17ade54bec..f35bc19a2d 100644 --- a/include/simgrid/kernel/routing/FloydZone.hpp +++ b/include/simgrid/kernel/routing/FloydZone.hpp @@ -25,7 +25,7 @@ class XBT_PRIVATE FloydZone : public RoutedZone { /* vars to compute the Floyd algorithm. */ std::vector predecessor_table_; std::vector cost_table_; - std::vector link_table_; + std::vector link_table_; void init_tables(unsigned int table_size); void do_seal() override; @@ -36,7 +36,7 @@ public: FloydZone& operator=(const FloydZone&) = delete; ~FloydZone() override; - void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override; + void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) override; void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, const std::vector& link_list, bool symmetrical) override; }; diff --git a/include/simgrid/kernel/routing/FullZone.hpp b/include/simgrid/kernel/routing/FullZone.hpp index 13565c4579..4551451f67 100644 --- a/include/simgrid/kernel/routing/FullZone.hpp +++ b/include/simgrid/kernel/routing/FullZone.hpp @@ -19,19 +19,18 @@ namespace routing { * computational requirements, but also the highest memory requirements (both in platform file and in memory). */ class XBT_PRIVATE FullZone : public RoutedZone { + std::vector routing_table_; + void do_seal() override; + public: using RoutedZone::RoutedZone; FullZone(const FullZone&) = delete; FullZone& operator=(const FullZone) = delete; ~FullZone() override; - void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override; + void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) override; void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, const std::vector& link_list, bool symmetrical) override; - -private: - std::vector routing_table_; - void do_seal() override; }; } // namespace routing } // namespace kernel diff --git a/include/simgrid/kernel/routing/NetZoneImpl.hpp b/include/simgrid/kernel/routing/NetZoneImpl.hpp index f164487f55..94b474c67a 100644 --- a/include/simgrid/kernel/routing/NetZoneImpl.hpp +++ b/include/simgrid/kernel/routing/NetZoneImpl.hpp @@ -19,6 +19,20 @@ namespace simgrid { namespace kernel { namespace routing { +class Route { +public: + Route() = default; + explicit Route(NetPoint* src, NetPoint* dst, NetPoint* gwSrc, NetPoint* gwDst) + : src_(src), dst_(dst), gw_src_(gwSrc), gw_dst_(gwDst) + { + } + NetPoint* src_ = nullptr; + NetPoint* dst_ = nullptr; + NetPoint* gw_src_ = nullptr; + NetPoint* gw_dst_ = nullptr; + std::vector link_list_; +}; + class BypassRoute { public: explicit BypassRoute(NetPoint* gwSrc, NetPoint* gwDst) : gw_src(gwSrc), gw_dst(gwDst) {} @@ -85,7 +99,7 @@ protected: * @param into Container into which the traversed links and gateway information should be pushed * @param latency Accumulator in which the latencies should be added (caller must set it to 0) */ - virtual void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) = 0; + virtual void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) = 0; /** @brief retrieves the list of all routes of size 1 (of type src x dst x Link) */ /* returns whether we found a bypass path */ bool get_bypass_route(routing::NetPoint* src, routing::NetPoint* dst, diff --git a/include/simgrid/kernel/routing/RoutedZone.hpp b/include/simgrid/kernel/routing/RoutedZone.hpp index 6e061e28ad..3fcbd94c6e 100644 --- a/include/simgrid/kernel/routing/RoutedZone.hpp +++ b/include/simgrid/kernel/routing/RoutedZone.hpp @@ -15,7 +15,7 @@ namespace routing { /** @ingroup ROUTING_API * @brief NetZone with an explicit routing (abstract class) * - * This abstract class factorizes code between its subclasses: Full, Dijkstra and Floyd. + * This abstract class factors code between its subclasses: Full, Dijkstra and Floyd. * * * @@ -56,9 +56,9 @@ public: std::map>* edges) override; protected: - RouteCreationArgs* new_extended_route(RoutingMode hierarchy, NetPoint* gw_src, NetPoint* gw_dst, - const std::vector& link_list, bool preserve_order); - XBT_ATTRIB_DEPRECATED_v330("Please drop 2nd, 3rd and 7th parameters") virtual RouteCreationArgs* new_extended_route( + Route* new_extended_route(RoutingMode hierarchy, NetPoint* gw_src, NetPoint* gw_dst, + const std::vector& link_list, bool preserve_order); + XBT_ATTRIB_DEPRECATED_v330("Please drop 2nd, 3rd and 7th parameters") virtual Route* new_extended_route( RoutingMode hierarchy, NetPoint* /* src */, NetPoint* /* dst */, NetPoint* gw_src, NetPoint* gw_dst, std::vector& link_list, bool /* symmetrical */, bool preserve_order) { diff --git a/include/simgrid/kernel/routing/StarZone.hpp b/include/simgrid/kernel/routing/StarZone.hpp index 6ecabcadc5..b441706249 100644 --- a/include/simgrid/kernel/routing/StarZone.hpp +++ b/include/simgrid/kernel/routing/StarZone.hpp @@ -65,7 +65,7 @@ class StarZone : public NetZoneImpl { public: explicit StarZone(const std::string& name); - void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* latency) override; + void get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* latency) override; void get_graph(const s_xbt_graph_t* graph, std::map>* nodes, std::map>* edges) override; @@ -87,7 +87,7 @@ private: bool has_links_down() const { return links_down_set; } }; /** @brief Auxiliary method to add links to a route */ - void add_links_to_route(const std::vector& links, RouteCreationArgs* route, double* latency, + void add_links_to_route(const std::vector& links, Route* route, double* latency, std::unordered_set& added_links) const; /** @brief Auxiliary methods to check params received in add_route method */ void check_add_route_param(const NetPoint* src, const NetPoint* dst, const NetPoint* gw_src, const NetPoint* gw_dst, diff --git a/include/simgrid/kernel/routing/TorusZone.hpp b/include/simgrid/kernel/routing/TorusZone.hpp index ae6e6d980b..983a6bb04e 100644 --- a/include/simgrid/kernel/routing/TorusZone.hpp +++ b/include/simgrid/kernel/routing/TorusZone.hpp @@ -25,7 +25,7 @@ class XBT_PRIVATE TorusZone : public ClusterZone { public: using ClusterZone::ClusterZone; void create_links(int id, int rank, unsigned int position); - void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override; + void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) override; void set_topology(const std::vector& dimensions); /** @brief Convert topology parameters from string to vector of uint */ diff --git a/include/simgrid/kernel/routing/VivaldiZone.hpp b/include/simgrid/kernel/routing/VivaldiZone.hpp index cd0fc40de8..ffc6f2ed66 100644 --- a/include/simgrid/kernel/routing/VivaldiZone.hpp +++ b/include/simgrid/kernel/routing/VivaldiZone.hpp @@ -48,7 +48,7 @@ class XBT_PRIVATE VivaldiZone : public StarZone { public: using StarZone::StarZone; void set_peer_link(NetPoint* netpoint, double bw_in, double bw_out); - void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override; + void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) override; }; namespace vivaldi { diff --git a/include/simgrid/kernel/routing/WifiZone.hpp b/include/simgrid/kernel/routing/WifiZone.hpp index 1c45b4fb44..2eb9f76611 100644 --- a/include/simgrid/kernel/routing/WifiZone.hpp +++ b/include/simgrid/kernel/routing/WifiZone.hpp @@ -29,7 +29,7 @@ public: WifiZone(const WifiZone&) = delete; WifiZone& operator=(const WifiZone) = delete; - void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override; + void get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) override; s4u::Link* create_link(const std::string& name, const std::vector& bandwidths) override; NetPoint* get_access_point() const { return access_point_; } }; diff --git a/src/kernel/routing/ClusterZone.cpp b/src/kernel/routing/ClusterZone.cpp index eb2fccec26..43651e2aa2 100644 --- a/src/kernel/routing/ClusterZone.cpp +++ b/src/kernel/routing/ClusterZone.cpp @@ -7,7 +7,6 @@ #include "simgrid/kernel/routing/NetPoint.hpp" #include "simgrid/kernel/routing/RoutedZone.hpp" #include "src/surf/network_interface.hpp" -#include "src/surf/xml/platf_private.hpp" // FIXME: RouteCreationArgs and friends XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf"); @@ -47,7 +46,7 @@ void ClusterZone::add_private_link_at(unsigned int position, std::pairget_cname(), src->id(), dst->get_cname(), dst->id()); xbt_assert(not private_links_.empty(), @@ -58,7 +57,7 @@ void ClusterZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg XBT_WARN("Routing from a cluster private router to itself is meaningless"); } else { std::pair info = private_links_.at(node_pos(src->id())); - route->link_list.push_back(info.first); + route->link_list_.push_back(info.first); if (lat) *lat += info.first->get_latency(); } @@ -68,20 +67,20 @@ void ClusterZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg if (not src->is_router()) { // No private link for the private router if (has_limiter_) { // limiter for sender std::pair info = private_links_.at(node_pos_with_loopback(src->id())); - route->link_list.push_back(info.first); + route->link_list_.push_back(info.first); } std::pair info = private_links_.at(node_pos_with_loopback_limiter(src->id())); if (info.first) { // link up - route->link_list.push_back(info.first); + route->link_list_.push_back(info.first); if (lat) *lat += info.first->get_latency(); } } if (backbone_) { - route->link_list.push_back(backbone_); + route->link_list_.push_back(backbone_); if (lat) *lat += backbone_->get_latency(); } @@ -91,13 +90,13 @@ void ClusterZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg private_links_.at(node_pos_with_loopback_limiter(dst->id())); if (info.second) { // link down - route->link_list.push_back(info.second); + route->link_list_.push_back(info.second); if (lat) *lat += info.second->get_latency(); } if (has_limiter_) { // limiter for receiver info = private_links_.at(node_pos_with_loopback(dst->id())); - route->link_list.push_back(info.first); + route->link_list_.push_back(info.first); } } } diff --git a/src/kernel/routing/DijkstraZone.cpp b/src/kernel/routing/DijkstraZone.cpp index 6270976eae..30c7515c75 100644 --- a/src/kernel/routing/DijkstraZone.cpp +++ b/src/kernel/routing/DijkstraZone.cpp @@ -6,7 +6,6 @@ #include "simgrid/kernel/routing/DijkstraZone.hpp" #include "simgrid/kernel/routing/NetPoint.hpp" #include "src/surf/network_interface.hpp" -#include "src/surf/xml/platf_private.hpp" #include "surf/surf.hpp" #include "xbt/string.hpp" @@ -30,8 +29,8 @@ public: void DijkstraZone::route_graph_delete(xbt_graph_t g) { xbt_graph_free_graph( - g, [](void* n) { delete static_cast(n); }, - [](void* e) { delete static_cast(e); }, nullptr); + g, [](void* n) { delete static_cast(n); }, [](void* e) { delete static_cast(e); }, + nullptr); } void DijkstraZone::do_seal() @@ -53,8 +52,8 @@ void DijkstraZone::do_seal() } if (not found) { - auto* route = new simgrid::kernel::routing::RouteCreationArgs(); - route->link_list.push_back(get_network_model()->loopback_); + auto* route = new Route(); + route->link_list_.push_back(get_network_model()->loopback_); xbt_graph_new_edge(route_graph_.get(), node, node, route); } } @@ -85,7 +84,7 @@ xbt_node_t DijkstraZone::node_map_search(int id) /* Parsing */ -void DijkstraZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat) +void DijkstraZone::get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* lat) { get_route_check_params(src, dst); int src_id = src->id(); @@ -109,10 +108,10 @@ void DijkstraZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationAr if (edge == nullptr) throw std::invalid_argument(xbt::string_printf("No route from '%s' to '%s'", src->get_cname(), dst->get_cname())); - const RouteCreationArgs* e_route = static_cast(xbt_graph_edge_get_data(edge)); + const Route* e_route = static_cast(xbt_graph_edge_get_data(edge)); - for (auto const& link : e_route->link_list) { - route->link_list.insert(route->link_list.begin(), link); + for (auto const& link : e_route->link_list_) { + route->link_list_.insert(route->link_list_.begin(), link); if (lat) *lat += link->get_latency(); } @@ -154,8 +153,8 @@ void DijkstraZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationAr const s_xbt_node_t* u_node = xbt_graph_edge_get_target(edge); const GraphNodeData* data = static_cast(xbt_graph_node_get_data(u_node)); int u_id = data->graph_id_; - const RouteCreationArgs* tmp_e_route = static_cast(xbt_graph_edge_get_data(edge)); - int cost_v_u = tmp_e_route->link_list.size(); /* count of links, old model assume 1 */ + const Route* tmp_e_route = static_cast(xbt_graph_edge_get_data(edge)); + int cost_v_u = tmp_e_route->link_list_.size(); /* count of links, old model assume 1 */ if (cost_v_u + cost_arr[v_id] < cost_arr[u_id]) { pred_arr[u_id] = v_id; @@ -178,11 +177,11 @@ void DijkstraZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationAr if (edge == nullptr) throw std::invalid_argument(xbt::string_printf("No route from '%s' to '%s'", src->get_cname(), dst->get_cname())); - const RouteCreationArgs* e_route = static_cast(xbt_graph_edge_get_data(edge)); + const Route* e_route = static_cast(xbt_graph_edge_get_data(edge)); const NetPoint* prev_gw_src = gw_src; - gw_src = e_route->gw_src; - NetPoint* gw_dst = e_route->gw_dst; + gw_src = e_route->gw_src_; + NetPoint* gw_dst = e_route->gw_dst_; if (v == dst_node_id) first_gw = gw_dst; @@ -194,25 +193,25 @@ void DijkstraZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationAr NetPoint* gw_dst_net_elm = nullptr; NetPoint* prev_gw_src_net_elm = nullptr; get_global_route(gw_dst_net_elm, prev_gw_src_net_elm, e_route_as_to_as, nullptr); - auto pos = route->link_list.begin(); + auto pos = route->link_list_.begin(); for (auto const& link : e_route_as_to_as) { - route->link_list.insert(pos, link); + route->link_list_.insert(pos, link); if (lat) *lat += link->get_latency(); pos++; } } - for (auto const& link : e_route->link_list) { - route->link_list.insert(route->link_list.begin(), link); + for (auto const& link : e_route->link_list_) { + route->link_list_.insert(route->link_list_.begin(), link); if (lat) *lat += link->get_latency(); } } if (get_hierarchy() == RoutingMode::recursive) { - route->gw_src = gw_src; - route->gw_dst = first_gw; + route->gw_src_ = gw_src; + route->gw_dst_ = first_gw; } if (not cached_) @@ -220,17 +219,17 @@ void DijkstraZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationAr } void DijkstraZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, - const std::vector& link_list, bool symmetrical) + const std::vector& link_list_, bool symmetrical) { - add_route_check_params(src, dst, gw_src, gw_dst, link_list, symmetrical); + add_route_check_params(src, dst, gw_src, gw_dst, link_list_, symmetrical); - new_edge(src->id(), dst->id(), new_extended_route(get_hierarchy(), gw_src, gw_dst, link_list, true)); + new_edge(src->id(), dst->id(), new_extended_route(get_hierarchy(), gw_src, gw_dst, link_list_, true)); if (symmetrical) - new_edge(dst->id(), src->id(), new_extended_route(get_hierarchy(), gw_dst, gw_src, link_list, false)); + new_edge(dst->id(), src->id(), new_extended_route(get_hierarchy(), gw_dst, gw_src, link_list_, false)); } -void DijkstraZone::new_edge(int src_id, int dst_id, RouteCreationArgs* route) +void DijkstraZone::new_edge(int src_id, int dst_id, Route* route) { XBT_DEBUG("Create Route from '%d' to '%d'", src_id, dst_id); @@ -245,13 +244,13 @@ void DijkstraZone::new_edge(int src_id, int dst_id, RouteCreationArgs* route) // Make sure that this graph edge was not already added to the graph if (xbt_graph_get_edge(route_graph_.get(), src, dst) != nullptr) { - if (route->gw_dst == nullptr || route->gw_src == nullptr) + if (route->gw_dst_ == nullptr || route->gw_src_ == nullptr) throw std::invalid_argument( - xbt::string_printf("Route from %s to %s already exists", route->src->get_cname(), route->dst->get_cname())); + xbt::string_printf("Route from %s to %s already exists", route->src_->get_cname(), route->dst_->get_cname())); else throw std::invalid_argument(xbt::string_printf("Route from %s@%s to %s@%s already exists", - route->src->get_cname(), route->gw_src->get_cname(), - route->dst->get_cname(), route->gw_dst->get_cname())); + route->src_->get_cname(), route->gw_src_->get_cname(), + route->dst_->get_cname(), route->gw_dst_->get_cname())); } // Finally add it diff --git a/src/kernel/routing/DragonflyZone.cpp b/src/kernel/routing/DragonflyZone.cpp index bfaa43b533..bc7a8c1fb5 100644 --- a/src/kernel/routing/DragonflyZone.cpp +++ b/src/kernel/routing/DragonflyZone.cpp @@ -6,7 +6,6 @@ #include "simgrid/kernel/routing/DragonflyZone.hpp" #include "simgrid/kernel/routing/NetPoint.hpp" #include "src/surf/network_interface.hpp" -#include "src/surf/xml/platf_private.hpp" #include #include @@ -73,13 +72,12 @@ s4u::DragonflyParams DragonflyZone::parse_topo_parameters(const std::string& top boost::split(parameters, topo_parameters, boost::is_any_of(";")); if (parameters.size() != 4) - surf_parse_error( - "Dragonfly are defined by the number of groups, chassis per groups, blades per chassis, nodes per blade"); + xbt_die("Dragonfly are defined by the number of groups, chassis per groups, blades per chassis, nodes per blade"); // Blue network : number of groups, number of links between each group boost::split(tmp, parameters[0], boost::is_any_of(",")); if (tmp.size() != 2) - surf_parse_error("Dragonfly topologies are defined by 3 levels with 2 elements each, and one with one element"); + xbt_die("Dragonfly topologies are defined by 3 levels with 2 elements each, and one with one element"); unsigned int n_groups; try { @@ -98,7 +96,7 @@ s4u::DragonflyParams DragonflyZone::parse_topo_parameters(const std::string& top // Black network : number of chassis/group, number of links between each router on the black network boost::split(tmp, parameters[1], boost::is_any_of(",")); if (tmp.size() != 2) - surf_parse_error("Dragonfly topologies are defined by 3 levels with 2 elements each, and one with one element"); + xbt_die("Dragonfly topologies are defined by 3 levels with 2 elements each, and one with one element"); unsigned int n_chassis; try { @@ -117,7 +115,7 @@ s4u::DragonflyParams DragonflyZone::parse_topo_parameters(const std::string& top // Green network : number of blades/chassis, number of links between each router on the green network boost::split(tmp, parameters[2], boost::is_any_of(",")); if (tmp.size() != 2) - surf_parse_error("Dragonfly topologies are defined by 3 levels with 2 elements each, and one with one element"); + xbt_die("Dragonfly topologies are defined by 3 levels with 2 elements each, and one with one element"); unsigned int n_routers; try { @@ -267,7 +265,7 @@ void DragonflyZone::generate_links() } } -void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* latency) +void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* latency) { // Minimal routing version. // TODO : non-minimal random one, and adaptive ? @@ -281,7 +279,7 @@ void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationA if ((src->id() == dst->id()) && has_loopback()) { resource::LinkImpl* uplink = get_uplink_from(node_pos(src->id())); - route->link_list.push_back(uplink); + route->link_list_.push_back(uplink); if (latency) *latency += uplink->get_latency(); return; @@ -301,12 +299,12 @@ void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationA DragonflyRouter* currentRouter = myRouter; // node->router local link - route->link_list.push_back(myRouter->my_nodes_[myCoords.node * num_links_per_link_]); + route->link_list_.push_back(myRouter->my_nodes_[myCoords.node * num_links_per_link_]); if (latency) *latency += myRouter->my_nodes_[myCoords.node * num_links_per_link_]->get_latency(); if (has_limiter()) { // limiter for sender - route->link_list.push_back(get_uplink_from(node_pos_with_loopback(src->id()))); + route->link_list_.push_back(get_uplink_from(node_pos_with_loopback(src->id()))); } if (targetRouter != myRouter) { @@ -315,7 +313,7 @@ void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationA // go to the router of our group connected to this one. if (currentRouter->blade_ != targetCoords.group) { // go to the nth router in our chassis - route->link_list.push_back(currentRouter->green_links_[targetCoords.group]); + route->link_list_.push_back(currentRouter->green_links_[targetCoords.group]); if (latency) *latency += currentRouter->green_links_[targetCoords.group]->get_latency(); currentRouter = &routers_[myCoords.group * (num_chassis_per_group_ * num_blades_per_chassis_) + @@ -324,7 +322,7 @@ void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationA if (currentRouter->chassis_ != 0) { // go to the first chassis of our group - route->link_list.push_back(currentRouter->black_links_[0]); + route->link_list_.push_back(currentRouter->black_links_[0]); if (latency) *latency += currentRouter->black_links_[0]->get_latency(); currentRouter = @@ -332,7 +330,7 @@ void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationA } // go to destination group - the only optical hop - route->link_list.push_back(currentRouter->blue_link_); + route->link_list_.push_back(currentRouter->blue_link_); if (latency) *latency += currentRouter->blue_link_->get_latency(); currentRouter = @@ -341,7 +339,7 @@ void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationA // same group, but same blade ? if (targetRouter->blade_ != currentRouter->blade_) { - route->link_list.push_back(currentRouter->green_links_[targetCoords.blade]); + route->link_list_.push_back(currentRouter->green_links_[targetCoords.blade]); if (latency) *latency += currentRouter->green_links_[targetCoords.blade]->get_latency(); currentRouter = @@ -350,26 +348,26 @@ void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationA // same blade, but same chassis ? if (targetRouter->chassis_ != currentRouter->chassis_) { - route->link_list.push_back(currentRouter->black_links_[targetCoords.chassis]); + route->link_list_.push_back(currentRouter->black_links_[targetCoords.chassis]); if (latency) *latency += currentRouter->black_links_[targetCoords.chassis]->get_latency(); } } if (has_limiter()) { // limiter for receiver - route->link_list.push_back(get_downlink_to(node_pos_with_loopback(dst->id()))); + route->link_list_.push_back(get_downlink_to(node_pos_with_loopback(dst->id()))); } // router->node local link - route->link_list.push_back( + route->link_list_.push_back( targetRouter->my_nodes_[targetCoords.node * num_links_per_link_ + num_links_per_link_ - 1]); if (latency) *latency += targetRouter->my_nodes_[targetCoords.node * num_links_per_link_ + num_links_per_link_ - 1]->get_latency(); // set gateways (if any) - route->gw_src = get_gateway(src->id()); - route->gw_dst = get_gateway(dst->id()); + route->gw_src_ = get_gateway(src->id()); + route->gw_dst_ = get_gateway(dst->id()); } } // namespace routing } // namespace kernel diff --git a/src/kernel/routing/FatTreeZone.cpp b/src/kernel/routing/FatTreeZone.cpp index bac4382981..b7df0d1c0a 100644 --- a/src/kernel/routing/FatTreeZone.cpp +++ b/src/kernel/routing/FatTreeZone.cpp @@ -51,7 +51,7 @@ bool FatTreeZone::is_in_sub_tree(FatTreeNode* root, FatTreeNode* node) const return true; } -void FatTreeZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) +void FatTreeZone::get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency) { if (dst->is_router() || src->is_router()) return; @@ -72,7 +72,7 @@ void FatTreeZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg /* 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 && has_loopback()) { - into->link_list.push_back(source->loopback_); + into->link_list_.push_back(source->loopback_); if (latency) *latency += source->loopback_->get_latency(); return; @@ -89,13 +89,13 @@ void FatTreeZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg int k = this->num_parents_per_node_[currentNode->level]; d = d % k; - into->link_list.push_back(currentNode->parents[d]->up_link_); + into->link_list_.push_back(currentNode->parents[d]->up_link_); if (latency) *latency += currentNode->parents[d]->up_link_->get_latency(); if (currentNode->limiter_link_) - into->link_list.push_back(currentNode->limiter_link_); + into->link_list_.push_back(currentNode->limiter_link_); currentNode = currentNode->parents[d]->up_node_; } @@ -106,20 +106,20 @@ void FatTreeZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg while (currentNode != destination) { for (unsigned int i = 0; i < currentNode->children.size(); i++) { if (i % this->num_children_per_node_[currentNode->level - 1] == destination->label[currentNode->level - 1]) { - into->link_list.push_back(currentNode->children[i]->down_link_); + into->link_list_.push_back(currentNode->children[i]->down_link_); if (latency) *latency += currentNode->children[i]->down_link_->get_latency(); currentNode = currentNode->children[i]->down_node_; if (currentNode->limiter_link_) - into->link_list.push_back(currentNode->limiter_link_); + into->link_list_.push_back(currentNode->limiter_link_); XBT_DEBUG("%d(%u,%u) is accessible through %d(%u,%u)", destination->id, destination->level, destination->position, currentNode->id, currentNode->level, currentNode->position); } } } // set gateways (if any) - into->gw_src = get_gateway(src->id()); - into->gw_dst = get_gateway(dst->id()); + into->gw_src_ = get_gateway(src->id()); + into->gw_dst_ = get_gateway(dst->id()); } /* This function makes the assumption that parse_specific_arguments() and diff --git a/src/kernel/routing/FloydZone.cpp b/src/kernel/routing/FloydZone.cpp index 5e109f36d1..593810d92d 100644 --- a/src/kernel/routing/FloydZone.cpp +++ b/src/kernel/routing/FloydZone.cpp @@ -6,7 +6,6 @@ #include "simgrid/kernel/routing/FloydZone.hpp" #include "simgrid/kernel/routing/NetPoint.hpp" #include "src/surf/network_interface.hpp" -#include "src/surf/xml/platf_private.hpp" #include "surf/surf.hpp" #include "xbt/string.hpp" @@ -40,14 +39,14 @@ void FloydZone::init_tables(unsigned int table_size) } } -void FloydZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat) +void FloydZone::get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* lat) { unsigned int table_size = get_table_size(); get_route_check_params(src, dst); /* create a result route */ - std::vector route_stack; + std::vector route_stack; unsigned int cur = dst->id(); do { int pred = TO_FLOYD_PRED(src->id(), cur); @@ -58,37 +57,37 @@ void FloydZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* } while (cur != src->id()); if (get_hierarchy() == RoutingMode::recursive) { - route->gw_src = route_stack.back()->gw_src; - route->gw_dst = route_stack.front()->gw_dst; + route->gw_src_ = route_stack.back()->gw_src_; + route->gw_dst_ = route_stack.front()->gw_dst_; } NetPoint* prev_dst_gw = nullptr; while (not route_stack.empty()) { - const RouteCreationArgs* e_route = route_stack.back(); + const Route* e_route = route_stack.back(); route_stack.pop_back(); if (get_hierarchy() == RoutingMode::recursive && prev_dst_gw != nullptr && - prev_dst_gw->get_cname() != e_route->gw_src->get_cname()) { - get_global_route(prev_dst_gw, e_route->gw_src, route->link_list, lat); + prev_dst_gw->get_cname() != e_route->gw_src_->get_cname()) { + get_global_route(prev_dst_gw, e_route->gw_src_, route->link_list_, lat); } - for (auto const& link : e_route->link_list) { - route->link_list.push_back(link); + for (auto const& link : e_route->link_list_) { + route->link_list_.push_back(link); if (lat) *lat += link->get_latency(); } - prev_dst_gw = e_route->gw_dst; + prev_dst_gw = e_route->gw_dst_; } } void FloydZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, - const std::vector& link_list, bool symmetrical) + const std::vector& link_list_, bool symmetrical) { /* set the size of table routing */ unsigned int table_size = get_table_size(); init_tables(table_size); - add_route_check_params(src, dst, gw_src, gw_dst, link_list, symmetrical); + add_route_check_params(src, dst, gw_src, gw_dst, link_list_, symmetrical); /* Check that the route does not already exist */ if (gw_dst && gw_src) // netzone route (to adapt the error message, if any) @@ -100,9 +99,9 @@ void FloydZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoi "The route between %s and %s already exists (Rq: routes are symmetrical by default).", src->get_cname(), dst->get_cname()); - TO_FLOYD_LINK(src->id(), dst->id()) = new_extended_route(get_hierarchy(), gw_src, gw_dst, link_list, true); + TO_FLOYD_LINK(src->id(), dst->id()) = new_extended_route(get_hierarchy(), gw_src, gw_dst, link_list_, true); 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(); + TO_FLOYD_COST(src->id(), dst->id()) = (TO_FLOYD_LINK(src->id(), dst->id()))->link_list_.size(); if (symmetrical) { if (gw_dst && gw_src) // netzone route (to adapt the error message, if any) @@ -127,10 +126,10 @@ void FloydZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoi XBT_DEBUG("Load NetzoneRoute from \"%s(%s)\" to \"%s(%s)\"", dst->get_cname(), gw_src->get_cname(), src->get_cname(), gw_dst->get_cname()); - TO_FLOYD_LINK(dst->id(), src->id()) = new_extended_route(get_hierarchy(), gw_src, gw_dst, link_list, false); + TO_FLOYD_LINK(dst->id(), src->id()) = new_extended_route(get_hierarchy(), gw_src, gw_dst, link_list_, false); 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 */ + (TO_FLOYD_LINK(dst->id(), src->id()))->link_list_.size(); /* count of links, old model assume 1 */ } } @@ -143,10 +142,10 @@ void FloydZone::do_seal() /* Add the loopback if needed */ if (get_network_model()->loopback_ && get_hierarchy() == RoutingMode::base) { for (unsigned int i = 0; i < table_size; i++) { - RouteCreationArgs* route = TO_FLOYD_LINK(i, i); + Route* route = TO_FLOYD_LINK(i, i); if (not route) { - route = new RouteCreationArgs(); - route->link_list.push_back(get_network_model()->loopback_); + route = new Route(); + route->link_list_.push_back(get_network_model()->loopback_); TO_FLOYD_LINK(i, i) = route; TO_FLOYD_PRED(i, i) = i; TO_FLOYD_COST(i, i) = 1; diff --git a/src/kernel/routing/FullZone.cpp b/src/kernel/routing/FullZone.cpp index ab756c155b..3570508015 100644 --- a/src/kernel/routing/FullZone.cpp +++ b/src/kernel/routing/FullZone.cpp @@ -6,7 +6,6 @@ #include "simgrid/kernel/routing/FullZone.hpp" #include "simgrid/kernel/routing/NetPoint.hpp" #include "src/surf/network_interface.hpp" -#include "src/surf/xml/platf_private.hpp" #include "surf/surf.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_full, surf, "Routing part of surf"); @@ -28,10 +27,10 @@ void FullZone::do_seal() /* Add the loopback if needed */ if (get_network_model()->loopback_ && get_hierarchy() == RoutingMode::base) { for (unsigned int i = 0; i < table_size; i++) { - RouteCreationArgs* route = TO_ROUTE_FULL(i, i); + Route* route = TO_ROUTE_FULL(i, i); if (not route) { - route = new RouteCreationArgs(); - route->link_list.push_back(get_network_model()->loopback_); + route = new Route(); + route->link_list_.push_back(get_network_model()->loopback_); TO_ROUTE_FULL(i, i) = route; } } @@ -45,18 +44,18 @@ FullZone::~FullZone() delete route; } -void FullZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* res, double* lat) +void FullZone::get_local_route(NetPoint* src, NetPoint* dst, Route* res, double* lat) { XBT_DEBUG("full getLocalRoute from %s[%u] to %s[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id()); unsigned int table_size = get_table_size(); - const RouteCreationArgs* e_route = TO_ROUTE_FULL(src->id(), dst->id()); + const Route* e_route = TO_ROUTE_FULL(src->id(), dst->id()); if (e_route != nullptr) { - res->gw_src = e_route->gw_src; - res->gw_dst = e_route->gw_dst; - for (auto const& link : e_route->link_list) { - res->link_list.push_back(link); + res->gw_src_ = e_route->gw_src_; + res->gw_dst_ = e_route->gw_dst_; + for (auto const& link : e_route->link_list_) { + res->link_list_.push_back(link); if (lat) *lat += link->get_latency(); } diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index ca5ae92149..b9efafc840 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -13,7 +13,6 @@ #include "src/surf/HostImpl.hpp" #include "src/surf/cpu_interface.hpp" #include "src/surf/network_interface.hpp" -#include "src/surf/xml/platf_private.hpp" #include "surf/surf.hpp" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_route); @@ -176,26 +175,26 @@ int NetZoneImpl::add_component(NetPoint* elm) } void NetZoneImpl::add_route(NetPoint* /*src*/, NetPoint* /*dst*/, NetPoint* /*gw_src*/, NetPoint* /*gw_dst*/, - const std::vector& /*link_list*/, bool /*symmetrical*/) + const std::vector& /*link_list_*/, bool /*symmetrical*/) { xbt_die("NetZone '%s' does not accept new routes (wrong class).", get_cname()); } void NetZoneImpl::add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, - std::vector& link_list, bool /* symmetrical */) + std::vector& link_list_, bool /* symmetrical */) { /* Argument validity checks */ if (gw_dst) { XBT_DEBUG("Load bypassNetzoneRoute from %s@%s to %s@%s", src->get_cname(), gw_src->get_cname(), dst->get_cname(), gw_dst->get_cname()); - xbt_assert(not link_list.empty(), "Bypass route between %s@%s and %s@%s cannot be empty.", src->get_cname(), + xbt_assert(not link_list_.empty(), "Bypass route between %s@%s and %s@%s cannot be empty.", src->get_cname(), gw_src->get_cname(), dst->get_cname(), gw_dst->get_cname()); xbt_assert(bypass_routes_.find({src, dst}) == bypass_routes_.end(), "The bypass route between %s@%s and %s@%s already exists.", src->get_cname(), gw_src->get_cname(), dst->get_cname(), gw_dst->get_cname()); } else { XBT_DEBUG("Load bypassRoute from %s to %s", src->get_cname(), dst->get_cname()); - xbt_assert(not link_list.empty(), "Bypass route between %s and %s cannot be empty.", src->get_cname(), + xbt_assert(not link_list_.empty(), "Bypass route between %s and %s cannot be empty.", src->get_cname(), dst->get_cname()); xbt_assert(bypass_routes_.find({src, dst}) == bypass_routes_.end(), "The bypass route between %s and %s already exists.", src->get_cname(), dst->get_cname()); @@ -203,7 +202,7 @@ void NetZoneImpl::add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_sr /* Build a copy that will be stored in the dict */ auto* newRoute = new BypassRoute(gw_src, gw_dst); - for (auto const& link : link_list) + for (auto const& link : link_list_) newRoute->links.push_back(link); /* Store it */ @@ -415,7 +414,7 @@ bool NetZoneImpl::get_bypass_route(NetPoint* src, NetPoint* dst, void NetZoneImpl::get_global_route(NetPoint* src, NetPoint* dst, /* OUT */ std::vector& links, double* latency) { - RouteCreationArgs route; + Route route; XBT_DEBUG("Resolve route from '%s' to '%s'", src->get_cname(), dst->get_cname()); @@ -433,26 +432,26 @@ void NetZoneImpl::get_global_route(NetPoint* src, NetPoint* dst, /* If src and dst are in the same netzone, life is good */ if (src_ancestor == dst_ancestor) { /* SURF_ROUTING_BASE */ - route.link_list = std::move(links); + route.link_list_ = std::move(links); common_ancestor->get_local_route(src, dst, &route, latency); - links = std::move(route.link_list); + links = std::move(route.link_list_); return; } /* Not in the same netzone, no bypass. We'll have to find our path between the netzones recursively */ common_ancestor->get_local_route(src_ancestor->netpoint_, dst_ancestor->netpoint_, &route, latency); - xbt_assert((route.gw_src != nullptr) && (route.gw_dst != nullptr), "Bad gateways for route from '%s' to '%s'.", + xbt_assert((route.gw_src_ != nullptr) && (route.gw_dst_ != nullptr), "Bad gateways for route from '%s' to '%s'.", src->get_cname(), dst->get_cname()); /* If source gateway is not our source, we have to recursively find our way up to this point */ - if (src != route.gw_src) - get_global_route(src, route.gw_src, links, latency); - links.insert(links.end(), begin(route.link_list), end(route.link_list)); + if (src != route.gw_src_) + get_global_route(src, route.gw_src_, links, latency); + links.insert(links.end(), begin(route.link_list_), end(route.link_list_)); /* If dest gateway is not our destination, we have to recursively find our way from this point */ - if (route.gw_dst != dst) - get_global_route(route.gw_dst, dst, links, latency); + if (route.gw_dst_ != dst) + get_global_route(route.gw_dst_, dst, links, latency); } void NetZoneImpl::seal() diff --git a/src/kernel/routing/RoutedZone.cpp b/src/kernel/routing/RoutedZone.cpp index 4a07c1a847..8be4dfef2a 100644 --- a/src/kernel/routing/RoutedZone.cpp +++ b/src/kernel/routing/RoutedZone.cpp @@ -6,7 +6,6 @@ #include "simgrid/kernel/routing/RoutedZone.hpp" #include "simgrid/kernel/routing/NetPoint.hpp" #include "src/surf/network_interface.hpp" -#include "src/surf/xml/platf_private.hpp" #include "xbt/dict.h" #include "xbt/graph.h" #include "xbt/log.h" @@ -66,7 +65,7 @@ void RoutedZone::get_graph(const s_xbt_graph_t* graph, std::mapget_cname(), nodes); - previous_name = route.gw_src->get_cname(); + if (route.gw_src_) { + previous = new_xbt_graph_node(graph, route.gw_src_->get_cname(), nodes); + previous_name = route.gw_src_->get_cname(); } else { previous = new_xbt_graph_node(graph, my_src->get_cname(), nodes); previous_name = my_src->get_cname(); } - for (auto const& link : route.link_list) { + for (auto const& link : route.link_list_) { const char* link_name = link->get_cname(); current = new_xbt_graph_node(graph, link_name, nodes); current_name = link_name; @@ -95,9 +94,9 @@ void RoutedZone::get_graph(const s_xbt_graph_t* graph, std::mapget_cname(), nodes); - current_name = route.gw_dst->get_cname(); + if (route.gw_dst_) { + current = new_xbt_graph_node(graph, route.gw_dst_->get_cname(), nodes); + current_name = route.gw_dst_->get_cname(); } else { current = new_xbt_graph_node(graph, my_dst->get_cname(), nodes); current_name = my_dst->get_cname(); @@ -111,24 +110,23 @@ void RoutedZone::get_graph(const s_xbt_graph_t* graph, std::map& link_list, - bool preserve_order) +Route* RoutedZone::new_extended_route(RoutingMode hierarchy, NetPoint* gw_src, NetPoint* gw_dst, + const std::vector& link_list, bool preserve_order) { - auto* result = new RouteCreationArgs(); + auto* result = new Route(); if (hierarchy == RoutingMode::recursive) { xbt_assert(gw_src && gw_dst, "nullptr is obviously a deficient gateway"); - result->gw_src = gw_src; - result->gw_dst = gw_dst; + result->gw_src_ = gw_src; + result->gw_dst_ = gw_dst; } if (preserve_order) - result->link_list = link_list; + result->link_list_ = link_list; else - result->link_list.assign(link_list.rbegin(), link_list.rend()); // reversed - result->link_list.shrink_to_fit(); + result->link_list_.assign(link_list.rbegin(), link_list.rend()); // reversed + result->link_list_.shrink_to_fit(); return result; } diff --git a/src/kernel/routing/StarZone.cpp b/src/kernel/routing/StarZone.cpp index 72fb1e4499..ac88fd2fa6 100644 --- a/src/kernel/routing/StarZone.cpp +++ b/src/kernel/routing/StarZone.cpp @@ -7,7 +7,6 @@ #include "simgrid/kernel/routing/NetPoint.hpp" #include "simgrid/kernel/routing/RoutedZone.hpp" #include "src/surf/network_interface.hpp" -#include "src/surf/xml/platf_private.hpp" // RouteCreationArgs and friends #include "xbt/string.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_star, surf, "Routing part of surf"); @@ -17,20 +16,20 @@ namespace kernel { namespace routing { StarZone::StarZone(const std::string& name) : NetZoneImpl(name) {} -void StarZone::add_links_to_route(const std::vector& links, RouteCreationArgs* route, - double* latency, std::unordered_set& added_links) const +void StarZone::add_links_to_route(const std::vector& links, Route* route, double* latency, + std::unordered_set& added_links) const { for (auto* link : links) { - /* do not add duplicated links in route->link_list */ + /* do not add duplicated links in route->link_list_ */ if (not added_links.insert(link).second) continue; if (latency) *latency += link->get_latency(); - route->link_list.push_back(link); + route->link_list_.push_back(link); } } -void StarZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* latency) +void StarZone::get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* latency) { XBT_VERB("StarZone getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id()); @@ -57,8 +56,8 @@ void StarZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* /* going DOWN */ add_links_to_route(dst_route.links_down, route, latency, added_links); /* gateways */ - route->gw_src = src_route.gateway; - route->gw_dst = dst_route.gateway; + route->gw_src_ = src_route.gateway; + route->gw_dst_ = dst_route.gateway; } void StarZone::get_graph(const s_xbt_graph_t* graph, std::map>* nodes, @@ -126,32 +125,32 @@ void StarZone::check_add_route_param(const NetPoint* src, const NetPoint* dst, c } void StarZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, - const std::vector& link_list, bool symmetrical) + const std::vector& link_list_, bool symmetrical) { check_add_route_param(src, dst, gw_src, gw_dst, symmetrical); - s4u::NetZone::on_route_creation(symmetrical, gw_src, gw_dst, gw_src, gw_dst, link_list); + s4u::NetZone::on_route_creation(symmetrical, gw_src, gw_dst, gw_src, gw_dst, link_list_); /* loopback */ if (src == dst) { - routes_[src->id()].loopback = link_list; + routes_[src->id()].loopback = link_list_; } else { /* src to everyone */ if (src) { auto& route = routes_[src->id()]; - route.links_up = link_list; + route.links_up = link_list_; route.gateway = gw_src; route.links_up_set = true; if (symmetrical) { /* reverse it for down/symmetrical links */ - route.links_down.assign(link_list.rbegin(), link_list.rend()); + route.links_down.assign(link_list_.rbegin(), link_list_.rend()); route.links_down_set = true; } } /* dst to everyone */ if (dst) { auto& route = routes_[dst->id()]; - route.links_down = link_list; + route.links_down = link_list_; route.gateway = gw_dst; route.links_down_set = true; } diff --git a/src/kernel/routing/StarZone_test.cpp b/src/kernel/routing/StarZone_test.cpp index 8f57da121f..d9c5a98908 100644 --- a/src/kernel/routing/StarZone_test.cpp +++ b/src/kernel/routing/StarZone_test.cpp @@ -11,7 +11,6 @@ #include "simgrid/s4u/Host.hpp" #include "simgrid/s4u/NetZone.hpp" #include "src/surf/network_interface.hpp" -#include "src/surf/xml/platf_private.hpp" // RouteCreationArgs and friends namespace { class EngineWrapper { @@ -103,7 +102,7 @@ TEST_CASE("kernel::routing::StarZone: Get routes: assert", "[.][assert]") zone->add_route(host1->get_netpoint(), nullptr, nullptr, nullptr, links, true); zone->add_route(nullptr, host2->get_netpoint(), nullptr, nullptr, links2, false); double lat; - simgrid::kernel::routing::RouteCreationArgs route; + simgrid::kernel::routing::Route route; zone->get_local_route(host2->get_netpoint(), host1->get_netpoint(), &route, &lat); } @@ -112,7 +111,7 @@ TEST_CASE("kernel::routing::StarZone: Get routes: assert", "[.][assert]") zone->add_route(host1->get_netpoint(), nullptr, nullptr, nullptr, links, false); zone->add_route(host2->get_netpoint(), nullptr, nullptr, nullptr, links2, true); double lat; - simgrid::kernel::routing::RouteCreationArgs route; + simgrid::kernel::routing::Route route; zone->get_local_route(host2->get_netpoint(), host1->get_netpoint(), &route, &lat); } } @@ -172,14 +171,14 @@ TEST_CASE("kernel::routing::StarZone: Get routes (hosts)", "") zone->seal(); double lat = 0.0; - simgrid::kernel::routing::RouteCreationArgs route; + simgrid::kernel::routing::Route route; zone->get_local_route(host1->get_netpoint(), host2->get_netpoint(), &route, &lat); REQUIRE(lat == 30); - REQUIRE(route.gw_src == nullptr); - REQUIRE(route.gw_dst == nullptr); - REQUIRE(route.link_list.size() == 2); - REQUIRE(route.link_list[0]->get_name() == "link1"); - REQUIRE(route.link_list[1]->get_name() == "link2"); + REQUIRE(route.gw_src_ == nullptr); + REQUIRE(route.gw_dst_ == nullptr); + REQUIRE(route.link_list_.size() == 2); + REQUIRE(route.link_list_[0]->get_name() == "link1"); + REQUIRE(route.link_list_[1]->get_name() == "link2"); } SECTION("Get route: shared link(backbone)") @@ -197,13 +196,13 @@ TEST_CASE("kernel::routing::StarZone: Get routes (hosts)", "") zone->seal(); double lat = 0.0; - simgrid::kernel::routing::RouteCreationArgs route; + simgrid::kernel::routing::Route route; zone->get_local_route(host1->get_netpoint(), host2->get_netpoint(), &route, &lat); REQUIRE(lat == 130); - REQUIRE(route.link_list.size() == 3); - REQUIRE(route.link_list[0]->get_name() == "link1"); - REQUIRE(route.link_list[1]->get_name() == "backbone"); - REQUIRE(route.link_list[2]->get_name() == "link2"); + REQUIRE(route.link_list_.size() == 3); + REQUIRE(route.link_list_[0]->get_name() == "link1"); + REQUIRE(route.link_list_[1]->get_name() == "backbone"); + REQUIRE(route.link_list_[2]->get_name() == "link2"); } SECTION("Get route: loopback") @@ -217,12 +216,12 @@ TEST_CASE("kernel::routing::StarZone: Get routes (hosts)", "") zone->seal(); double lat = 0.0; - simgrid::kernel::routing::RouteCreationArgs route; + simgrid::kernel::routing::Route route; zone->get_local_route(host1->get_netpoint(), host1->get_netpoint(), &route, &lat); REQUIRE(lat == 110); - REQUIRE(route.link_list.size() == 2); - REQUIRE(route.link_list[0]->get_name() == "link1"); - REQUIRE(route.link_list[1]->get_name() == "backbone"); + REQUIRE(route.link_list_.size() == 2); + REQUIRE(route.link_list_[0]->get_name() == "link1"); + REQUIRE(route.link_list_[1]->get_name() == "backbone"); } } @@ -251,13 +250,13 @@ TEST_CASE("kernel::routing::StarZone: Get routes (netzones)", "") zone->seal(); double lat = 0.0; - simgrid::kernel::routing::RouteCreationArgs route; + simgrid::kernel::routing::Route route; zone->get_local_route(subzone1, subzone2, &route, &lat); REQUIRE(lat == 30); - REQUIRE(route.gw_src == router1); - REQUIRE(route.gw_dst == router2); - REQUIRE(route.link_list.size() == 2); - REQUIRE(route.link_list[0]->get_name() == "link1"); - REQUIRE(route.link_list[1]->get_name() == "link2"); + REQUIRE(route.gw_src_ == router1); + REQUIRE(route.gw_dst_ == router2); + REQUIRE(route.link_list_.size() == 2); + REQUIRE(route.link_list_[0]->get_name() == "link1"); + REQUIRE(route.link_list_[1]->get_name() == "link2"); } } diff --git a/src/kernel/routing/TorusZone.cpp b/src/kernel/routing/TorusZone.cpp index e1ad2dd25f..a9d371dfb3 100644 --- a/src/kernel/routing/TorusZone.cpp +++ b/src/kernel/routing/TorusZone.cpp @@ -7,7 +7,6 @@ #include "simgrid/kernel/routing/NetPoint.hpp" #include "simgrid/s4u/Host.hpp" #include "src/surf/network_interface.hpp" -#include "src/surf/xml/platf_private.hpp" #include #include @@ -70,7 +69,8 @@ std::vector TorusZone::parse_topo_parameters(const std::string& to * Parse attribute dimensions="dim1,dim2,dim3,...,dimN" and save them into a vector. * Additionally, we need to know how many ranks we have in total */ - std::transform(begin(dimensions_str), end(dimensions_str), std::back_inserter(dimensions), surf_parse_get_int); + std::transform(begin(dimensions_str), end(dimensions_str), std::back_inserter(dimensions), + [](const std::string& s) { return std::stoi(s); }); } return dimensions; } @@ -82,7 +82,7 @@ void TorusZone::set_topology(const std::vector& dimensions) set_num_links_per_node(dimensions_.size()); } -void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat) +void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* lat) { XBT_VERB("torus getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id()); @@ -92,7 +92,7 @@ void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* if (src->id() == dst->id() && has_loopback()) { resource::LinkImpl* uplink = get_uplink_from(node_pos(src->id())); - route->link_list.push_back(uplink); + route->link_list_.push_back(uplink); if (lat) *lat += uplink->get_latency(); return; @@ -168,7 +168,7 @@ void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* } if (has_limiter()) { // limiter for sender - route->link_list.push_back(get_uplink_from(node_pos_with_loopback(current_node))); + route->link_list_.push_back(get_uplink_from(node_pos_with_loopback(current_node))); } resource::LinkImpl* lnk; @@ -177,15 +177,15 @@ void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* else lnk = get_downlink_to(linkOffset); - route->link_list.push_back(lnk); + route->link_list_.push_back(lnk); if (lat) *lat += lnk->get_latency(); current_node = next_node; } // set gateways (if any) - route->gw_src = get_gateway(src->id()); - route->gw_dst = get_gateway(dst->id()); + route->gw_src_ = get_gateway(src->id()); + route->gw_dst_ = get_gateway(dst->id()); } } // namespace routing diff --git a/src/kernel/routing/VivaldiZone.cpp b/src/kernel/routing/VivaldiZone.cpp index cb9beb4198..eceb3f7ae5 100644 --- a/src/kernel/routing/VivaldiZone.cpp +++ b/src/kernel/routing/VivaldiZone.cpp @@ -8,7 +8,6 @@ #include "simgrid/s4u/Engine.hpp" #include "simgrid/s4u/Host.hpp" #include "src/surf/network_interface.hpp" -#include "src/surf/xml/platf_private.hpp" #include "surf/surf.hpp" #include @@ -71,15 +70,15 @@ void VivaldiZone::set_peer_link(NetPoint* netpoint, double bw_in, double bw_out) add_route(nullptr, netpoint, nullptr, nullptr, {linkDown->get_impl()}, false); } -void VivaldiZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat) +void VivaldiZone::get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* lat) { XBT_DEBUG("vivaldi getLocalRoute from '%s'[%u] '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id()); if (src->is_netzone()) { std::string srcName = "router_" + src->get_name(); std::string dstName = "router_" + dst->get_name(); - route->gw_src = s4u::Engine::get_instance()->netpoint_by_name_or_null(srcName); - route->gw_dst = s4u::Engine::get_instance()->netpoint_by_name_or_null(dstName); + route->gw_src_ = s4u::Engine::get_instance()->netpoint_by_name_or_null(srcName); + route->gw_dst_ = s4u::Engine::get_instance()->netpoint_by_name_or_null(dstName); } StarZone::get_local_route(src, dst, route, lat); diff --git a/src/kernel/routing/WifiZone.cpp b/src/kernel/routing/WifiZone.cpp index f6693e0bd1..95f3c16b48 100644 --- a/src/kernel/routing/WifiZone.cpp +++ b/src/kernel/routing/WifiZone.cpp @@ -6,7 +6,6 @@ #include "simgrid/kernel/routing/WifiZone.hpp" #include "simgrid/kernel/routing/NetPoint.hpp" #include "src/surf/network_interface.hpp" -#include "src/surf/xml/platf_private.hpp" #include "surf/surf.hpp" #include @@ -29,7 +28,7 @@ void WifiZone::do_seal() } } -void WifiZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* res, double* lat) +void WifiZone::get_local_route(NetPoint* src, NetPoint* dst, Route* res, double* lat) { XBT_DEBUG("full getLocalRoute from %s[%u] to %s[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id()); @@ -39,13 +38,13 @@ void WifiZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* if (src != access_point_) { XBT_DEBUG("src %s is not our gateway", src->get_cname()); - res->link_list.push_back(wifi_link_); + res->link_list_.push_back(wifi_link_); if (lat) *lat += wifi_link_->get_latency(); } if (dst != access_point_) { XBT_DEBUG("dst %s is not our gateway", dst->get_cname()); - res->link_list.push_back(wifi_link_); + res->link_list_.push_back(wifi_link_); if (lat) *lat += wifi_link_->get_latency(); } -- 2.20.1
Comparison of the RoutedZone subclasses