Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rename kernel::resource:Cpu to CpuImpl
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Sun, 9 May 2021 14:41:39 +0000 (16:41 +0200)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Sun, 9 May 2021 14:41:45 +0000 (16:41 +0200)
13 files changed:
include/simgrid/forward.h
include/simgrid/s4u/Host.hpp
src/instr/instr_platform.cpp
src/plugins/host_energy.cpp
src/plugins/vm/VirtualMachineImpl.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/ptask_L07.cpp
src/surf/ptask_L07.hpp

index 8806405..18368a6 100644 (file)
@@ -156,7 +156,7 @@ class System;
 }
 namespace resource {
 class Action;
-class Cpu;
+class CpuImpl;
 class Model;
 class Resource;
 class CpuModel;
index c5023e8..c6f580c 100644 (file)
@@ -221,7 +221,7 @@ private:
 public:
 #ifndef DOXYGEN
   /** DO NOT USE DIRECTLY (@todo: these should be protected, once our code is clean) */
-  kernel::resource::Cpu* pimpl_cpu = nullptr;
+  kernel::resource::CpuImpl* pimpl_cpu = nullptr;
 #endif
 };
 } // namespace s4u
index c49bb9c..908d7b8 100644 (file)
@@ -340,7 +340,7 @@ static void on_action_state_change(kernel::resource::Action const& action,
     double value = action.get_variable()->get_value() * action.get_variable()->get_constraint_weight(i);
     /* Beware of composite actions: ptasks put links and cpus together. Extra pb: we cannot dynamic_cast from void* */
     kernel::resource::Resource* resource = action.get_variable()->get_constraint(i)->get_id();
-    const kernel::resource::Cpu* cpu     = dynamic_cast<kernel::resource::Cpu*>(resource);
+    const kernel::resource::CpuImpl* cpu = dynamic_cast<kernel::resource::CpuImpl*>(resource);
 
     if (cpu != nullptr)
       resource_set_utilization("HOST", "speed_used", cpu->get_cname(), action.get_category(), value,
index 906718e..6ace54b 100644 (file)
@@ -407,7 +407,7 @@ static void on_creation(simgrid::s4u::Host& host)
 static void on_action_state_change(simgrid::kernel::resource::CpuAction const& action,
                                    simgrid::kernel::resource::Action::State /*previous*/)
 {
-  for (simgrid::kernel::resource::Cpu* const& cpu : action.cpus()) {
+  for (simgrid::kernel::resource::CpuImpl* const& cpu : action.cpus()) {
     simgrid::s4u::Host* host = cpu->get_iface();
     if (host != nullptr) {
       // If it's a VM, take the corresponding PM
index 19d1847..08ea671 100644 (file)
@@ -156,7 +156,7 @@ double VMModel::next_occurring_event(double now)
     if (ws_vm->get_state() == s4u::VirtualMachine::State::SUSPENDED) // Ignore suspended VMs
       continue;
 
-    const kernel::resource::Cpu* cpu = ws_vm->pimpl_cpu;
+    const kernel::resource::CpuImpl* cpu = ws_vm->pimpl_cpu;
 
     // solved_value below is X1 in comment above: what this VM got in the sharing on the PM
     double solved_value = ws_vm->get_vm_impl()->get_action()->get_variable()->get_value();
index ed072e0..2223a80 100644 (file)
@@ -3,12 +3,13 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "cpu_cas01.hpp"
 #include "simgrid/kernel/routing/NetZoneImpl.hpp"
 #include "simgrid/s4u/Engine.hpp"
+
 #include "simgrid/sg_config.hpp"
 #include "src/kernel/EngineImpl.hpp"
 #include "src/kernel/resource/profile/Event.hpp"
+#include "src/surf/cpu_cas01.hpp"
 #include "src/surf/cpu_ti.hpp"
 #include "src/surf/surf_interface.hpp"
 #include "surf/surf.hpp"
@@ -69,7 +70,7 @@ CpuCas01Model::CpuCas01Model(const std::string& name) : CpuModel(name)
   set_maxmin_system(new lmm::System(select));
 }
 
-Cpu* CpuCas01Model::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate)
+CpuImpl* CpuCas01Model::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate)
 {
   return (new CpuCas01(host, speed_per_pstate))->set_model(this);
 }
@@ -96,7 +97,7 @@ void CpuCas01::on_speed_change()
                                                             action->requested_core() * speed_.scale * speed_.peak);
   }
 
-  Cpu::on_speed_change();
+  CpuImpl::on_speed_change();
 }
 
 void CpuCas01::apply_event(profile::Event* event, double value)
