Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
new signal s4u::Host::onSpeedChange: when pstate is changed (or similar)
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 15 Feb 2017 15:19:28 +0000 (16:19 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 15 Feb 2017 15:19:28 +0000 (16:19 +0100)
ChangeLog
include/simgrid/s4u/host.hpp
src/s4u/s4u_host.cpp
src/surf/cpu_cas01.cpp
src/surf/cpu_interface.cpp
src/surf/plugins/host_energy.cpp

index 2af5b4a..b84978d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,8 +17,10 @@ SimGrid (3.15) UNRELEASED; urgency=low
 
  S4U
  - New callbacks:
-   - simgrid::s4u::onPlatformCreated: right before the simulation starts
-   - simgrid::s4u::onSimulationEnd: right after the main simulation loop
+   - s4u::onPlatformCreated: right before the simulation starts
+   - s4u::onSimulationEnd: right after the main simulation loop
+   - s4u::Host::onSpeedChange: when the pstate is changed, or when an
+     event from the availability_file changes the avail speed.
  - Links are now usable from s4u
 
  -- target_date=March 20 2017 -- Da SimGrid team <simgrid-devel@lists.gforge.inria.fr>
index 5251f3d..ad4c0a0 100644 (file)
@@ -124,6 +124,9 @@ public:
   static simgrid::xbt::signal<void(Host&)> onDestruction;
   /*** Called when the machine is turned on or off */
   static simgrid::xbt::signal<void(Host&)> onStateChange;
+  /*** Called when the speed of the machine is changed
+   * (either because of a pstate switch or because of an external load event coming from the profile) */
+  static simgrid::xbt::signal<void(Host&)> onSpeedChange;
 };
 
 }} // namespace simgrid::s4u
index ebf3823..0c91112 100644 (file)
@@ -40,6 +40,7 @@ namespace s4u {
 simgrid::xbt::signal<void(Host&)> Host::onCreation;
 simgrid::xbt::signal<void(Host&)> Host::onDestruction;
 simgrid::xbt::signal<void(Host&)> Host::onStateChange;
+simgrid::xbt::signal<void(Host&)> Host::onSpeedChange;
 
 Host::Host(const char* name)
   : name_(name)
index 04db0b1..f9835fa 100644 (file)
@@ -114,7 +114,7 @@ void CpuCas01::onSpeedChange() {
     CpuCas01Action* action = static_cast<CpuCas01Action*>(lmm_variable_id(var));
 
     lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(), speed_.scale * speed_.peak);
-    }
+  }
 
   Cpu::onSpeedChange();
 }
index 260f49c..768c419 100644 (file)
@@ -177,6 +177,7 @@ double Cpu::getAvailableSpeed()
 
 void Cpu::onSpeedChange() {
   TRACE_surf_host_set_speed(surf_get_clock(), cname(), coresAmount_ * speed_.scale * speed_.peak);
+  s4u::Host::onSpeedChange(*host_);
 }
 
 int Cpu::coreCount()
index 7a3029a..8aa4cc0 100644 (file)
@@ -57,8 +57,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_energy, surf, "Logging specific to the SURF
 namespace simgrid {
 namespace energy {
 
-class XBT_PRIVATE HostEnergy;
-
 class PowerRange {
 public:
   double idle;
@@ -286,7 +284,9 @@ static void onActionStateChange(simgrid::surf::CpuAction* action, simgrid::surf:
   }
 }
 
-static void onHostStateChange(simgrid::s4u::Host& host)
+/* This callback is fired either when the host change its state (on/off) or its speed
+ * (because the user changed the pstate, or because of external trace events) */
+static void onHostChange(simgrid::s4u::Host& host)
 {
   if (dynamic_cast<simgrid::s4u::VirtualMachine*>(&host)) // Ignore virtual machines
     return;
@@ -309,9 +309,8 @@ static void onHostDestruction(simgrid::s4u::Host& host)
 
 /* **************************** Public interface *************************** */
 /** \ingroup SURF_plugin_energy
- * \brief Enable energy plugin
- * \details Enable energy plugin to get joules consumption of each cpu. You should call this function before
- * #MSG_init().
+ * \brief Enable host energy plugin
+ * \details Enable energy plugin to get joules consumption of each cpu. Call this function before #MSG_init().
  */
 void sg_host_energy_plugin_init()
 {
@@ -321,7 +320,8 @@ void sg_host_energy_plugin_init()
   HostEnergy::EXTENSION_ID = simgrid::s4u::Host::extension_create<HostEnergy>();
 
   simgrid::s4u::Host::onCreation.connect(&onCreation);
-  simgrid::s4u::Host::onStateChange.connect(&onHostStateChange);
+  simgrid::s4u::Host::onStateChange.connect(&onHostChange);
+  simgrid::s4u::Host::onSpeedChange.connect(&onHostChange);
   simgrid::s4u::Host::onDestruction.connect(&onHostDestruction);
   simgrid::surf::CpuAction::onStateChange.connect(&onActionStateChange);
 }