Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanings in k:r:Cpu
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 22 May 2018 06:29:33 +0000 (08:29 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 22 May 2018 06:47:08 +0000 (08:47 +0200)
12 files changed:
src/s4u/s4u_Host.cpp
src/surf/cpu_cas01.cpp
src/surf/cpu_cas01.hpp
src/surf/cpu_interface.cpp
src/surf/cpu_interface.hpp
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp
src/surf/plugins/host_energy.cpp
src/surf/ptask_L07.cpp
src/surf/ptask_L07.hpp
src/surf/sg_platf.cpp
src/surf/xml/surfxml_parseplatf.cpp

index cdbc5a9..3ac5c47 100644 (file)
@@ -223,17 +223,24 @@ void Host::set_property(std::string key, std::string value)
 /** @brief Get the peak processor speed (in flops/s), at the specified pstate  */
 double Host::getPstateSpeed(int pstate_index)
 {
-  return simgrid::simix::simcall([this, pstate_index] { return this->pimpl_cpu->getPstateSpeed(pstate_index); });
+  return simgrid::simix::simcall([this, pstate_index] { return this->pimpl_cpu->get_pstate_peak_speed(pstate_index); });
 }
 
-/** @brief Get the peak processor speed in flops/s, (under full load (=1.0), at the current pstate) */
+/** @brief Get the peak processor speed in flops/s, (under full load (=1.0), at the current pstate)
+ *
+ *  The result also takes the external load into account.
+ */
 double Host::getSpeed()
 {
-  return this->pimpl_cpu->getSpeed(1.0);
+  return this->pimpl_cpu->get_speed(1.0);
 }
+/** @brief Get the available speed ratio, between 0 and 1.
+ *
+ * This accounts for external load (see @ref set_speed_trace()).
+ */
 double Host::get_available_speed()
 {
-  return this->pimpl_cpu->get_available_speed();
+  return this->pimpl_cpu->get_speed_ratio();
 }
 
 /** @brief Returns the number of core of the processor. */
index e06a155..92d582d 100644 (file)
@@ -98,7 +98,8 @@ bool CpuCas01::is_used()
 }
 
 /** @brief take into account changes of speed (either load or max) */
-void CpuCas01::onSpeedChange() {
+void CpuCas01::on_speed_change()
+{
   kernel::lmm::Variable* var = nullptr;
   const kernel::lmm::Element* elem = nullptr;
 
@@ -111,7 +112,7 @@ void CpuCas01::onSpeedChange() {
                                                             action->requested_core() * speed_.scale * speed_.peak);
   }
 
-  Cpu::onSpeedChange();
+  Cpu::on_speed_change();
 }
 
 void CpuCas01::apply_event(tmgr_trace_event_t event, double value)
@@ -121,7 +122,7 @@ void CpuCas01::apply_event(tmgr_trace_event_t event, double value)
     xbt_assert(get_cores_count() == 1, "FIXME: add speed scaling code also for constraint_core[i]");
 
     speed_.scale = value;
-    onSpeedChange();
+    on_speed_change();
 
     tmgr_trace_event_unref(&speed_.event);
   } else if (event == state_event_) {
index 84f7fb9..139c303 100644 (file)
@@ -45,7 +45,7 @@ public:
   bool is_used() override;
 
 protected:
-  void onSpeedChange() override;
+  void on_speed_change() override;
 };
 
 /**********
index 7fffcb5..245c019 100644 (file)
@@ -97,7 +97,7 @@ void Cpu::set_pstate(int pstate_index)
   pstate_ = pstate_index;
   speed_.peak = new_peak_speed;
 
-  onSpeedChange();
+  on_speed_change();
 }
 
 int Cpu::get_pstate()
@@ -105,7 +105,7 @@ int Cpu::get_pstate()
   return pstate_;
 }
 
-double Cpu::getPstateSpeed(int pstate_index)
+double Cpu::get_pstate_peak_speed(int pstate_index)
 {
   xbt_assert((pstate_index <= static_cast<int>(speed_per_pstate_.size())),
              "Invalid parameters (pstate index out of bounds)");
@@ -113,18 +113,19 @@ double Cpu::getPstateSpeed(int pstate_index)
   return speed_per_pstate_[pstate_index];
 }
 
-double Cpu::getSpeed(double load)
+double Cpu::get_speed(double load)
 {
   return load * speed_.peak;
 }
 
-double Cpu::get_available_speed()
+double Cpu::get_speed_ratio()
 {
 /* number between 0 and 1 */
   return speed_.scale;
 }
 
