From 4a0571155ff39551248051413a24ab9df8838c18 Mon Sep 17 00:00:00 2001 From: SUTER Frederic Date: Tue, 6 Apr 2021 19:51:34 +0200 Subject: [PATCH] factor on_creation signal trigger in Host::seal() --- src/instr/instr_platform.cpp | 3 +++ src/plugins/vm/s4u_VirtualMachine.cpp | 5 +---- src/s4u/s4u_Host.cpp | 1 + src/surf/sg_platf.cpp | 3 --- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index 0ae22190a4..c49bb9cbad 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -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(); diff --git a/src/plugins/vm/s4u_VirtualMachine.cpp b/src/plugins/vm/s4u_VirtualMachine.cpp index 37f6abf63c..ff2932141a 100644 --- a/src/plugins/vm/s4u_VirtualMachine.cpp +++ b/src/plugins/vm/s4u_VirtualMachine.cpp @@ -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() diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index 948353fb39..c11256d4ee 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -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 diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 4fd51a357c..e9b6eec1db 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -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(""); @@ -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 } /** -- 2.20.1