index 3855bf4..967b186 100644 (file)
@@ -31,16 +31,16 @@ public:
   CpuCas01Model(const CpuCas01Model&) = delete;
   CpuCas01Model& operator=(const CpuCas01Model&) = delete;
 
-  Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
+  CpuImpl* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
 };
 
 /************
  * Resource *
  ************/
 
-class CpuCas01 : public Cpu {
+class CpuCas01 : public CpuImpl {
 public:
-  using Cpu::Cpu;
+  using CpuImpl::CpuImpl;
   CpuCas01(const CpuCas01&) = delete;
   CpuCas01& operator=(const CpuCas01&) = delete;
   void apply_event(profile::Event* event, double value) override;
index dd0d66d..bfa0af4 100644 (file)
@@ -49,7 +49,7 @@ void CpuModel::update_actions_state_full(double /*now*/, double delta)
 /************
  * Resource *
  ************/
-Cpu::Cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate)
+CpuImpl::CpuImpl(s4u::Host* host, const std::vector<double>& speed_per_pstate)
     : Resource_T(host->get_cname()), piface_(host), speed_per_pstate_(speed_per_pstate)
 {
   speed_.scale    = 1;
@@ -57,7 +57,7 @@ Cpu::Cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate)
   host->pimpl_cpu = this;
 }
 
-void Cpu::reset_vcpu(Cpu* that)
+void CpuImpl::reset_vcpu(CpuImpl* that)
 {
   this->pstate_ = that->pstate_;
   this->speed_  = that->speed_;
@@ -65,7 +65,7 @@ void Cpu::reset_vcpu(Cpu* that)
   this->speed_per_pstate_.assign(that->speed_per_pstate_.begin(), that->speed_per_pstate_.end());
 }
 
