Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Seal NetZone
authorBruno Donassolo <bruno.donassolo@inria.fr>
Fri, 2 Apr 2021 17:26:31 +0000 (19:26 +0200)
committerBruno Donassolo <bruno.donassolo@inria.fr>
Fri, 2 Apr 2021 17:26:31 +0000 (19:26 +0200)
We need to be able to seal the netzone too.
Sealing a netzone, seals its children and hosts.

Add protection to avoid sealing twice.

include/simgrid/s4u/NetZone.hpp
src/kernel/routing/NetZoneImpl.cpp
src/s4u/s4u_Host.cpp
src/s4u/s4u_Netzone.cpp
src/surf/HostImpl.cpp
src/surf/cpu_interface.cpp

index a78e29d..a21b78d 100644 (file)
@@ -137,6 +137,11 @@ public:
   s4u::Link* create_link(const std::string& name, const std::vector<std::string>& bandwidths,
                          Link::SharingPolicy policy = Link::SharingPolicy::SHARED);
 
+  /**
+   * @brief Seal this netzone configuration
+   */
+  void seal();
+
 private:
   /** @brief Auxiliary function to get list of LinkImpl */
   static std::vector<kernel::resource::LinkImpl*> get_link_list_impl(const std::vector<Link*> link_list);
index 7280225..0365866 100644 (file)
@@ -465,7 +465,18 @@ void NetZoneImpl::get_global_route(NetPoint* src, NetPoint* dst,
 
 void NetZoneImpl::seal()
 {
+  /* already sealed netzone */
+  if (sealed_)
+    return;
   do_seal(); // derived class' specific sealing procedure
+
+  /* seals sub-netzones and hosts */
+  for (auto* host : get_all_hosts()) {
+    host->seal();
+  }
+  for (auto* sub_net : *get_children()) {
+    sub_net->seal();
+  }
   sealed_ = true;
 }
 
index 08234c4..948353f 100644 (file)
@@ -349,7 +349,6 @@ void Host::execute(double flops, double priority) const
 
 void Host::seal()
 {
-  kernel::actor::simcall([this]() { this->pimpl_cpu->seal(); });
   kernel::actor::simcall([this]() { this->pimpl_->seal(); });
 }
 
index fa6f0c2..287d9e8 100644 (file)
@@ -143,6 +143,11 @@ void NetZone::extract_xbt_graph(const s_xbt_graph_t* graph, std::map<std::string
   pimpl_->get_graph(graph, nodes, edges);
 }
 
+void NetZone::seal()
+{
+  kernel::actor::simcall([this] { pimpl_->seal(); });
+}
+
 s4u::Host* NetZone::create_host(const std::string& name, const std::vector<double>& speed_per_pstate)
 {
   return kernel::actor::simcall(
index e5c6467..3e4d408 100644 (file)
@@ -153,6 +153,11 @@ void HostImpl::remove_disk(const std::string& disk_name)
 
 void HostImpl::seal()
 {
+  if (sealed_) {
+    return;
+  }
+  // seals host's CPU
+  get_iface()->pimpl_cpu->seal();
   sealed_ = true;
 }
 } // namespace surf
index e15a33c..dd0d66d 100644 (file)
@@ -129,6 +129,9 @@ Cpu* Cpu::set_speed_profile(kernel::profile::Profile* profile)
 
 void Cpu::seal()
 {
+  if (is_sealed()) {
+    return;
+  }
   lmm::System* lmm = get_model()->get_maxmin_system();
   if (dynamic_cast<CpuTiModel*>(get_model()) == nullptr)
     this->set_constraint(lmm->constraint_new(this, core_count_ * speed_per_pstate_.front()));