Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge similar signals, and other cleanups
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 6 Oct 2019 22:12:32 +0000 (00:12 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 6 Oct 2019 22:15:04 +0000 (00:15 +0200)
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.

13 files changed:
include/simgrid/s4u/Exec.hpp
src/instr/instr_platform.cpp
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/ExecImpl.hpp
src/plugins/dirty_page_tracking.cpp
src/plugins/host_dvfs.cpp
src/plugins/host_energy.cpp
src/plugins/host_load.cpp
src/plugins/vm/VirtualMachineImpl.cpp
src/s4u/s4u_Exec.cpp
src/smpi/plugins/load_balancer/LoadBalancer.cpp
src/smpi/plugins/load_balancer/load_balancer.hpp
src/smpi/plugins/sampi_loadbalancer.cpp

index 6aeb5fc..a3920f7 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <simgrid/forward.h>
 #include <simgrid/s4u/Activity.hpp>
+#include <simgrid/s4u/Actor.hpp>
 #include <xbt/ex.h>
 
 #include <atomic>
@@ -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<void(Actor const&)> on_start;
-  static xbt::signal<void(Actor const&)> on_completion;
+  static xbt::signal<void(Actor const&, Exec const&)> on_start;
+  static xbt::signal<void(Actor const&, Exec const&)> 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 {
index fa042a8..f72c308 100644 (file)
@@ -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) {
index 016f1e7..a210ab0 100644 (file)
@@ -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<void(ExecImpl&)> ExecImpl::on_creation;
-xbt::signal<void(ExecImpl const&)> ExecImpl::on_completion;
 xbt::signal<void(ExecImpl const&, s4u::Host*)> ExecImpl::on_migration;
 
 } // namespace activity
index 524e3d1..86ac8a3 100644 (file)
@@ -45,8 +45,6 @@ public:
   void post() override;
   void finish() override;
 
-  static xbt::signal<void(ExecImpl&)> on_creation;
-  static xbt::signal<void(ExecImpl const&)> on_completion;
   static xbt::signal<void(ExecImpl const&, s4u::Host*)> on_migration;
 };
 } // namespace activity
index 684c2ad..ebf4968 100644 (file)
@@ -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<simgrid::vm::DirtyPageTrackingExt>(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<simgrid::s4u::VirtualMachine*>(exec.get_host());
+  auto exec                        = static_cast<simgrid::kernel::activity::ExecImpl*>(e.get_impl());
+  simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(exec->get_host());
   if (vm == nullptr)
     return;
 
   if (vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->is_tracking()) {
-    vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->track(&exec, exec.get_remaining());
+    vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->track(exec, exec->get_remaining());
   } else {
-    vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->track(&exec, 0.0);
+    vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->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<simgrid::s4u::VirtualMachine*>(exec.get_host());
+  auto exec                        = static_cast<simgrid::kernel::activity::ExecImpl*>(e.get_impl());
+  simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(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<simgrid::vm::DirtyPageTrackingExt>()->is_tracking()) {
-    double delta = vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->get_stored_remains(&exec);
+    double delta = vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->get_stored_remains(exec);
     vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->update_dirty_page_count(delta);
   }
-  vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->untrack(&exec);
+  vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->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::DirtyPageTrackingExt>();
     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);
   }
 }
 
index 0159926..86eecf1 100644 (file)
@@ -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(
index b938f3f..f1167b8 100644 (file)
@@ -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<simgrid::s4u::VirtualMachine*>(host);
index 8582891..060577d 100644 (file)
@@ -9,12 +9,26 @@
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
 #include <simgrid/s4u.hpp>
 
+// 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<HostLoad>();
+ * @endverbatim
+ *
+ * If no extension of that type was ever attached to the inspected object, the ``extension<X>()`` 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<simgrid::s4u::Host, HostLoad> 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<simgrid::kernel::activity::ExecImplPtr, /* cost still remaining*/double> current_activities;
+  std::map<simgrid::kernel::activity::ExecImpl*, /* cost still remaining*/ double> 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<simgrid::s4u::Host, HostLoad> 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<simgrid::s4u::VirtualMachine*>(host);
       if (vm != nullptr)
         host = vm->get_pm();
       xbt_assert(host != nullptr);
-      host->extension<HostLoad>()->add_activity(&activity);
+      host->extension<HostLoad>()->add_activity(static_cast<simgrid::kernel::activity::ExecImpl*>(activity.get_impl()));
       host->extension<HostLoad>()->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<simgrid::s4u::VirtualMachine*>(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<HostLoad>()->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<HostLoad>()->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<HostLoad>()->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<HostLoad>()->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<HostLoad>()->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<HostLoad>()->reset();
 }
index deecf72..2776c8d 100644 (file)
@@ -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<kernel::activity::ExecImpl const*>(&task);
+  s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(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<s4u::VirtualMachine*>(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<kernel::activity::ExecImpl const*>(&act);
   return exec != nullptr ? dynamic_cast<s4u::VirtualMachine*>(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)
index 48d7d4d..698c1b1 100644 (file)
@@ -12,8 +12,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_exec, s4u_activity, "S4U asynchronous execut
 
 namespace simgrid {
 namespace s4u {
-xbt::signal<void(Actor const&)> Exec::on_start;
-xbt::signal<void(Actor const&)> Exec::on_completion;
+xbt::signal<void(Actor const&, Exec const&)> Exec::on_start;
+xbt::signal<void(Actor const&, Exec const&)> 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<kernel::activity::ExecImpl*>(pimpl_.get())->get_host();
+}
+unsigned int Exec::get_host_number() const
+{
+  return static_cast<kernel::activity::ExecImpl*>(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;
 }
 
index a83ae07..cc67e00 100644 (file)
@@ -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;
 }
 }
 }
index c58920b..4924337 100644 (file)
@@ -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);
 };
 
 }
index 59f5914..c58d907 100644 (file)
@@ -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(