-void Cpu::onSpeedChange() {
+void Cpu::on_speed_change()
+{
   s4u::Host::on_speed_change(*host_);
 }
 
@@ -133,7 +134,7 @@ int Cpu::get_cores_count()
   return cores_count_;
 }
 
-void Cpu::setStateTrace(tmgr_trace_t trace)
+void Cpu::set_state_trace(tmgr_trace_t trace)
 {
   xbt_assert(state_event_ == nullptr, "Cannot set a second state trace to Host %s", host_->get_cname());
 
index 73f12a1..5cb4464 100644 (file)
@@ -105,19 +105,30 @@ public:
   /** @brief Get the amount of cores */
   virtual int get_cores_count();
 
-  /** @brief Get the speed, accounting for the trace load and provided process load instead of the real current one */
-  virtual double getSpeed(double load);
+  /** @brief Get a forecast of the speed (in flops/s) if the load were as provided.
+   *
+   * The provided load encompasses both the application's activities and the external load that come from a trace.
+   *
+   * Use a load of 1.0 to compute the amount of flops that the Cpu would deliver with one CPU-bound task.
+   * If you use a load of 0, this function will return 0: when nobody is using the Cpu, it delivers nothing.
+   *
+   * If you want to know the amount of flops currently delivered, use  load = get_load()*get_speed_ratio()
+   */
+  virtual double get_speed(double load);
 
 protected:
   /** @brief Take speed changes (either load or max) into account */
-  virtual void onSpeedChange();
+  virtual void on_speed_change();
 
 public:
-  /** @brief Get the available speed of the current Cpu */
-  virtual double get_available_speed();
+  /** @brief Get the available speed ratio, between 0 and 1.
+   *
+   * This accounts for external load (see @ref set_speed_trace()).
+   */
+  virtual double get_speed_ratio();
 
-  /** @brief Get the current Cpu computational speed */
-  virtual double getPstateSpeed(int pstate_index);
+  /** @brief Get the peak processor speed (in flops/s), at the specified pstate */
+  virtual double get_pstate_peak_speed(int pstate_index);
 
   virtual int get_pstates_count();
   virtual void set_pstate(int pstate_index);
@@ -129,14 +140,14 @@ private:
   int cores_count_ = 1;
   simgrid::s4u::Host* host_;
 
-  int pstate_ = 0;                     /*< Current pstate (index in the speedPeakList)*/
+  int pstate_ = 0;                       /*< Current pstate (index in the speed_per_pstate_)*/
   std::vector<double> speed_per_pstate_; /*< List of supported CPU capacities (pstate related) */
 
 public:
   /** @brief Setup the trace file with states events (ON or OFF).
    * Trace must contain boolean values (0 or 1).
    */
-  virtual void setStateTrace(tmgr_trace_t trace);
+  virtual void set_state_trace(tmgr_trace_t trace);
   /*< @brief Setup the trace file with availability events (peak speed changes due to external load).
    * Trace must contain relative values (ratio between 0 and 1)
    */
index d903ac8..519bf98 100644 (file)
@@ -494,10 +494,10 @@ bool CpuTi::is_used()
   return not action_set_.empty();
 }
 
-double CpuTi::get_available_speed()
+double CpuTi::get_speed_ratio()
 {
   speed_.scale = speed_integrated_trace_->get_power_scale(surf_get_clock());
-  return Cpu::get_available_speed();
+  return Cpu::get_speed_ratio();
 }
 
 /** @brief Update the remaining amount of actions */
