From: Martin Quinson Date: Mon, 14 May 2018 20:52:59 +0000 (+0200) Subject: Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid X-Git-Tag: v3.20~230 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/30e93357d63b0846afb6a60db2004b6761607103?hp=a53d7cf0445e5a6c3f2bb6606e6bd3b2b33b7867 Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid --- diff --git a/include/simgrid/s4u/Host.hpp b/include/simgrid/s4u/Host.hpp index 0a3c3c94a7..b62ab7aa2e 100644 --- a/include/simgrid/s4u/Host.hpp +++ b/include/simgrid/s4u/Host.hpp @@ -123,12 +123,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 @@ -139,14 +143,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 @@ -154,18 +158,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 cb72c4e8b2..6eff60534b 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -382,8 +382,8 @@ 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::onSpeedChange.connect(instr_host_on_speed_change); + simgrid::s4u::Host::on_creation.connect(instr_host_on_creation); + simgrid::s4u::Host::on_speed_change.connect(instr_host_on_speed_change); simgrid::s4u::Link::on_creation.connect(instr_link_on_creation); simgrid::s4u::Link::on_bandwidth_change.connect(instr_link_on_bandwidth_change); } @@ -403,12 +403,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 0e9445657c..a9a58c0e77 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); }); } } @@ -249,13 +249,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/simix/smx_host.cpp b/src/simix/smx_host.cpp index a2cc7678be..3e9573a26e 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -210,16 +210,14 @@ void simcall_HANDLER_execution_wait(smx_simcall_t simcall, smx_activity_t synchr void simcall_HANDLER_execution_test(smx_simcall_t simcall, smx_activity_t synchro) { - simcall_execution_test__set__result(simcall, (synchro->state_ != SIMIX_WAITING && synchro->state_ != SIMIX_RUNNING)); - if (simcall_execution_test__get__result(simcall)) { + int res = (synchro->state_ != SIMIX_WAITING && synchro->state_ != SIMIX_RUNNING); + if (res) { synchro->simcalls_.push_back(simcall); SIMIX_execution_finish(synchro); } else { SIMIX_simcall_answer(simcall); } - /* If the synchro is already finished then perform the error handling */ - if (synchro->state_ != SIMIX_RUNNING) - SIMIX_execution_finish(synchro); + simcall_execution_test__set__result(simcall, res); } void SIMIX_execution_finish(smx_activity_t synchro) diff --git a/src/simix/smx_network.cpp b/src/simix/smx_network.cpp index 72f03f7c4d..649154b07a 100644 --- a/src/simix/smx_network.cpp +++ b/src/simix/smx_network.cpp @@ -339,19 +339,17 @@ void simcall_HANDLER_comm_test(smx_simcall_t simcall, smx_activity_t synchro) simgrid::kernel::activity::CommImplPtr comm = boost::static_pointer_cast(synchro); + int res; + if (MC_is_active() || MC_record_replay_is_active()){ - simcall_comm_test__set__result(simcall, comm->src_proc && comm->dst_proc); - if (simcall_comm_test__get__result(simcall)){ + res = comm->src_proc && comm->dst_proc; + if (res) synchro->state_ = SIMIX_DONE; - synchro->simcalls_.push_back(simcall); - SIMIX_comm_finish(synchro); - } else { - SIMIX_simcall_answer(simcall); - } - return; + } else { + res = synchro->state_ != SIMIX_WAITING && synchro->state_ != SIMIX_RUNNING; } - simcall_comm_test__set__result(simcall, (synchro->state_ != SIMIX_WAITING && synchro->state_ != SIMIX_RUNNING)); + simcall_comm_test__set__result(simcall, res); if (simcall_comm_test__get__result(simcall)) { synchro->simcalls_.push_back(simcall); SIMIX_comm_finish(synchro); 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 e18c775b77..05fbd12bf9 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -133,7 +133,7 @@ double Cpu::get_available_speed() } void Cpu::onSpeedChange() { - 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. */