Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Adding seal() for Host
authorBruno Donassolo <bruno.donassolo@inria.fr>
Thu, 1 Apr 2021 14:31:31 +0000 (16:31 +0200)
committerBruno Donassolo <bruno.donassolo@inria.fr>
Thu, 1 Apr 2021 15:28:59 +0000 (17:28 +0200)
Allow changing Host settings before seal

include/simgrid/s4u/Host.hpp
src/kernel/routing/NetZoneImpl.cpp
src/plugins/vm/s4u_VirtualMachine.cpp
src/s4u/s4u_Host.cpp
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp
src/surf/sg_platf.cpp

index b23efc3..7aba7b7 100644 (file)
@@ -166,6 +166,12 @@ public:
   void route_to(const Host* dest, std::vector<Link*>& links, double* latency) const;
   void route_to(const Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency) const;
 
+  /**
+   * @brief Seal this host
+   * No more configuration is allowed after the seal
+   */
+  void seal();
+
 #ifndef DOXYGEN
   XBT_ATTRIB_DEPRECATED_v331("Please use Comm::sendto()") void sendto(Host* dest, double byte_amount);
 
index ebcdc97..05a9a87 100644 (file)
@@ -162,7 +162,7 @@ s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vector<d
   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)->set_core_count(core_amount)->seal();
+  cpu_model_pm_->create_cpu(res, speed_per_pstate)->set_core_count(core_amount);
 
   return res;
 }
index 7450b70..37f6abf 100644 (file)
@@ -52,6 +52,8 @@ VirtualMachine::VirtualMachine(const std::string& name, s4u::Host* physical_host
   if (physical_host->get_pstate() != 0)
     set_pstate(physical_host->get_pstate());
 
+  seal(); // seal this host
+
   // Real hosts are (only) created through NetZone::create_host(), and this where the on_creation signal is fired.
   // VMs are created directly, thus firing the signal here. The right solution is probably to separate Host and VM.
   simgrid::s4u::Host::on_creation(*this);
index 3345eca..5dc3074 100644 (file)
@@ -342,6 +342,12 @@ void Host::execute(double flops, double priority) const
   this_actor::exec_init(flops)->set_priority(1 / priority)->vetoable_start()->wait();
 }
 
+void Host::seal()
+{
+  kernel::actor::simcall([this]() { this->pimpl_cpu->seal(); });
+  kernel::actor::simcall([this]() { this->pimpl_->seal(); });
+}
+
 } // namespace s4u
 } // namespace simgrid
 
index 9b8ec04..e5c6467 100644 (file)
@@ -150,5 +150,10 @@ void HostImpl::remove_disk(const std::string& disk_name)
     position++;
   }
 }
+
+void HostImpl::seal()
+{
+  sealed_ = true;
+}
 } // namespace surf
 } // namespace simgrid
index 2429c3d..7fb7086 100644 (file)
@@ -51,6 +51,7 @@ class XBT_PRIVATE HostImpl : public xbt::PropertyHolder {
   s4u::Host piface_;
   std::vector<kernel::resource::DiskImpl*> disks_;
   xbt::string name_{"noname"};
+  bool sealed_ = false;
 
 protected:
   virtual ~HostImpl(); // Use destroy() instead of this destructor.
@@ -83,6 +84,8 @@ public:
   void remove_actor(kernel::actor::ActorImpl* actor) { xbt::intrusive_erase(actor_list_, *actor); }
   void add_actor_at_boot(kernel::actor::ProcessArg* arg) { actors_at_boot_.emplace_back(arg); }
 
+  void seal();
+
   template <class F> void foreach_actor(F function)
   {
     for (auto& actor : actor_list_)
index b7f75c9..b4bfc7c 100644 (file)
@@ -78,6 +78,7 @@ void sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* args)
   if (not args->coord.empty())
     new simgrid::kernel::routing::vivaldi::Coords(host->get_netpoint(), args->coord);
 
+  host->seal();
   simgrid::s4u::Host::on_creation(*host); // notify the signal
 
   /* When energy plugin is activated, changing the pstate requires to already have the HostEnergy extension whose
@@ -426,6 +427,7 @@ void sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer)
     host->set_state_profile(peer->state_trace);
   if (peer->speed_trace)
     host->set_speed_profile(peer->speed_trace);
+  host->seal();
   simgrid::s4u::Host::on_creation(*host); // notify the signal
 }