}
namespace resource {
class Action;
-class Cpu;
+class CpuImpl;
class Model;
class Resource;
class CpuModel;
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
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,
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
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();
/* 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"
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);
}
action->requested_core() * speed_.scale * speed_.peak);
}
- Cpu::on_speed_change();
+ CpuImpl::on_speed_change();
}
void CpuCas01::apply_event(profile::Event* event, double value)
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;
/************
* 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;
host->pimpl_cpu = this;
}
-void Cpu::reset_vcpu(Cpu* that)
+void CpuImpl::reset_vcpu(CpuImpl* that)
{
this->pstate_ = that->pstate_;
this->speed_ = that->speed_;
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 "
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());
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)");
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());
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());
return this;
}
-void Cpu::seal()
+void CpuImpl::seal()
{
if (is_sealed()) {
return;
}
/** @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);
}
* 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;
* 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_;
* @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;
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
* 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};
};
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;
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);
}
/************
* 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);
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);
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 */
#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>
/************
* 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);
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;
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);
}
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)
* 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_;
};
* 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;