index c371e8e..5e961db 100644 (file)
@@ -119,7 +119,7 @@ public:
     return nullptr;
   }
   CpuAction *sleep(double duration) override;
-  double get_available_speed() override;
+  double get_speed_ratio() override;
 
   void set_modified(bool modified);
 
index 8e3fa2d..4f4ecc9 100644 (file)
@@ -171,7 +171,7 @@ void HostEnergy::update()
 
     XBT_DEBUG("[update_energy of %s] period=[%.2f-%.2f]; current power peak=%.0E flop/s; consumption change: %.2f J -> "
               "%.2f J",
-              host->get_cname(), start_time, finish_time, host->pimpl_cpu->getSpeed(1.0), previous_energy,
+              host->get_cname(), start_time, finish_time, host->pimpl_cpu->get_speed(1.0), previous_energy,
               energy_this_step);
   }
 
index 84e6aa6..22b73e9 100644 (file)
@@ -286,7 +286,8 @@ bool CpuL07::is_used()
 }
 
 /** @brief take into account changes of speed (either load or max) */
-void CpuL07::onSpeedChange() {
+void CpuL07::on_speed_change()
+{
   kernel::lmm::Variable* var = nullptr;
   const kernel::lmm::Element* elem = nullptr;
 
@@ -297,7 +298,7 @@ void CpuL07::onSpeedChange() {
     get_model()->get_maxmin_system()->update_variable_bound(action->get_variable(), speed_.scale * speed_.peak);
   }
 
-  Cpu::onSpeedChange();
+  Cpu::on_speed_change();
 }
 
 bool LinkL07::is_used()
@@ -310,7 +311,7 @@ void CpuL07::apply_event(tmgr_trace_event_t triggered, double value)
   XBT_DEBUG("Updating cpu %s (%p) with value %g", get_cname(), this, value);
   if (triggered == speed_.event) {
     speed_.scale = value;
-    onSpeedChange();
+    on_speed_change();
     tmgr_trace_event_unref(&speed_.event);
 
   } else if (triggered == state_event_) {
index 9cd6442..01f1c80 100644 (file)
@@ -84,7 +84,7 @@ public:
   kernel::resource::Action* sleep(double duration) override;
 
 protected:
-  void onSpeedChange() override;
+  void on_speed_change() override;
 };
 
 class LinkL07 : public kernel::resource::LinkImpl {
index 4ecc5c4..3b0eed0 100644 (file)
@@ -80,7 +80,7 @@ void sg_platf_new_host(simgrid::kernel::routing::HostCreationArgs* args)
 
   /* Change from the defaults */
   if (args->state_trace)
-    host->pimpl_cpu->setStateTrace(args->state_trace);
+    host->pimpl_cpu->set_state_trace(args->state_trace);
   if (args->speed_trace)
     host->pimpl_cpu->set_speed_trace(args->speed_trace);
   if (args->pstate != 0)
@@ -487,7 +487,7 @@ void sg_platf_new_peer(simgrid::kernel::routing::PeerCreationArgs* peer)
 
   /* Change from the defaults */
   if (peer->state_trace)
-    host->pimpl_cpu->setStateTrace(peer->state_trace);
+    host->pimpl_cpu->set_state_trace(peer->state_trace);
   if (peer->speed_trace)
     host->pimpl_cpu->set_speed_trace(peer->speed_trace);
 }
index 460bba8..e3cb42b 100644 (file)
@@ -109,7 +109,7 @@ void parse_platform_file(const char *file)
     xbt_assert(host, "Host %s undefined", elm.second.c_str());
     simgrid::surf::Cpu* cpu = host->pimpl_cpu;
 
-    cpu->setStateTrace(trace);
+    cpu->set_state_trace(trace);
   }
 
   for (auto const& elm : trace_connect_list_host_speed) {