-Cpu* Cpu::set_pstate(int pstate_index)
+CpuImpl* CpuImpl::set_pstate(int pstate_index)
 {
   xbt_assert(pstate_index <= static_cast<int>(speed_per_pstate_.size()),
              "Invalid parameters for CPU %s (pstate %d > length of pstates %d). Please fix your platform file, or your "
@@ -80,7 +80,7 @@ Cpu* Cpu::set_pstate(int pstate_index)
   return this;
 }
 
-Cpu* Cpu::set_pstate_speed(const std::vector<double>& speed_per_state)
+CpuImpl* CpuImpl::set_pstate_speed(const std::vector<double>& speed_per_state)
 {
   xbt_assert(speed_per_state.size() > 0, "CPU %s: processor speed vector cannot be empty", get_cname());
   xbt_assert(not is_sealed(), "CPU %s: processor speed cannot be changed once CPU has been sealed", get_cname());
@@ -89,7 +89,7 @@ Cpu* Cpu::set_pstate_speed(const std::vector<double>& speed_per_state)
   return this;
 }
 
-double Cpu::get_pstate_peak_speed(int pstate_index) const
+double CpuImpl::get_pstate_peak_speed(int pstate_index) const
 {
   xbt_assert((pstate_index <= static_cast<int>(speed_per_pstate_.size())),
              "Invalid parameters (pstate index out of bounds)");
@@ -97,12 +97,12 @@ double Cpu::get_pstate_peak_speed(int pstate_index) const
   return speed_per_pstate_[pstate_index];
 }
 
-void Cpu::on_speed_change()
+void CpuImpl::on_speed_change()
 {
   s4u::Host::on_speed_change(*piface_);
 }
 
-Cpu* Cpu::set_core_count(int core_count)
+CpuImpl* CpuImpl::set_core_count(int core_count)
 {
   xbt_assert(not is_sealed(), "Core count cannot be changed once CPU has been sealed");
   xbt_assert(core_count > 0, "Host %s must have at least one core, not 0.", piface_->get_cname());
@@ -113,12 +113,12 @@ Cpu* Cpu::set_core_count(int core_count)
   return this;
 }
 
-int Cpu::get_core_count()
+int CpuImpl::get_core_count()
 {
   return core_count_;
 }
 
-Cpu* Cpu::set_speed_profile(kernel::profile::Profile* profile)
+CpuImpl* CpuImpl::set_speed_profile(kernel::profile::Profile* profile)
 {
   if (profile) {
     xbt_assert(speed_.event == nullptr, "Cannot set a second speed trace to Host %s", piface_->get_cname());
@@ -127,7 +127,7 @@ Cpu* Cpu::set_speed_profile(kernel::profile::Profile* profile)
   return this;
 }
 
-void Cpu::seal()
+void CpuImpl::seal()
 {
   if (is_sealed()) {
     return;
@@ -186,16 +186,16 @@ void CpuAction::set_state(Action::State state)
 }
 
 /** @brief returns a list of all CPUs that this action is using */
-std::list<Cpu*> CpuAction::cpus() const
+std::list<CpuImpl*> CpuAction::cpus() const
 {
-  std::list<Cpu*> retlist;
+  std::list<CpuImpl*> retlist;
   int llen = get_variable()->get_number_of_constraint();
 
   for (int i = 0; i < llen; i++) {
     /* Beware of composite actions: ptasks put links and cpus together */
     // extra pb: we cannot dynamic_cast from void*...
     Resource* resource = get_variable()->get_constraint(i)->get_id();
-    auto* cpu          = dynamic_cast<Cpu*>(resource);
+    auto* cpu          = dynamic_cast<CpuImpl*>(resource);
     if (cpu != nullptr)
       retlist.push_back(cpu);
   }
index 03dffc6..cb672be 100644 (file)
@@ -38,7 +38,7 @@ public:
    *                         This ignores any potential external load coming from a trace.
    * @param core The number of core of this Cpu
    */
-  virtual Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) = 0;
+  virtual CpuImpl* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) = 0;
 
   void update_actions_state_lazy(double now, double delta) override;
   void update_actions_state_full(double now, double delta) override;
@@ -48,7 +48,7 @@ public:
  * Resource *
  ************/
 
-class XBT_PUBLIC Cpu : public Resource_T<Cpu> {
+class XBT_PUBLIC CpuImpl : public Resource_T<CpuImpl> {
   friend vm::VirtualMachineImpl; // Resets the VCPU
 
   s4u::Host* piface_;
@@ -64,15 +64,15 @@ public:
    * @param host The host in which this Cpu should be plugged
    * @param speed_per_pstate Processor speed (in flop per second) for each pstate
    */
-  Cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate);
+  CpuImpl(s4u::Host* host, const std::vector<double>& speed_per_pstate);
 
-  Cpu(const Cpu&) = delete;
-  Cpu& operator=(const Cpu&) = delete;
+  CpuImpl(const CpuImpl&) = delete;
+  CpuImpl& operator=(const CpuImpl&) = delete;
 
   /** @brief Public interface */
   s4u::Host* get_iface() { return piface_; }
 
-  Cpu* set_core_count(int core_count);
+  CpuImpl* set_core_count(int core_count);
   virtual int get_core_count();
 
   void seal() override;
@@ -98,19 +98,19 @@ public:
   virtual int get_pstate_count() const { return speed_per_pstate_.size(); }
 
   virtual int get_pstate() const { return pstate_; }
-  virtual Cpu* set_pstate(int pstate_index);
+  virtual CpuImpl* set_pstate(int pstate_index);
 
   /*< @brief Setup the profile file with availability events (peak speed changes due to external load).
    * Profile must contain relative values (ratio between 0 and 1)
    */
-  virtual Cpu* set_speed_profile(profile::Profile* profile);
+  virtual CpuImpl* set_speed_profile(profile::Profile* profile);
 
   /**
    * @brief Set the CPU's speed
    *
    * @param speed_per_state list of powers for this processor (default power is at index 0)
    */
-  Cpu* set_pstate_speed(const std::vector<double>& speed_per_state);
+  CpuImpl* set_pstate_speed(const std::vector<double>& speed_per_state);
 
   /**
    * @brief Execute some quantity of computation
@@ -146,7 +146,7 @@ protected:
    * Used to reset a VCPU when its VM migrates to another host, so it only resets the fields that should be in this
    *case.
    **/
-  virtual void reset_vcpu(Cpu* that);
+  virtual void reset_vcpu(CpuImpl* that);
 
   Metric speed_                  = {1.0, 0, nullptr};
 };
@@ -170,7 +170,7 @@ public:
   void set_state(Action::State state) override;
 
   void update_remains_lazy(double now) override;
-  std::list<Cpu*> cpus() const;
+  std::list<CpuImpl*> cpus() const;
 
   void suspend() override;
   void resume() override;
index 0f98f52..285a6de 100644 (file)
@@ -274,7 +274,7 @@ void CpuTiModel::create_pm_models()
   simgrid::s4u::Engine::get_instance()->get_netzone_root()->get_impl()->set_cpu_pm_model(cpu_model_pm);
 }
 
-Cpu* CpuTiModel::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate)
+CpuImpl* CpuTiModel::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate)
 {
   return (new CpuTi(host, speed_per_pstate))->set_model(this);
 }
