Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
factor on_creation signal trigger in Host::seal()
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Tue, 6 Apr 2021 17:51:34 +0000 (19:51 +0200)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Tue, 6 Apr 2021 17:51:34 +0000 (19:51 +0200)
src/instr/instr_platform.cpp
src/plugins/vm/s4u_VirtualMachine.cpp
src/s4u/s4u_Host.cpp
src/surf/sg_platf.cpp

index 0ae2219..c49bb9c 100644 (file)
@@ -304,6 +304,9 @@ static void on_link_creation(s4u::Link const& link)
 
 static void on_host_creation(s4u::Host const& host)
 {
+  if (Container::by_name_or_null(host.get_name())) // This host already exists, do nothing
+    return;
+
   Container* container  = new HostContainer(host, currentContainer.back());
   const Container* root = Container::get_root();
 
index 37f6abf..ff29321 100644 (file)
@@ -49,14 +49,11 @@ VirtualMachine::VirtualMachine(const std::string& name, s4u::Host* physical_host
       ->create_cpu(this, speeds)
       ->set_core_count(core_amount)
       ->seal();
+
   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);
 }
 
 VirtualMachine::~VirtualMachine()
index 948353f..c11256d 100644 (file)
@@ -350,6 +350,7 @@ void Host::execute(double flops, double priority) const
 void Host::seal()
 {
   kernel::actor::simcall([this]() { this->pimpl_->seal(); });
+  simgrid::s4u::Host::on_creation(*this); // notify the signal
 }
 
 } // namespace s4u
index 4fd51a3..e9b6eec 100644 (file)
@@ -80,7 +80,6 @@ void sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* args)
     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
    * allocation is triggered by the on_creation signal. Then set_pstate must be called after the signal emition */
@@ -182,7 +181,6 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster
     if ((cluster->properties != nullptr) && (not cluster->properties->empty()))
       host->set_properties(*cluster->properties);
     host->seal();
-    simgrid::s4u::Host::on_creation(*host); // notify the signal
 
     XBT_DEBUG("</host>");
 
@@ -422,7 +420,6 @@ void sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer)
   if (peer->speed_trace)
     host->set_speed_profile(peer->speed_trace);
   host->seal();
-  simgrid::s4u::Host::on_creation(*host); // notify the signal
 }
 
 /**