From: SUTER Frederic Date: Sun, 9 May 2021 14:41:39 +0000 (+0200) Subject: Rename kernel::resource:Cpu to CpuImpl X-Git-Tag: v3.28~304 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a8ef16dfe15a51e315150b693b11f80f23b1d5af Rename kernel::resource:Cpu to CpuImpl --- diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index 8806405e5d..18368a6da9 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -156,7 +156,7 @@ class System; } namespace resource { class Action; -class Cpu; +class CpuImpl; class Model; class Resource; class CpuModel; diff --git a/include/simgrid/s4u/Host.hpp b/include/simgrid/s4u/Host.hpp index c5023e8bf0..c6f580cd6d 100644 --- a/include/simgrid/s4u/Host.hpp +++ b/include/simgrid/s4u/Host.hpp @@ -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 diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index c49bb9cbad..908d7b8627 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -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(resource); + const kernel::resource::CpuImpl* cpu = dynamic_cast(resource); if (cpu != nullptr) resource_set_utilization("HOST", "speed_used", cpu->get_cname(), action.get_category(), value, diff --git a/src/plugins/host_energy.cpp b/src/plugins/host_energy.cpp index 906718ef52..6ace54bac6 100644 --- a/src/plugins/host_energy.cpp +++ b/src/plugins/host_energy.cpp @@ -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 diff --git a/src/plugins/vm/VirtualMachineImpl.cpp b/src/plugins/vm/VirtualMachineImpl.cpp index 19d184776f..08ea671b0e 100644 --- a/src/plugins/vm/VirtualMachineImpl.cpp +++ b/src/plugins/vm/VirtualMachineImpl.cpp @@ -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(); diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index ed072e071a..2223a80369 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -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& speed_per_pstate) +CpuImpl* CpuCas01Model::create_cpu(s4u::Host* host, const std::vector& 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) diff --git a/src/surf/cpu_cas01.hpp b/src/surf/cpu_cas01.hpp index 3855bf4e2f..967b186f8e 100644 --- a/src/surf/cpu_cas01.hpp +++ b/src/surf/cpu_cas01.hpp @@ -31,16 +31,16 @@ public: CpuCas01Model(const CpuCas01Model&) = delete; CpuCas01Model& operator=(const CpuCas01Model&) = delete; - Cpu* create_cpu(s4u::Host* host, const std::vector& speed_per_pstate) override; + CpuImpl* create_cpu(s4u::Host* host, const std::vector& 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; diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index dd0d66d7e7..bfa0af4c5c 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -49,7 +49,7 @@ void CpuModel::update_actions_state_full(double /*now*/, double delta) /************ * Resource * ************/ -Cpu::Cpu(s4u::Host* host, const std::vector& speed_per_pstate) +CpuImpl::CpuImpl(s4u::Host* host, const std::vector& 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& 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(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& speed_per_state) +CpuImpl* CpuImpl::set_pstate_speed(const std::vector& 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& 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(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 CpuAction::cpus() const +std::list CpuAction::cpus() const { - std::list retlist; + std::list 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(resource); + auto* cpu = dynamic_cast(resource); if (cpu != nullptr) retlist.push_back(cpu); } diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 03dffc6711..cb672bef21 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -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& speed_per_pstate) = 0; + virtual CpuImpl* create_cpu(s4u::Host* host, const std::vector& 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 { +class XBT_PUBLIC CpuImpl : public Resource_T { 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& speed_per_pstate); + CpuImpl(s4u::Host* host, const std::vector& 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& speed_per_state); + CpuImpl* set_pstate_speed(const std::vector& 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 cpus() const; + std::list cpus() const; void suspend() override; void resume() override; diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 0f98f52396..285a6deabf 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -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& speed_per_pstate) +CpuImpl* CpuTiModel::create_cpu(s4u::Host* host, const std::vector& 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& speed_per_pstate) : Cpu(host, speed_per_pstate) +CpuTi::CpuTi(s4u::Host* host, const std::vector& 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 */ diff --git a/src/surf/cpu_ti.hpp b/src/surf/cpu_ti.hpp index 25644f9065..5fdb31403d 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -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 #include @@ -97,14 +96,14 @@ using ActionTiList = boost::intrusive::list; /************ * Resource * ************/ -class CpuTi : public Cpu { +class CpuTi : public CpuImpl { public: CpuTi(s4u::Host* host, const std::vector& 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& speed_per_pstate) override; + CpuImpl* create_cpu(s4u::Host* host, const std::vector& speed_per_pstate) override; double next_occurring_event(double now) override; void update_actions_state(double now, double delta) override; diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 58184ed1c7..e6e51fcdbb 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -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& speed_per_pstate) +kernel::resource::CpuImpl* CpuL07Model::create_cpu(s4u::Host* host, const std::vector& 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) diff --git a/src/surf/ptask_L07.hpp b/src/surf/ptask_L07.hpp index 4e6bf2b392..f153895210 100644 --- a/src/surf/ptask_L07.hpp +++ b/src/surf/ptask_L07.hpp @@ -57,7 +57,7 @@ public: * method in surf_presolve */ }; - kernel::resource::Cpu* create_cpu(s4u::Host* host, const std::vector& speed_per_pstate) override; + kernel::resource::CpuImpl* create_cpu(s4u::Host* host, const std::vector& 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;