From b4ace96f8a501a6659817d9741aeb103cbcfd2c4 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 7 Oct 2019 00:12:32 +0200 Subject: [PATCH] Merge similar signals, and other cleanups This change set is a bit large and some bits are brutal, but it escalated quickly and I went out of patience to finish it. --- include/simgrid/s4u/Exec.hpp | 10 ++- src/instr/instr_platform.cpp | 4 +- src/kernel/activity/ExecImpl.cpp | 5 -- src/kernel/activity/ExecImpl.hpp | 2 - src/plugins/dirty_page_tracking.cpp | 23 ++--- src/plugins/host_dvfs.cpp | 24 +++-- src/plugins/host_energy.cpp | 5 +- src/plugins/host_load.cpp | 88 +++++++++++++------ src/plugins/vm/VirtualMachineImpl.cpp | 43 ++++++--- src/s4u/s4u_Exec.cpp | 31 +++++-- .../plugins/load_balancer/LoadBalancer.cpp | 4 +- .../plugins/load_balancer/load_balancer.hpp | 2 +- src/smpi/plugins/sampi_loadbalancer.cpp | 6 +- 13 files changed, 160 insertions(+), 87 deletions(-) diff --git a/include/simgrid/s4u/Exec.hpp b/include/simgrid/s4u/Exec.hpp index 6aeb5fc76a..a3920f7a74 100644 --- a/include/simgrid/s4u/Exec.hpp +++ b/include/simgrid/s4u/Exec.hpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -43,8 +44,8 @@ public: friend XBT_PUBLIC void intrusive_ptr_release(Exec* e); friend XBT_PUBLIC void intrusive_ptr_add_ref(Exec* e); #endif - static xbt::signal on_start; - static xbt::signal on_completion; + static xbt::signal on_start; + static xbt::signal on_completion; virtual Exec* start() override = 0; virtual double get_remaining_ratio() = 0; @@ -68,6 +69,11 @@ public: Exec* cancel() override; const std::string& get_name() const { return name_; } const char* get_cname() const { return name_.c_str(); } + Host* get_host() const; + unsigned int get_host_number() const; + double get_start_time() const; + double get_finish_time() const; + double get_cost() const; }; class XBT_PUBLIC ExecSeq : public Exec { diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index fa042a83ac..f72c308a71 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -388,10 +388,10 @@ void instr_define_callbacks() simgrid::s4u::Actor::on_wake_up.connect([](simgrid::s4u::Actor const& actor) { simgrid::instr::Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->pop_event(); }); - simgrid::s4u::Exec::on_start.connect([](simgrid::s4u::Actor const& actor) { + simgrid::s4u::Exec::on_start.connect([](simgrid::s4u::Actor const& actor, simgrid::s4u::Exec const&) { simgrid::instr::Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->push_event("execute"); }); - simgrid::s4u::Exec::on_completion.connect([](simgrid::s4u::Actor const& actor) { + simgrid::s4u::Exec::on_completion.connect([](simgrid::s4u::Actor const& actor, simgrid::s4u::Exec const&) { simgrid::instr::Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->pop_event(); }); simgrid::s4u::Comm::on_sender_start.connect([](simgrid::s4u::Actor const& actor) { diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index 016f1e7609..a210ab0ef1 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -153,7 +153,6 @@ ExecImpl* ExecImpl::start() } XBT_DEBUG("Create execute synchro %p: %s", this, get_cname()); - ExecImpl::on_creation(*this); return this; } @@ -195,8 +194,6 @@ void ExecImpl::post() state_ = SIMIX_DONE; } - on_completion(*this); - clean_action(); if (timeout_detector_) { @@ -309,8 +306,6 @@ ActivityImpl* ExecImpl::migrate(s4u::Host* to) /************* * Callbacks * *************/ -xbt::signal ExecImpl::on_creation; -xbt::signal ExecImpl::on_completion; xbt::signal ExecImpl::on_migration; } // namespace activity diff --git a/src/kernel/activity/ExecImpl.hpp b/src/kernel/activity/ExecImpl.hpp index 524e3d15b1..86ac8a3cb8 100644 --- a/src/kernel/activity/ExecImpl.hpp +++ b/src/kernel/activity/ExecImpl.hpp @@ -45,8 +45,6 @@ public: void post() override; void finish() override; - static xbt::signal on_creation; - static xbt::signal on_completion; static xbt::signal on_migration; }; } // namespace activity diff --git a/src/plugins/dirty_page_tracking.cpp b/src/plugins/dirty_page_tracking.cpp index 684c2ad8ba..ebf4968f87 100644 --- a/src/plugins/dirty_page_tracking.cpp +++ b/src/plugins/dirty_page_tracking.cpp @@ -4,6 +4,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "simgrid/plugins/live_migration.h" +#include "simgrid/s4u/Exec.hpp" #include "src/kernel/activity/ExecImpl.hpp" #include "src/plugins/vm/VirtualMachineImpl.hpp" @@ -72,32 +73,34 @@ static void on_virtual_machine_creation(simgrid::vm::VirtualMachineImpl& vm) vm.extension_set(new simgrid::vm::DirtyPageTrackingExt()); } -static void on_exec_creation(simgrid::kernel::activity::ExecImpl const& exec) +static void on_exec_creation(simgrid::s4u::Actor const&, simgrid::s4u::Exec const& e) { - simgrid::s4u::VirtualMachine* vm = dynamic_cast(exec.get_host()); + auto exec = static_cast(e.get_impl()); + simgrid::s4u::VirtualMachine* vm = dynamic_cast(exec->get_host()); if (vm == nullptr) return; if (vm->get_impl()->extension()->is_tracking()) { - vm->get_impl()->extension()->track(&exec, exec.get_remaining()); + vm->get_impl()->extension()->track(exec, exec->get_remaining()); } else { - vm->get_impl()->extension()->track(&exec, 0.0); + vm->get_impl()->extension()->track(exec, 0.0); } } -static void on_exec_completion(simgrid::kernel::activity::ExecImpl const& exec) +static void on_exec_completion(simgrid::s4u::Actor const&, simgrid::s4u::Exec const& e) { - simgrid::s4u::VirtualMachine* vm = dynamic_cast(exec.get_host()); + auto exec = static_cast(e.get_impl()); + simgrid::s4u::VirtualMachine* vm = dynamic_cast(exec->get_host()); if (vm == nullptr) return; /* If we are in the middle of dirty page tracking, we record how much computation has been done until now, and keep * the information for the lookup_() function that will called soon. */ if (vm->get_impl()->extension()->is_tracking()) { - double delta = vm->get_impl()->extension()->get_stored_remains(&exec); + double delta = vm->get_impl()->extension()->get_stored_remains(exec); vm->get_impl()->extension()->update_dirty_page_count(delta); } - vm->get_impl()->extension()->untrack(&exec); + vm->get_impl()->extension()->untrack(exec); } void sg_vm_dirty_page_tracking_init() @@ -106,8 +109,8 @@ void sg_vm_dirty_page_tracking_init() simgrid::vm::DirtyPageTrackingExt::EXTENSION_ID = simgrid::vm::VirtualMachineImpl::extension_create(); simgrid::vm::VirtualMachineImpl::on_creation.connect(&on_virtual_machine_creation); - simgrid::kernel::activity::ExecImpl::on_creation.connect(&on_exec_creation); - simgrid::kernel::activity::ExecImpl::on_completion.connect(&on_exec_completion); + simgrid::s4u::Exec::on_start.connect(&on_exec_creation); + simgrid::s4u::Exec::on_completion.connect(&on_exec_completion); } } diff --git a/src/plugins/host_dvfs.cpp b/src/plugins/host_dvfs.cpp index 0159926bda..86eecf1527 100644 --- a/src/plugins/host_dvfs.cpp +++ b/src/plugins/host_dvfs.cpp @@ -293,19 +293,17 @@ public: task_id = 0; } }); - simgrid::kernel::activity::ExecImpl::on_creation.connect( - [this](simgrid::kernel::activity::ExecImpl const& activity) { - if (activity.get_host() == get_host()) - pre_task(); - }); - simgrid::kernel::activity::ExecImpl::on_completion.connect( - [this](simgrid::kernel::activity::ExecImpl const& activity) { - // For more than one host (not yet supported), we can access the host via - // simcalls_.front()->issuer->iface()->get_host() - if (activity.get_host() == get_host() && iteration_running) { - comp_timer += activity.surf_action_->get_finish_time() - activity.surf_action_->get_start_time(); - } - }); + simgrid::s4u::Exec::on_start.connect([this](simgrid::s4u::Actor const&, simgrid::s4u::Exec const& activity) { + if (activity.get_host() == get_host()) + pre_task(); + }); + simgrid::s4u::Exec::on_completion.connect([this](simgrid::s4u::Actor const&, simgrid::s4u::Exec const& activity) { + // For more than one host (not yet supported), we can access the host via + // simcalls_.front()->issuer->iface()->get_host() + if (activity.get_host() == get_host() && iteration_running) { + comp_timer += activity.get_finish_time() - activity.get_start_time(); + } + }); // FIXME I think that this fires at the same time for all hosts, so when the src sends something, // the dst will be notified even though it didn't even arrive at the recv yet simgrid::s4u::Link::on_communicate.connect( diff --git a/src/plugins/host_energy.cpp b/src/plugins/host_energy.cpp index b938f3fbcb..f1167b87a8 100644 --- a/src/plugins/host_energy.cpp +++ b/src/plugins/host_energy.cpp @@ -5,8 +5,9 @@ #include "simgrid/plugins/energy.h" #include "simgrid/s4u/Engine.hpp" -#include "src/kernel/activity/ExecImpl.hpp" +#include "simgrid/s4u/Exec.hpp" #include "src/include/surf/surf.hpp" +#include "src/kernel/activity/ExecImpl.hpp" #include "src/plugins/vm/VirtualMachineImpl.hpp" #include "src/surf/cpu_interface.hpp" @@ -515,7 +516,7 @@ void sg_host_energy_plugin_init() // that the next trigger would be the 2nd compute, hence ignoring the idle time // during the recv call. By updating at the beginning of a compute, we can // fix that. (If the cpu is not idle, this is not required.) - simgrid::kernel::activity::ExecImpl::on_creation.connect([](simgrid::kernel::activity::ExecImpl const& activity) { + simgrid::s4u::Exec::on_start.connect([](simgrid::s4u::Actor const&, simgrid::s4u::Exec const& activity) { if (activity.get_host_number() == 1) { // We only run on one host simgrid::s4u::Host* host = activity.get_host(); simgrid::s4u::VirtualMachine* vm = dynamic_cast(host); diff --git a/src/plugins/host_load.cpp b/src/plugins/host_load.cpp index 85828913ba..060577d454 100644 --- a/src/plugins/host_load.cpp +++ b/src/plugins/host_load.cpp @@ -9,12 +9,26 @@ #include "src/plugins/vm/VirtualMachineImpl.hpp" #include +// Makes sure that this plugin can be activated from the command line with ``--plugin=name`` SIMGRID_REGISTER_PLUGIN(host_load, "Cpu load", &sg_host_load_plugin_init) -/** @addtogroup plugin_load +/** @defgroup plugin_host_load -This plugin makes it very simple for users to obtain the current load for each host. + @rst +Simple plugin that monitors the current load for each host. + +In addition, this constitutes a good introductory example on how to write a plugin. +It attaches an extension to each host to store some data, and places callbacks in the following signals: + + - :cpp:member:`simgrid::s4u::Host::on_creation`: Attach a new extension to the newly created host. + - :cpp:member:`simgrid::s4u::Exec::on_start`: Make note that a new execution started, increasing the load. + - :cpp:member:`simgrid::s4u::Exec::on_completion`: Make note that an execution completed, decreasing the load. + - :cpp:member:`simgrid::s4u::Host::on_state_change`: Do what is appropriate when the host gets suspended, turned off or similar. + - :cpp:member:`simgrid::s4u::Host::on_speed_change`: Do what is appropriate when the DVFS is modified. + + Note that extensions are automatically destroyed when the host gets destroyed. + @endrst */ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_plugin_load, surf, "Logging specific to the HostLoad plugin"); @@ -24,6 +38,21 @@ namespace plugin { static const double activity_uninitialized_remaining_cost = -1; +/** This class stores the extra data needed by this plugin about a given host + * + * It is stored as an extension of s4u::Host. Such extensions are retrieved by type as follows: + * + * @verbatim + * simgrid::s4u::Host* this_host = ???; + * this_extension = host->extension(); + * @endverbatim + * + * If no extension of that type was ever attached to the inspected object, the ``extension()`` template returns + * nullptr. + * + * Please refer to the implementation of ``sg_host_load_plugin_init()`` to see the extension objects are attached to + * hosts at initialization time. + */ class HostLoad { public: static simgrid::xbt::Extension EXTENSION_ID; @@ -55,13 +84,13 @@ public: /** Return idle time over the whole simulation */ double get_total_idle_time() { update(); return total_idle_time_; } void update(); - void add_activity(simgrid::kernel::activity::ExecImplPtr activity); + void add_activity(simgrid::kernel::activity::ExecImpl* activity); void reset(); private: simgrid::s4u::Host* host_ = nullptr; /* Stores all currently ongoing activities (computations) on this machine */ - std::map current_activities; + std::map current_activities; double last_updated_ = 0; double last_reset_ = 0; /** @@ -76,13 +105,14 @@ private: double current_flops_ = 0; double computed_flops_ = 0; double idle_time_ = 0; - double total_idle_time_ = 0; /* This gets never reset */ + double total_idle_time_ = 0; /* This updated but never gets reset */ double theor_max_flops_ = 0; }; +// Create the static field that the extension mechanism needs simgrid::xbt::Extension HostLoad::EXTENSION_ID; -void HostLoad::add_activity(simgrid::kernel::activity::ExecImplPtr activity) +void HostLoad::add_activity(simgrid::kernel::activity::ExecImpl* activity) { current_activities.insert({activity, activity_uninitialized_remaining_cost}); } @@ -180,7 +210,7 @@ static void on_host_change(simgrid::s4u::Host const& host) /* **************************** Public interface *************************** */ /** @brief Initializes the HostLoad plugin - * @details The HostLoad plugin provides an API to get the current load of each host. + * @ingroup plugin_host_load */ void sg_host_load_plugin_init() { @@ -205,14 +235,14 @@ void sg_host_load_plugin_init() host.extension_set(new HostLoad(&host)); }); - simgrid::kernel::activity::ExecImpl::on_creation.connect([](simgrid::kernel::activity::ExecImpl& activity) { + simgrid::s4u::Exec::on_start.connect([](simgrid::s4u::Actor const&, simgrid::s4u::Exec const& activity) { if (activity.get_host_number() == 1) { // We only run on one host simgrid::s4u::Host* host = activity.get_host(); simgrid::s4u::VirtualMachine* vm = dynamic_cast(host); if (vm != nullptr) host = vm->get_pm(); xbt_assert(host != nullptr); - host->extension()->add_activity(&activity); + host->extension()->add_activity(static_cast(activity.get_impl())); host->extension()->update(); // If the system was idle until now, we need to update *before* // this computation starts running so we can keep track of the // idle time. (Communication operations don't trigger this hook!) @@ -221,7 +251,7 @@ void sg_host_load_plugin_init() XBT_WARN("HostLoad plugin currently does not support executions on several hosts"); } }); - simgrid::kernel::activity::ExecImpl::on_completion.connect([](simgrid::kernel::activity::ExecImpl const& activity) { + simgrid::s4u::Exec::on_completion.connect([](simgrid::s4u::Actor const&, simgrid::s4u::Exec const& activity) { if (activity.get_host_number() == 1) { // We only run on one host simgrid::s4u::Host* host = activity.get_host(); simgrid::s4u::VirtualMachine* vm = dynamic_cast(host); @@ -239,61 +269,61 @@ void sg_host_load_plugin_init() } /** @brief Returns the current load of that host, as a ratio = achieved_flops / (core_current_speed * core_amount) - * - * See simgrid::plugin::HostLoad::get_current_load() for the full documentation. + * @ingroup plugin_host_load */ double sg_host_get_current_load(sg_host_t host) { - xbt_assert(HostLoad::EXTENSION_ID.valid(), - "The Load plugin is not active. Please call sg_host_load_plugin_init() during initialization."); + xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin."); return host->extension()->get_current_load(); } -/** @brief Returns the current load of the host passed as argument - * - * See also @ref plugin_load +/** @brief Returns the current load of that host + * @ingroup plugin_host_load */ double sg_host_get_avg_load(sg_host_t host) { - xbt_assert(HostLoad::EXTENSION_ID.valid(), - "The Load plugin is not active. Please call sg_host_load_plugin_init() during initialization."); + xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin."); return host->extension()->get_average_load(); } /** @brief Returns the time this host was idle since the last reset - * - * See also @ref plugin_load + * @ingroup plugin_host_load */ double sg_host_get_idle_time(sg_host_t host) { - xbt_assert(HostLoad::EXTENSION_ID.valid(), - "The Load plugin is not active. Please call sg_host_load_plugin_init() during initialization."); + xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin."); return host->extension()->get_idle_time(); } +/** @brief Returns the time this host was idle since the beginning of the simulation + * @ingroup plugin_host_load + */ double sg_host_get_total_idle_time(sg_host_t host) { - xbt_assert(HostLoad::EXTENSION_ID.valid(), - "The Load plugin is not active. Please call sg_host_load_plugin_init() during initialization."); + xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin."); return host->extension()->get_total_idle_time(); } +/** @brief Returns the amount of flops computed by that host since the last reset + * @ingroup plugin_host_load + */ double sg_host_get_computed_flops(sg_host_t host) { - xbt_assert(HostLoad::EXTENSION_ID.valid(), - "The Load plugin is not active. Please call sg_host_load_plugin_init() during initialization."); + xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin."); return host->extension()->get_computed_flops(); } +/** @brief Resets the idle time and flops amount of that host + * @ingroup plugin_host_load + */ void sg_host_load_reset(sg_host_t host) { - xbt_assert(HostLoad::EXTENSION_ID.valid(), - "The Load plugin is not active. Please call sg_host_load_plugin_init() during initialization."); + xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin."); host->extension()->reset(); } diff --git a/src/plugins/vm/VirtualMachineImpl.cpp b/src/plugins/vm/VirtualMachineImpl.cpp index deecf72441..2776c8dfef 100644 --- a/src/plugins/vm/VirtualMachineImpl.cpp +++ b/src/plugins/vm/VirtualMachineImpl.cpp @@ -5,6 +5,7 @@ #include "src/plugins/vm/VirtualMachineImpl.hpp" #include "simgrid/Exception.hpp" +#include "simgrid/s4u/Exec.hpp" #include "src/include/surf/surf.hpp" #include "src/kernel/activity/ExecImpl.hpp" @@ -51,25 +52,45 @@ static void host_state_change(s4u::Host const& host) } } -static s4u::VirtualMachine* get_vm_from_task(kernel::activity::ActivityImpl const& task) +static void add_active_exec(s4u::Actor const&, s4u::Exec const& task) { - auto* exec = dynamic_cast(&task); + s4u::VirtualMachine* vm = dynamic_cast(task.get_host()); + if (vm != nullptr) { + VirtualMachineImpl* vm_impl = vm->get_impl(); + vm_impl->active_tasks_ = vm_impl->active_tasks_ + 1; + vm_impl->update_action_weight(); + } +} + +static void remove_active_exec(s4u::Actor const&, s4u::Exec const& task) +{ + s4u::VirtualMachine* vm = dynamic_cast(task.get_host()); + if (vm != nullptr) { + VirtualMachineImpl* vm_impl = vm->get_impl(); + vm_impl->active_tasks_ = vm_impl->active_tasks_ - 1; + vm_impl->update_action_weight(); + } +} + +static s4u::VirtualMachine* get_vm_from_activity(kernel::activity::ActivityImpl const& act) +{ + auto* exec = dynamic_cast(&act); return exec != nullptr ? dynamic_cast(exec->get_host()) : nullptr; } -static void add_active_task(kernel::activity::ActivityImpl const& task) +static void add_active_activity(kernel::activity::ActivityImpl const& act) { - s4u::VirtualMachine* vm = get_vm_from_task(task); + s4u::VirtualMachine* vm = get_vm_from_activity(act); if (vm != nullptr) { VirtualMachineImpl *vm_impl = vm->get_impl(); vm_impl->active_tasks_ = vm_impl->active_tasks_ + 1; - vm_impl->update_action_weight(); + vm_impl->update_action_weight(); } } -static void remove_active_task(kernel::activity::ActivityImpl const& task) +static void remove_active_activity(kernel::activity::ActivityImpl const& act) { - s4u::VirtualMachine* vm = get_vm_from_task(task); + s4u::VirtualMachine* vm = get_vm_from_activity(act); if (vm != nullptr) { VirtualMachineImpl *vm_impl = vm->get_impl(); vm_impl->active_tasks_ = vm_impl->active_tasks_ - 1; @@ -81,10 +102,10 @@ VMModel::VMModel() { all_existing_models.push_back(this); s4u::Host::on_state_change.connect(host_state_change); - kernel::activity::ExecImpl::on_creation.connect(add_active_task); - kernel::activity::ExecImpl::on_completion.connect(remove_active_task); - kernel::activity::ActivityImpl::on_resumed.connect(add_active_task); - kernel::activity::ActivityImpl::on_suspended.connect(remove_active_task); + s4u::Exec::on_start.connect(add_active_exec); + s4u::Exec::on_completion.connect(remove_active_exec); + kernel::activity::ActivityImpl::on_resumed.connect(add_active_activity); + kernel::activity::ActivityImpl::on_suspended.connect(remove_active_activity); } double VMModel::next_occuring_event(double now) diff --git a/src/s4u/s4u_Exec.cpp b/src/s4u/s4u_Exec.cpp index 48d7d4da31..698c1b1261 100644 --- a/src/s4u/s4u_Exec.cpp +++ b/src/s4u/s4u_Exec.cpp @@ -12,8 +12,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_exec, s4u_activity, "S4U asynchronous execut namespace simgrid { namespace s4u { -xbt::signal Exec::on_start; -xbt::signal Exec::on_completion; +xbt::signal Exec::on_start; +xbt::signal Exec::on_completion; Exec::Exec() { @@ -44,7 +44,7 @@ Exec* Exec::wait() start(); simcall_execution_wait(pimpl_); state_ = State::FINISHED; - on_completion(*Actor::self()); + on_completion(*Actor::self(), *this); return this; } @@ -105,6 +105,27 @@ ExecPtr Exec::set_name(const std::string& name) return this; } +Host* Exec::get_host() const +{ + return static_cast(pimpl_.get())->get_host(); +} +unsigned int Exec::get_host_number() const +{ + return static_cast(pimpl_.get())->get_host_number(); +} +double Exec::get_start_time() const +{ + return (pimpl_->surf_action_ == nullptr) ? -1 : pimpl_->surf_action_->get_start_time(); +} +double Exec::get_finish_time() const +{ + return (pimpl_->surf_action_ == nullptr) ? -1 : pimpl_->surf_action_->get_finish_time(); +} +double Exec::get_cost() const +{ + return (pimpl_->surf_action_ == nullptr) ? -1 : pimpl_->surf_action_->get_cost(); +} + /** @brief Change the execution priority, don't you think? * * An execution with twice the priority will get twice the amount of flops when the resource is shared. @@ -144,7 +165,7 @@ Exec* ExecSeq::start() .start(); }); state_ = State::STARTED; - on_start(*Actor::self()); + on_start(*Actor::self(), *this); return this; } @@ -206,7 +227,7 @@ Exec* ExecPar::start() .start(); }); state_ = State::STARTED; - on_start(*Actor::self()); + on_start(*Actor::self(), *this); return this; } diff --git a/src/smpi/plugins/load_balancer/LoadBalancer.cpp b/src/smpi/plugins/load_balancer/LoadBalancer.cpp index a83ae07036..cc67e00628 100644 --- a/src/smpi/plugins/load_balancer/LoadBalancer.cpp +++ b/src/smpi/plugins/load_balancer/LoadBalancer.cpp @@ -136,9 +136,9 @@ simgrid::s4u::Host* LoadBalancer::get_mapping(simgrid::s4u::ActorPtr actor) return new_mapping.get_host(actor); } -void LoadBalancer::record_actor_computation(simgrid::s4u::ActorPtr actor, double load) +void LoadBalancer::record_actor_computation(simgrid::s4u::Actor const& actor, double load) { - actor_computation[actor->get_pid()] += load; + actor_computation[actor.get_pid()] += load; } } } diff --git a/src/smpi/plugins/load_balancer/load_balancer.hpp b/src/smpi/plugins/load_balancer/load_balancer.hpp index c58920bf61..4924337984 100644 --- a/src/smpi/plugins/load_balancer/load_balancer.hpp +++ b/src/smpi/plugins/load_balancer/load_balancer.hpp @@ -67,7 +67,7 @@ public: * FIXME These are functions used for testing and should be re-written or removed */ simgrid::s4u::Host* get_mapping(simgrid::s4u::ActorPtr); - void record_actor_computation(simgrid::s4u::ActorPtr actor, double load); + void record_actor_computation(simgrid::s4u::Actor const& actor, double load); }; } diff --git a/src/smpi/plugins/sampi_loadbalancer.cpp b/src/smpi/plugins/sampi_loadbalancer.cpp index 59f5914af9..c58d907eaf 100644 --- a/src/smpi/plugins/sampi_loadbalancer.cpp +++ b/src/smpi/plugins/sampi_loadbalancer.cpp @@ -136,9 +136,9 @@ void sg_load_balancer_plugin_init() static bool done = false; if (!done) { done = true; - simgrid::kernel::activity::ExecImpl::on_completion.connect([](simgrid::kernel::activity::ExecImpl const& activity) { - simgrid::smpi::plugin::lb.record_actor_computation(activity.simcalls_.front()->issuer_->iface(), - activity.surf_action_->get_cost()); + simgrid::s4u::Exec::on_completion.connect([](simgrid::s4u::Actor const& actor, simgrid::s4u::Exec const& exec) { + + simgrid::smpi::plugin::lb.record_actor_computation(actor, exec.get_cost()); }); xbt_replay_action_register( -- 2.20.1