Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[HostLoad] Add method HostLoad::add_activity(ExecImplPtr)
authorChristian Heinrich <franz-christian.heinrich@inria.fr>
Thu, 26 Jul 2018 09:22:22 +0000 (11:22 +0200)
committerChristian Heinrich <franz-christian.heinrich@inria.fr>
Thu, 26 Jul 2018 14:45:10 +0000 (16:45 +0200)
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.

src/plugins/host_load.cpp

index c12ac69..0c6a9e5 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "simgrid/plugins/load.h"
 #include "src/include/surf/surf.hpp"
 
 #include "simgrid/plugins/load.h"
 #include "src/include/surf/surf.hpp"
+#include "src/kernel/activity/ExecImpl.hpp"
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
 #include <simgrid/s4u.hpp>
 
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
 #include <simgrid/s4u.hpp>
 
@@ -21,6 +22,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_plugin_load, surf, "Logging specific to the
 namespace simgrid {
 namespace plugin {
 
 namespace simgrid {
 namespace plugin {
 
+static const double activity_uninitialized_remaining_cost = -1;
+
 class HostLoad {
 public:
   static simgrid::xbt::Extension<simgrid::s4u::Host, HostLoad> EXTENSION_ID;
 class HostLoad {
 public:
   static simgrid::xbt::Extension<simgrid::s4u::Host, HostLoad> 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();
   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;
   void reset();
 
 private:
   simgrid::s4u::Host* host_ = nullptr;
+  /* Stores all currently ongoing activities (computations) on this machine */
+  std::map<simgrid::kernel::activity::ExecImplPtr, /* cost still remaining*/double> current_activities;
   double last_updated_      = 0;
   double last_reset_        = 0;
   /**
   double last_updated_      = 0;
   double last_reset_        = 0;
   /**
@@ -69,6 +75,11 @@ private:
 
 simgrid::xbt::Extension<simgrid::s4u::Host, HostLoad> HostLoad::EXTENSION_ID;
 
 
 simgrid::xbt::Extension<simgrid::s4u::Host, HostLoad> 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();
 void HostLoad::update()
 {
   double now = surf_get_clock();