@@ -313,7 +313,7 @@ void CpuTiModel::update_actions_state(double now, double /*delta*/)
 /************
  * Resource *
  ************/
-CpuTi::CpuTi(s4u::Host* host, const std::vector<double>& speed_per_pstate) : Cpu(host, speed_per_pstate)
+CpuTi::CpuTi(s4u::Host* host, const std::vector<double>& speed_per_pstate) : CpuImpl(host, speed_per_pstate)
 {
   speed_.peak = speed_per_pstate.front();
   XBT_DEBUG("CPU create: peak=%f", speed_.peak);
@@ -327,7 +327,7 @@ CpuTi::~CpuTi()
   delete speed_integrated_trace_;
 }
 
-Cpu* CpuTi::set_speed_profile(kernel::profile::Profile* profile)
+CpuImpl* CpuTi::set_speed_profile(kernel::profile::Profile* profile)
 {
   delete speed_integrated_trace_;
   speed_integrated_trace_ = new CpuTiTmgr(profile, speed_.scale);
@@ -454,7 +454,7 @@ bool CpuTi::is_used() const
 double CpuTi::get_speed_ratio()
 {
   speed_.scale = speed_integrated_trace_->get_power_scale(surf_get_clock());
-  return Cpu::get_speed_ratio();
+  return CpuImpl::get_speed_ratio();
 }
 
 /** @brief Update the remaining amount of actions */
index 25644f9..5fdb314 100644 (file)
@@ -6,9 +6,8 @@
 #ifndef SURF_MODEL_CPUTI_H_
 #define SURF_MODEL_CPUTI_H_
 
+#include "cpu_interface.hpp"
 #include "src/kernel/resource/profile/Profile.hpp"
-#include "src/surf/cpu_interface.hpp"
-
 #include <boost/intrusive/list.hpp>
 #include <memory>
 
@@ -97,14 +96,14 @@ using ActionTiList = boost::intrusive::list<CpuTiAction, ActionTiListOptions>;
 /************
  * Resource *
  ************/
-class CpuTi : public Cpu {
+class CpuTi : public CpuImpl {
 public:
   CpuTi(s4u::Host* host, const std::vector<double>& speed_per_pstate);
   CpuTi(const CpuTi&)            = delete;
   CpuTi& operator&(const CpuTi&) = delete;
   ~CpuTi() override;
 
-  Cpu* set_speed_profile(profile::Profile* profile) override;
+  CpuImpl* set_speed_profile(profile::Profile* profile) override;
 
   void apply_event(profile::Event* event, double value) override;
   void update_actions_finish_time(double now);
@@ -144,7 +143,7 @@ public:
   using CpuModel::CpuModel;
   CpuTiModel(const CpuTiModel&) = delete;
   CpuTiModel& operator=(const CpuTiModel&) = delete;
-  Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
+  CpuImpl* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
   double next_occurring_event(double now) override;
   void update_actions_state(double now, double delta) override;
 
index 58184ed..e6e51fc 100644 (file)
@@ -234,7 +234,7 @@ kernel::resource::Action* NetworkL07Model::communicate(s4u::Host* src, s4u::Host
   return res;
 }
 
-kernel::resource::Cpu* CpuL07Model::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate)
+kernel::resource::CpuImpl* CpuL07Model::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate)
 {
   return (new CpuL07(host, speed_per_pstate))->set_model(this);
 }
@@ -295,7 +295,7 @@ void CpuL07::on_speed_change()
     get_model()->get_maxmin_system()->update_variable_bound(action->get_variable(), speed_.scale * speed_.peak);
   }
 
-  Cpu::on_speed_change();
+  CpuImpl::on_speed_change();
 }
 
 LinkL07::LinkL07(const std::string& name, double bandwidth, kernel::lmm::System* system) : LinkImpl(name)
index 4e6bf2b..f153895 100644 (file)
@@ -57,7 +57,7 @@ public:
        * method in surf_presolve */
   };
 
-  kernel::resource::Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
+  kernel::resource::CpuImpl* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
   HostL07Model* hostModel_;
 };
 
@@ -84,9 +84,9 @@ public:
  * Resource *
  ************/
 
-class CpuL07 : public kernel::resource::Cpu {
+class CpuL07 : public kernel::resource::CpuImpl {
 public:
-  using kernel::resource::Cpu::Cpu;
+  using kernel::resource::CpuImpl::CpuImpl;
   CpuL07(const CpuL07&) = delete;
   CpuL07& operator=(const CpuL07&) = delete;