Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix some doxygen errors
[simgrid.git] / src / kernel / routing / ClusterZone.cpp
index 14c3fb05ef0fee48eec50cf6d6f59363ac6a93c0..fa82dd48d0c6776781f8d78a6d37075a9305be25 100644 (file)
@@ -1,14 +1,14 @@
-/* Copyright (c) 2009-2022. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2023. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "simgrid/s4u/Host.hpp"
 #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");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_cluster, ker_platform, "Kernel Cluster Routing");
 
 /* This routing is specifically setup to represent clusters, aka homogeneous sets of machines
  * Note that a router is created, easing the interconnection with the rest of the world. */
@@ -57,58 +57,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)
@@ -123,9 +71,8 @@ void ClusterBase::fill_leaf_from_cb(unsigned long position, const std::vector<un
   auto index_to_dims = [&dimensions](unsigned long index) {
     std::vector<unsigned long> dims_array(dimensions.size());
     for (auto i = static_cast<int>(dimensions.size() - 1); i >= 0; --i) {
-      if (index <= 0) {
+      if (index == 0)
         break;
-      }
       unsigned long value = index % dimensions[i];
       dims_array[i]      = value;
       index              = (index / dimensions[i]);
@@ -136,7 +83,17 @@ void ClusterBase::fill_leaf_from_cb(unsigned long position, const std::vector<un
   kernel::routing::NetPoint* netpoint = nullptr;
   kernel::routing::NetPoint* gw       = nullptr;
   auto dims                           = index_to_dims(position);
-  std::tie(netpoint, gw)              = set_callbacks.netpoint(get_iface(), dims, position);
+  if (set_callbacks.is_by_netpoint()) { // XBT_ATTRIB_DEPRECATED_v339
+    std::tie(netpoint, gw) = set_callbacks.netpoint(get_iface(), dims, position); // XBT_ATTRIB_DEPRECATED_v339
+  } else if (set_callbacks.is_by_netzone()) {
+    s4u::NetZone* netzone = set_callbacks.netzone(get_iface(), dims, position);
+    netpoint              = netzone->get_netpoint();
+    gw                    = netzone->get_gateway();
+  } else {
+    s4u::Host* host = set_callbacks.host(get_iface(), dims, position);
+    netpoint        = host->get_netpoint();
+  }
+
   xbt_assert(netpoint, "set_netpoint(elem=%lu): Invalid netpoint (nullptr)", position);
   if (netpoint->is_netzone()) {
     xbt_assert(gw && not gw->is_netzone(),