Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
change way vivaldi coordinates are managed internally
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Mon, 12 Apr 2021 12:24:45 +0000 (14:24 +0200)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Mon, 12 Apr 2021 12:24:45 +0000 (14:24 +0200)
include/simgrid/kernel/routing/NetPoint.hpp
include/simgrid/kernel/routing/VivaldiZone.hpp
include/simgrid/s4u/Host.hpp
src/kernel/routing/NetPoint.cpp
src/kernel/routing/VivaldiZone.cpp
src/s4u/s4u_Host.cpp
src/surf/sg_platf.cpp
src/surf/xml/platf_private.hpp

index c5f5535..33d1be5 100644 (file)
@@ -38,6 +38,7 @@ public:
   NetZoneImpl* get_englobing_zone() { return englobing_zone_; }
   /** @brief Set the NetZone in which this NetPoint is included */
   NetPoint* set_englobing_zone(NetZoneImpl* netzone_p);
+  NetPoint* set_coordinates(const std::string& coords);
 
   bool is_netzone() const { return component_type_ == Type::NetZone; }
   bool is_host() const { return component_type_ == Type::Host; }
index d7627b9..4e4f6af 100644 (file)
@@ -47,7 +47,7 @@ namespace routing {
 class XBT_PRIVATE VivaldiZone : public ClusterZone {
 public:
   using ClusterZone::ClusterZone;
-  void set_peer_link(NetPoint* netpoint, double bw_in, double bw_out, const std::string& coord);
+  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;
 };
 
index 4ecd0d5..07d7cc5 100644 (file)
@@ -163,6 +163,7 @@ public:
   int get_pstate() const;
   double get_pstate_speed(int pstate_index) const;
   Host* set_pstate(int pstate_index);
+  Host* set_coordinates(const std::string& coords);
 
   std::vector<Disk*> get_disks() const;
   /**
index 14c4c70..fad35e5 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/kernel/routing/NetPoint.hpp"
+#include "simgrid/kernel/routing/VivaldiZone.hpp"
 #include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "xbt/log.h"
@@ -33,6 +34,11 @@ NetPoint* NetPoint::set_englobing_zone(NetZoneImpl* netzone_p)
   return this;
 }
 
+NetPoint* NetPoint::set_coordinates(const std::string& coords)
+{
+  new vivaldi::Coords(this, coords);
+  return this;
+}
 } // namespace routing
 } // namespace kernel
 } // namespace simgrid
index f073f37..bab7709 100644 (file)
@@ -61,13 +61,11 @@ static std::vector<double>* netpoint_get_coords(NetPoint* np)
   return &coords->coords;
 }
 
-void VivaldiZone::set_peer_link(NetPoint* netpoint, double bw_in, double bw_out, const std::string& coord)
+void VivaldiZone::set_peer_link(NetPoint* netpoint, double bw_in, double bw_out)
 {
   xbt_assert(netpoint->get_englobing_zone() == this,
              "Cannot add a peer link to a netpoint that is not in this netzone");
 
-  new vivaldi::Coords(netpoint, coord);
-
   std::string link_up   = "link_" + netpoint->get_name() + "_UP";
   std::string link_down = "link_" + netpoint->get_name() + "_DOWN";
   resource::LinkImpl* linkUp = get_network_model()->create_link(link_up, std::vector<double>(1, bw_out));
index 72dcc0f..72c27ad 100644 (file)
@@ -305,6 +305,12 @@ int Host::get_pstate() const
   return this->pimpl_cpu->get_pstate();
 }
 
+Host* Host::set_coordinates(const std::string& coords)
+{
+  if (not coords.empty())
+    kernel::actor::simcall([this, coords] { this->pimpl_netpoint_->set_coordinates(coords); });
+  return this;
+}
 std::vector<Disk*> Host::get_disks() const
 {
   return this->pimpl_->get_disks();
index b3e76c3..1f4eb20 100644 (file)
@@ -63,10 +63,8 @@ void sg_platf_exit()
 /** @brief Add a host to the current NetZone */
 void sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* args)
 {
-  simgrid::s4u::Host* host = routing_get_current()->create_host(args->id, args->speed_per_pstate);
-
-  if (not args->coord.empty())
-    new simgrid::kernel::routing::vivaldi::Coords(host->get_netpoint(), args->coord);
+  simgrid::s4u::Host* host =
+      routing_get_current()->create_host(args->id, args->speed_per_pstate)->set_coordinates(args->coord);
 
   if (args->properties) {
     host->set_properties(*args->properties);
@@ -87,7 +85,7 @@ void sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* args)
 }
 
 /** @brief Add a "router" to the network element list */
-simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name, const char* coords)
+simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name, const std::string& coords)
 {
   xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name),
              "Refusing to create a router named '%s': this name already describes a node.", name.c_str());
@@ -96,8 +94,8 @@ simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name,
   netpoint->set_englobing_zone(current_routing);
   XBT_DEBUG("Router '%s' has the id %u", netpoint->get_cname(), netpoint->id());
 
-  if (coords && strcmp(coords, ""))
-    new simgrid::kernel::routing::vivaldi::Coords(netpoint, coords);
+  if (not coords.empty())
+    netpoint->set_coordinates(coords);
 
   return netpoint;
 }
@@ -231,7 +229,7 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster
   XBT_DEBUG("<router id=\"%s\"/>", cluster->router_id.c_str());
   if (cluster->router_id.empty())
     cluster->router_id = std::string(cluster->prefix) + cluster->id + "_router" + cluster->suffix;
-  current_zone->set_router(sg_platf_new_router(cluster->router_id, nullptr));
+  current_zone->set_router(sg_platf_new_router(cluster->router_id, ""));
 
   // Make the backbone
   if ((cluster->bb_bw > 0) || (cluster->bb_lat > 0)) {
@@ -395,13 +393,12 @@ void sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer)
 
   simgrid::s4u::Host* host = zone->create_host(peer->id, std::vector<double>{peer->speed})
                                  ->set_state_profile(peer->state_trace)
-                                 ->set_speed_profile(peer->speed_trace);
-
-  zone->set_peer_link(host->get_netpoint(), peer->bw_in, peer->bw_out, peer->coord);
+                                 ->set_speed_profile(peer->speed_trace)
+                                 ->set_coordinates(peer->coord)
+                                 ->seal();
 
-  host->seal();
+  zone->set_peer_link(host->get_netpoint(), peer->bw_in, peer->bw_out);
 }
-
 /**
  * @brief Auxiliary function to build the object NetZoneImpl
  *
index f48f6fb..165da98 100644 (file)
@@ -189,8 +189,8 @@ sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer); // Ad
 XBT_PUBLIC void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* clust);   // Add a cluster   to the current Zone
 XBT_PUBLIC void
 sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone
-XBT_PUBLIC simgrid::kernel::routing::NetPoint* // Add a router    to the current Zone
-    sg_platf_new_router(const std::string&, const char* coords);
+XBT_PUBLIC simgrid::kernel::routing::NetPoint*                                      // Add a router to the current Zone
+sg_platf_new_router(const std::string&, const std::string& coords);
 
 XBT_PUBLIC void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route);             // Add a route
 XBT_PUBLIC void sg_platf_new_bypassRoute(simgrid::kernel::routing::RouteCreationArgs* bypassroute); // Add a bypassRoute