Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Define duplicated function get_graph() only once, in common ancestor.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 10 May 2022 19:25:16 +0000 (21:25 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 10 May 2022 19:47:04 +0000 (21:47 +0200)
include/simgrid/kernel/routing/ClusterZone.hpp
include/simgrid/kernel/routing/NetZoneImpl.hpp
include/simgrid/kernel/routing/RoutedZone.hpp
src/kernel/routing/ClusterZone.cpp
src/kernel/routing/NetZoneImpl.cpp
src/kernel/routing/RoutedZone.cpp

index 9d51532..aee536d 100644 (file)
@@ -135,9 +135,6 @@ protected:
     return private_links_.find(position) != private_links_.end();
   }
 
-  void get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t, std::less<>>* nodes,
-                 std::map<std::string, xbt_edge_t, std::less<>>* edges) override;
-
   unsigned long node_pos(unsigned long id) const { return id * num_links_per_node_; }
   unsigned long node_pos_with_loopback(unsigned long id) const { return node_pos(id) + (has_loopback_ ? 1 : 0); }
 
index e03fcf8..55a1748 100644 (file)
@@ -264,7 +264,7 @@ public:
                                              std::unordered_set<NetZoneImpl*>& netzones);
 
   virtual void get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t, std::less<>>* nodes,
-                         std::map<std::string, xbt_edge_t, std::less<>>* edges) = 0;
+                         std::map<std::string, xbt_edge_t, std::less<>>* edges);
 
   /*** Called on each newly created regular route (not on bypass routes) */
   static xbt::signal<void(bool symmetrical, NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
index c086cea..0e657cc 100644 (file)
@@ -52,9 +52,6 @@ class XBT_PRIVATE RoutedZone : public NetZoneImpl {
 public:
   explicit RoutedZone(const std::string& name);
 
-  void get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t, std::less<>>* nodes,
-                 std::map<std::string, xbt_edge_t, std::less<>>* edges) override;
-
 protected:
   Route* new_extended_route(RoutingMode hierarchy, NetPoint* gw_src, NetPoint* gw_dst,
                             const std::vector<resource::StandardLinkImpl*>& link_list, bool preserve_order);
index 14c3fb0..df83652 100644 (file)
@@ -5,7 +5,6 @@
 
 #include "simgrid/kernel/routing/ClusterZone.hpp"
 #include "simgrid/kernel/routing/NetPoint.hpp"
-#include "simgrid/kernel/routing/RoutedZone.hpp"
 #include "src/kernel/resource/StandardLinkImpl.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_cluster, ker_routing, "Kernel Cluster Routing");
@@ -57,58 +56,6 @@ NetPoint* ClusterBase::get_gateway(unsigned long position)
   return it == gateways_.end() ? nullptr : it->second;
 }
 
-void ClusterBase::get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t, std::less<>>* nodes,
-                           std::map<std::string, xbt_edge_t, std::less<>>* edges)
-{
-  std::vector<NetPoint*> vertices = get_vertices();
-
-  for (auto const& my_src : vertices) {
-    for (auto const& my_dst : vertices) {
-      if (my_src == my_dst)
-        continue;
-
-      Route route;
-
-      get_local_route(my_src, my_dst, &route, nullptr);
-
-      XBT_DEBUG("get_route_and_latency %s -> %s", my_src->get_cname(), my_dst->get_cname());
-
-      xbt_node_t current;
-      xbt_node_t previous;
-      const char* previous_name;
-      const char* current_name;
-
-      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_) {
-        const char* link_name = link->get_cname();
-        current               = new_xbt_graph_node(graph, link_name, nodes);
-        current_name          = link_name;
-        new_xbt_graph_edge(graph, previous, current, edges);
-        XBT_DEBUG("  %s -> %s", previous_name, current_name);
-        previous      = current;
-        previous_name = current_name;
-      }
-
-      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();
-      }
-      new_xbt_graph_edge(graph, previous, current, edges);
-      XBT_DEBUG("  %s -> %s", previous_name, current_name);
-    }
-  }
-}
-
 void ClusterBase::fill_leaf_from_cb(unsigned long position, const std::vector<unsigned long>& dimensions,
                                     const s4u::ClusterCallbacks& set_callbacks, NetPoint** node_netpoint,
                                     s4u::Link** lb_link, s4u::Link** limiter_link)
index 95f9028..17afb8b 100644 (file)
@@ -665,6 +665,58 @@ void NetZoneImpl::get_global_route_with_netzones(const NetPoint* src, const NetP
     get_global_route_with_netzones(route.gw_dst_, dst, links, latency, netzones);
 }
 
+void NetZoneImpl::get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t, std::less<>>* nodes,
+                            std::map<std::string, xbt_edge_t, std::less<>>* edges)
+{
+  std::vector<NetPoint*> vertices = get_vertices();
+
+  for (auto const& my_src : vertices) {
+    for (auto const& my_dst : vertices) {
+      if (my_src == my_dst)
+        continue;
+
+      Route route;
+
+      get_local_route(my_src, my_dst, &route, nullptr);
+
+      XBT_DEBUG("get_route_and_latency %s -> %s", my_src->get_cname(), my_dst->get_cname());
+
+      xbt_node_t current;
+      xbt_node_t previous;
+      const char* previous_name;
+      const char* current_name;
+
+      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_) {
+        const char* link_name = link->get_cname();
+        current               = new_xbt_graph_node(graph, link_name, nodes);
+        current_name          = link_name;
+        new_xbt_graph_edge(graph, previous, current, edges);
+        XBT_DEBUG("  %s -> %s", previous_name, current_name);
+        previous      = current;
+        previous_name = current_name;
+      }
+
+      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();
+      }
+      new_xbt_graph_edge(graph, previous, current, edges);
+      XBT_DEBUG("  %s -> %s", previous_name, current_name);
+    }
+  }
+}
+
 void NetZoneImpl::seal()
 {
   /* already sealed netzone */
index 27fbd27..2f02a1a 100644 (file)
@@ -20,58 +20,6 @@ namespace simgrid::kernel::routing {
 
 RoutedZone::RoutedZone(const std::string& name) : NetZoneImpl(name) {}
 
-void RoutedZone::get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t, std::less<>>* nodes,
-                           std::map<std::string, xbt_edge_t, std::less<>>* edges)
-{
-  std::vector<NetPoint*> vertices = get_vertices();
-
-  for (auto const& my_src : vertices) {
-    for (auto const& my_dst : vertices) {
-      if (my_src == my_dst)
-        continue;
-
-      Route route;
-
-      get_local_route(my_src, my_dst, &route, nullptr);
-
-      XBT_DEBUG("get_route_and_latency %s -> %s", my_src->get_cname(), my_dst->get_cname());
-
-      xbt_node_t current;
-      xbt_node_t previous;
-      const char* previous_name;
-      const char* current_name;
-
-      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_) {
-        const char* link_name = link->get_cname();
-        current               = new_xbt_graph_node(graph, link_name, nodes);
-        current_name          = link_name;
-        new_xbt_graph_edge(graph, previous, current, edges);
-        XBT_DEBUG("  %s -> %s", previous_name, current_name);
-        previous      = current;
-        previous_name = current_name;
-      }
-
-      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();
-      }
-      new_xbt_graph_edge(graph, previous, current, edges);
-      XBT_DEBUG("  %s -> %s", previous_name, current_name);
-    }
-  }
-}
-
 /* ************************************************************************** */
 /* ************************* GENERIC AUX FUNCTIONS ************************** */
 /* change a route containing link names into a route containing link entities */