Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
improve router creation
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Tue, 13 Apr 2021 09:39:20 +0000 (11:39 +0200)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Tue, 13 Apr 2021 14:37:44 +0000 (16:37 +0200)
include/simgrid/kernel/routing/NetPoint.hpp
include/simgrid/kernel/routing/NetZoneImpl.hpp
src/kernel/routing/NetPoint.cpp
src/kernel/routing/NetZoneImpl.cpp
src/surf/sg_platf.cpp

index 33d1be5..7b4126c 100644 (file)
@@ -52,7 +52,7 @@ private:
   unsigned int id_ = -1;
   std::string name_;
   NetPoint::Type component_type_;
-  NetZoneImpl* englobing_zone_;
+  NetZoneImpl* englobing_zone_ = nullptr;
 };
 } // namespace routing
 } // namespace kernel
index f829d7f..bbd3899 100644 (file)
@@ -134,6 +134,8 @@ public:
   s4u::Disk* create_disk(const std::string& name, double read_bandwidth, double write_bandwidth);
   /** @brief Make a link within that NetZone */
   virtual s4u::Link* create_link(const std::string& name, const std::vector<double>& bandwidths);
+  /** @brief Make a router within that NetZone */
+  NetPoint* create_router(const std::string& name);
   /** @brief Creates a new route in this NetZone */
   virtual void add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
                                 std::vector<resource::LinkImpl*>& link_list, bool symmetrical);
index fad35e5..5112bc6 100644 (file)
@@ -36,7 +36,8 @@ NetPoint* NetPoint::set_englobing_zone(NetZoneImpl* netzone_p)
 
 NetPoint* NetPoint::set_coordinates(const std::string& coords)
 {
-  new vivaldi::Coords(this, coords);
+  if (not coords.empty())
+    new vivaldi::Coords(this, coords);
   return this;
 }
 } // namespace routing
index a47f4b4..c1ebb3e 100644 (file)
@@ -140,11 +140,14 @@ int NetZoneImpl::get_host_count() const
   return count;
 }
 
-s4u::Disk* NetZoneImpl::create_disk(const std::string& name, double read_bandwidth, double write_bandwidth)
+s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vector<double>& speed_per_pstate)
 {
-  auto* l = disk_model_->create_disk(name, read_bandwidth, write_bandwidth);
+  auto* res = (new surf::HostImpl(name))->get_iface();
+  res->set_netpoint((new NetPoint(name, NetPoint::Type::Host))->set_englobing_zone(this));
 
-  return l->get_iface();
+  cpu_model_pm_->create_cpu(res, speed_per_pstate);
+
+  return res;
 }
 
 s4u::Link* NetZoneImpl::create_link(const std::string& name, const std::vector<double>& bandwidths)
@@ -152,16 +155,20 @@ s4u::Link* NetZoneImpl::create_link(const std::string& name, const std::vector<d
   return network_model_->create_link(name, bandwidths)->get_iface();
 }
 
-s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vector<double>& speed_per_pstate)
+s4u::Disk* NetZoneImpl::create_disk(const std::string& name, double read_bandwidth, double write_bandwidth)
 {
-  auto* res = (new surf::HostImpl(name))->get_iface();
-  res->set_netpoint((new NetPoint(name, NetPoint::Type::Host))->set_englobing_zone(this));
-
-  cpu_model_pm_->create_cpu(res, speed_per_pstate);
+  auto* l = disk_model_->create_disk(name, read_bandwidth, write_bandwidth);
 
-  return res;
+  return l->get_iface();
 }
 
+NetPoint* NetZoneImpl::create_router(const std::string& name)
+{
+  xbt_assert(nullptr == 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());
+
+  return (new NetPoint(name, NetPoint::Type::Router))->set_englobing_zone(this);
+}
 int NetZoneImpl::add_component(NetPoint* elm)
 {
   vertices_.push_back(elm);
index 90bd01c..b50f628 100644 (file)
@@ -70,7 +70,6 @@ void sg_platf_new_host_begin(const simgrid::kernel::routing::HostCreationArgs* a
                      ->set_core_count(args->core_amount)
                      ->set_state_profile(args->state_trace)
                      ->set_speed_profile(args->speed_trace);
-  //  host->get_impl()->set_disks(args->disks);
 }
 
 void sg_platf_new_host_set_properties(const std::unordered_map<std::string, std::string>& props)
@@ -96,16 +95,9 @@ void sg_platf_new_host_seal(int pstate)
 /** @brief Add a "router" to the network element list */
 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());
-
-  auto* netpoint = new simgrid::kernel::routing::NetPoint(name, simgrid::kernel::routing::NetPoint::Type::Router);
-  netpoint->set_englobing_zone(current_routing);
+  auto* netpoint = current_routing->create_router(name)->set_coordinates(coords);
   XBT_DEBUG("Router '%s' has the id %u", netpoint->get_cname(), netpoint->id());
 
-  if (not coords.empty())
-    netpoint->set_coordinates(coords);
-
   return netpoint;
 }
 
@@ -243,7 +235,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, ""));
+  current_zone->set_router(current_zone->create_router(cluster->router_id));
 
   // Make the backbone
   if ((cluster->bb_bw > 0) || (cluster->bb_lat > 0)) {