From cdcc6f10f0ba3de1b01e4c910fa1966114350ae6 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 12 May 2018 23:44:45 +0200 Subject: [PATCH] snake_case the s4u::Host signals --- include/simgrid/s4u/Host.hpp | 31 ++++++------------- src/instr/instr_platform.cpp | 6 ++-- src/kernel/routing/NetZoneImpl.cpp | 2 +- src/plugins/file_system/s4u_FileSystem.cpp | 2 +- src/plugins/vm/VirtualMachineImpl.cpp | 2 +- src/plugins/vm/s4u_VirtualMachine.cpp | 2 +- src/s4u/s4u_Host.cpp | 24 +++++++------- src/simix/smx_global.cpp | 2 +- src/smpi/internals/smpi_global.cpp | 5 ++- src/surf/cpu_interface.cpp | 2 +- src/surf/network_ib.cpp | 2 +- src/surf/plugins/host_dvfs.cpp | 2 +- src/surf/plugins/host_energy.cpp | 8 ++--- src/surf/plugins/host_load.cpp | 6 ++-- .../generic-simcalls/generic-simcalls.cpp | 3 +- 15 files changed, 43 insertions(+), 56 deletions(-) diff --git a/include/simgrid/s4u/Host.hpp b/include/simgrid/s4u/Host.hpp index d2d2cbf9d2..9e79f60f21 100644 --- a/include/simgrid/s4u/Host.hpp +++ b/include/simgrid/s4u/Host.hpp @@ -122,12 +122,16 @@ public: /** Block the calling actor on an execution located on the called host (with explicit priority) */ void execute(double flops, double priority); - /** @brief Returns the current computation load (in flops per second) */ + /** @brief Returns the current computation load (in flops per second) + * The external load (coming from an availability trace) is not taken in account. + * + * @return The number of activities currently running on a host (an activity at priority 2 is counted twice). + */ double getLoad(); private: simgrid::xbt::string name_{"noname"}; - std::unordered_map* mounts = nullptr; // caching + std::unordered_map* mounts_ = nullptr; // caching public: // TODO, this could be a unique_ptr @@ -138,14 +142,14 @@ public: kernel::routing::NetPoint* pimpl_netpoint = nullptr; /*** Called on each newly created host */ - static simgrid::xbt::signal onCreation; + static simgrid::xbt::signal on_creation; /*** Called just before destructing an host */ - static simgrid::xbt::signal onDestruction; + static simgrid::xbt::signal on_destruction; /*** Called when the machine is turned on or off (called AFTER the change) */ - static simgrid::xbt::signal onStateChange; + static simgrid::xbt::signal on_state_change; /*** Called when the speed of the machine is changed (called AFTER the change) * (either because of a pstate switch or because of an external load event coming from the profile) */ - static simgrid::xbt::signal onSpeedChange; + static simgrid::xbt::signal on_speed_change; }; } } // namespace simgrid::s4u @@ -153,18 +157,3 @@ public: extern int USER_HOST_LEVEL; #endif /* SIMGRID_S4U_HOST_HPP */ - -#if 0 - -public class Host { - - /** - * This method returns the number of tasks currently running on a host. - * The external load (coming from an availability trace) is not taken in account. - * - * @return The number of tasks currently running on a host. - */ - public native int getLoad(); - -} -#endif diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index e1b1fa85f6..8088380e6b 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -355,7 +355,7 @@ void instr_define_callbacks() // properly if (TRACE_needs_platform()) { simgrid::s4u::on_platform_created.connect(instr_on_platform_created); - simgrid::s4u::Host::onCreation.connect(instr_host_on_creation); + simgrid::s4u::Host::on_creation.connect(instr_host_on_creation); simgrid::s4u::Link::on_creation.connect(instr_link_on_creation); } simgrid::s4u::NetZone::onCreation.connect(instr_netzone_on_creation); @@ -373,12 +373,12 @@ void instr_define_callbacks() } if (TRACE_vm_is_enabled()) { - simgrid::s4u::Host::onCreation.connect(instr_vm_on_creation); + simgrid::s4u::Host::on_creation.connect(instr_vm_on_creation); simgrid::s4u::VirtualMachine::on_start.connect(instr_vm_on_start); simgrid::s4u::VirtualMachine::on_started.connect(instr_vm_on_started); simgrid::s4u::VirtualMachine::on_suspend.connect(instr_vm_on_suspend); simgrid::s4u::VirtualMachine::on_resume.connect(instr_vm_on_resume); - simgrid::s4u::Host::onDestruction.connect(instr_vm_on_destruction); + simgrid::s4u::Host::on_destruction.connect(instr_vm_on_destruction); } } /* diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index 0c3a7dcedd..bbcec30ea5 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -59,7 +59,7 @@ simgrid::s4u::Host* NetZoneImpl::create_host(const char* name, std::vectorsetProperty(kv.first, kv.second); - simgrid::s4u::Host::onCreation(*res); // notify the signal + simgrid::s4u::Host::on_creation(*res); // notify the signal return res; } diff --git a/src/plugins/file_system/s4u_FileSystem.cpp b/src/plugins/file_system/s4u_FileSystem.cpp index 056ffa9131..d89ecd0408 100644 --- a/src/plugins/file_system/s4u_FileSystem.cpp +++ b/src/plugins/file_system/s4u_FileSystem.cpp @@ -360,7 +360,7 @@ void sg_storage_file_system_init() if (not FileDescriptorHostExt::EXTENSION_ID.valid()) { FileDescriptorHostExt::EXTENSION_ID = simgrid::s4u::Host::extension_create(); - simgrid::s4u::Host::onCreation.connect(&on_host_creation); + simgrid::s4u::Host::on_creation.connect(&on_host_creation); } } diff --git a/src/plugins/vm/VirtualMachineImpl.cpp b/src/plugins/vm/VirtualMachineImpl.cpp index 025fc56221..6f9fe0b9a7 100644 --- a/src/plugins/vm/VirtualMachineImpl.cpp +++ b/src/plugins/vm/VirtualMachineImpl.cpp @@ -58,7 +58,7 @@ static void hostStateChange(s4u::Host& host) } VMModel::VMModel() { - s4u::Host::onStateChange.connect(hostStateChange); + s4u::Host::on_state_change.connect(hostStateChange); } double VMModel::next_occuring_event(double now) diff --git a/src/plugins/vm/s4u_VirtualMachine.cpp b/src/plugins/vm/s4u_VirtualMachine.cpp index 2985b7c6fa..8d83e9b75b 100644 --- a/src/plugins/vm/s4u_VirtualMachine.cpp +++ b/src/plugins/vm/s4u_VirtualMachine.cpp @@ -46,7 +46,7 @@ VirtualMachine::VirtualMachine(const char* name, s4u::Host* pm, int coreAmount, VirtualMachine::~VirtualMachine() { - onDestruction(*this); + on_destruction(*this); XBT_DEBUG("destroy %s", get_cname()); diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index bd963f4da1..a12b3fa8b9 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -23,10 +23,10 @@ template class Extendable; namespace s4u { -simgrid::xbt::signal Host::onCreation; -simgrid::xbt::signal Host::onDestruction; -simgrid::xbt::signal Host::onStateChange; -simgrid::xbt::signal Host::onSpeedChange; +simgrid::xbt::signal Host::on_creation; +simgrid::xbt::signal Host::on_destruction; +simgrid::xbt::signal Host::on_state_change; +simgrid::xbt::signal Host::on_speed_change; Host::Host(const char* name) : name_(name) { @@ -43,7 +43,7 @@ Host::~Host() if (pimpl_netpoint != nullptr) // not removed yet by a children class simgrid::s4u::Engine::get_instance()->netpoint_unregister(pimpl_netpoint); delete pimpl_cpu; - delete mounts; + delete mounts_; } /** @brief Fire the required callbacks and destroy the object @@ -58,7 +58,7 @@ void Host::destroy() { if (not currentlyDestroying_) { currentlyDestroying_ = true; - onDestruction(*this); + on_destruction(*this); Engine::get_instance()->host_unregister(std::string(name_)); delete this; } @@ -95,7 +95,7 @@ void Host::turnOn() simgrid::simix::simcall([this] { this->extension()->turnOn(); this->pimpl_cpu->turn_on(); - onStateChange(*this); + on_state_change(*this); }); } } @@ -106,7 +106,7 @@ void Host::turnOff() smx_actor_t self = SIMIX_process_self(); simgrid::simix::simcall([this, self] { SIMIX_host_off(this, self); - onStateChange(*this); + on_state_change(*this); }); } } @@ -245,13 +245,13 @@ void Host::getAttachedStorages(std::vector* storages) std::unordered_map const& Host::getMountedStorages() { - if (mounts == nullptr) { - mounts = new std::unordered_map(); + if (mounts_ == nullptr) { + mounts_ = new std::unordered_map(); for (auto const& m : this->pimpl_->storage_) { - mounts->insert({m.first, &m.second->piface_}); + mounts_->insert({m.first, &m.second->piface_}); } } - return *mounts; + return *mounts_; } void Host::execute(double flops) diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index a4a9b7a486..f01bd8f961 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -209,7 +209,7 @@ void SIMIX_global_init(int *argc, char **argv) /* register a function to be called by SURF after the environment creation */ sg_platf_init(); simgrid::s4u::on_platform_created.connect(SIMIX_post_create_environment); - simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) { + simgrid::s4u::Host::on_creation.connect([](simgrid::s4u::Host& host) { if (host.extension() == nullptr) // another callback to the same signal may have created it host.extension_set(new simgrid::simix::Host()); }); diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index 5c259e91a8..47ee856894 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -464,9 +464,8 @@ int smpi_main(const char* executable, int argc, char *argv[]) // TODO This will not be executed in the case where smpi_main is not called, // e.g., not for smpi_msg_masterslave. This should be moved to another location // that is always called -- maybe close to Actor::onCreation? - simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) { - host.extension_set(new simgrid::smpi::Host(&host)); - }); + simgrid::s4u::Host::on_creation.connect( + [](simgrid::s4u::Host& host) { host.extension_set(new simgrid::smpi::Host(&host)); }); // parse the platform file: get the host list SIMIX_create_environment(argv[1]); diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index ebe52e9cb8..a4c750a063 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -137,7 +137,7 @@ void Cpu::onSpeedChange() { instr::Container::by_name(get_cname()) ->get_variable("power") ->set_event(surf_get_clock(), coresAmount_ * speed_.scale * speed_.peak); - s4u::Host::onSpeedChange(*host_); + s4u::Host::on_speed_change(*host_); } int Cpu::coreCount() diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index 4a68c7b025..bc08cedab4 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -92,7 +92,7 @@ void surf_network_model_init_IB() all_existing_models->push_back(surf_network_model); simgrid::s4u::Link::on_communication_state_change.connect(IB_action_state_changed_callback); simgrid::s4u::Link::on_communicate.connect(IB_action_init_callback); - simgrid::s4u::Host::onCreation.connect(IB_create_host_callback); + simgrid::s4u::Host::on_creation.connect(IB_create_host_callback); simgrid::config::set_default("network/weight-S", 8775); } diff --git a/src/surf/plugins/host_dvfs.cpp b/src/surf/plugins/host_dvfs.cpp index 215336f6b7..e5ea579ecb 100644 --- a/src/surf/plugins/host_dvfs.cpp +++ b/src/surf/plugins/host_dvfs.cpp @@ -303,7 +303,7 @@ void sg_host_dvfs_plugin_init() sg_host_load_plugin_init(); - simgrid::s4u::Host::onCreation.connect(&on_host_added); + simgrid::s4u::Host::on_creation.connect(&on_host_added); simgrid::config::declare_flag( property_sampling_rate, "How often should the dvfs plugin check whether the frequency needs to be changed?", 0.1); simgrid::config::declare_flag( diff --git a/src/surf/plugins/host_energy.cpp b/src/surf/plugins/host_energy.cpp index a90c80e9e0..3f76a5b28f 100644 --- a/src/surf/plugins/host_energy.cpp +++ b/src/surf/plugins/host_energy.cpp @@ -457,10 +457,10 @@ void sg_host_energy_plugin_init() HostEnergy::EXTENSION_ID = simgrid::s4u::Host::extension_create(); - simgrid::s4u::Host::onCreation.connect(&onCreation); - simgrid::s4u::Host::onStateChange.connect(&onHostChange); - simgrid::s4u::Host::onSpeedChange.connect(&onHostChange); - simgrid::s4u::Host::onDestruction.connect(&onHostDestruction); + simgrid::s4u::Host::on_creation.connect(&onCreation); + simgrid::s4u::Host::on_state_change.connect(&onHostChange); + simgrid::s4u::Host::on_speed_change.connect(&onHostChange); + simgrid::s4u::Host::on_destruction.connect(&onHostDestruction); simgrid::s4u::on_simulation_end.connect(&onSimulationEnd); simgrid::surf::CpuAction::onStateChange.connect(&onActionStateChange); } diff --git a/src/surf/plugins/host_load.cpp b/src/surf/plugins/host_load.cpp index 039f23cda7..94e8966a31 100644 --- a/src/surf/plugins/host_load.cpp +++ b/src/surf/plugins/host_load.cpp @@ -177,15 +177,15 @@ void sg_host_load_plugin_init() /* When attaching a callback into a signal, you can use a lambda as follows, or a regular function as done below */ - simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) { + simgrid::s4u::Host::on_creation.connect([](simgrid::s4u::Host& host) { if (dynamic_cast(&host)) // Ignore virtual machines return; host.extension_set(new HostLoad(&host)); }); simgrid::surf::CpuAction::onStateChange.connect(&onActionStateChange); - simgrid::s4u::Host::onStateChange.connect(&onHostChange); - simgrid::s4u::Host::onSpeedChange.connect(&onHostChange); + simgrid::s4u::Host::on_state_change.connect(&onHostChange); + simgrid::s4u::Host::on_speed_change.connect(&onHostChange); } /** @brief Returns the current load of the host passed as argument diff --git a/teshsuite/simix/generic-simcalls/generic-simcalls.cpp b/teshsuite/simix/generic-simcalls/generic-simcalls.cpp index 94b9558f3e..8e9ffc4206 100644 --- a/teshsuite/simix/generic-simcalls/generic-simcalls.cpp +++ b/teshsuite/simix/generic-simcalls/generic-simcalls.cpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2016-2018. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2016-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -- 2.20.1