From: Christian Heinrich Date: Thu, 26 Jul 2018 09:22:22 +0000 (+0200) Subject: [HostLoad] Add method HostLoad::add_activity(ExecImplPtr) X-Git-Tag: v3_21~355^2~14 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/485f3ec7397ce81a0e05a413697723ff088f8aaf [HostLoad] Add method HostLoad::add_activity(ExecImplPtr) The HostLoad plugin keeps track of all the computations that are going on and does no longer have to rely on calculations of the sort time_passed*speed. Instead, we can now access the total cost of the computation and keep track of how much is still remaining. Like this, we always account for exactly the cost of that calculation. --- diff --git a/src/plugins/host_load.cpp b/src/plugins/host_load.cpp index c12ac691cd..0c6a9e544c 100644 --- a/src/plugins/host_load.cpp +++ b/src/plugins/host_load.cpp @@ -5,6 +5,7 @@ #include "simgrid/plugins/load.h" #include "src/include/surf/surf.hpp" +#include "src/kernel/activity/ExecImpl.hpp" #include "src/plugins/vm/VirtualMachineImpl.hpp" #include @@ -21,6 +22,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_plugin_load, surf, "Logging specific to the namespace simgrid { namespace plugin { +static const double activity_uninitialized_remaining_cost = -1; + class HostLoad { public: static simgrid::xbt::Extension EXTENSION_ID; @@ -45,10 +48,13 @@ public: double get_idle_time() { update(); return idle_time_; } /** Return idle time since last reset */ double get_total_idle_time() { update(); return total_idle_time_; } /** Return idle time over the whole simulation */ void update(); + void add_activity(simgrid::kernel::activity::ExecImplPtr activity); void reset(); private: simgrid::s4u::Host* host_ = nullptr; + /* Stores all currently ongoing activities (computations) on this machine */ + std::map current_activities; double last_updated_ = 0; double last_reset_ = 0; /** @@ -69,6 +75,11 @@ private: simgrid::xbt::Extension HostLoad::EXTENSION_ID; +void HostLoad::add_activity(simgrid::kernel::activity::ExecImplPtr activity) +{ + current_activities.insert({activity, activity_uninitialized_remaining_cost}); +} + void HostLoad::update() { double now = surf_get_clock();