X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/eadbe829389f23151f79257824f3164d7801bbc7..98d5c6b1131ff3bf60e100e8cfcce9fc79bd77eb:/src/surf/cpu_interface.cpp diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index db1bd195e6..8325194bbe 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -10,11 +10,12 @@ XBT_LOG_EXTERNAL_CATEGORY(surf_kernel); XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu, surf, "Logging specific to the SURF cpu module"); -simgrid::surf::CpuModel *surf_cpu_model_pm; -simgrid::surf::CpuModel *surf_cpu_model_vm; +simgrid::kernel::resource::CpuModel* surf_cpu_model_pm; +simgrid::kernel::resource::CpuModel* surf_cpu_model_vm; namespace simgrid { -namespace surf { +namespace kernel { +namespace resource { /********* * Model * @@ -43,7 +44,7 @@ void CpuModel::update_actions_state_full(double /*now*/, double delta) if (((action.get_remains_no_update() <= 0) && (action.get_variable()->get_weight() > 0)) || ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) { - action.finish(kernel::resource::Action::State::FINISHED); + action.finish(Action::State::FINISHED); } } } @@ -51,35 +52,27 @@ void CpuModel::update_actions_state_full(double /*now*/, double delta) /************ * Resource * ************/ -Cpu::Cpu(kernel::resource::Model* model, simgrid::s4u::Host* host, std::vector* speedPerPstate, int core) - : Cpu(model, host, nullptr /*constraint*/, speedPerPstate, core) +Cpu::Cpu(Model* model, s4u::Host* host, const std::vector& speed_per_pstate, int core) + : Cpu(model, host, nullptr /*constraint*/, speed_per_pstate, core) { } -Cpu::Cpu(kernel::resource::Model* model, simgrid::s4u::Host* host, kernel::lmm::Constraint* constraint, - std::vector* speedPerPstate, int core) - : Resource(model, host->get_cname(), constraint), core_count_(core), host_(host) +Cpu::Cpu(Model* model, s4u::Host* host, lmm::Constraint* constraint, const std::vector& speed_per_pstate, + int core) + : Resource(model, host->get_cname(), constraint) + , core_count_(core) + , host_(host) + , speed_per_pstate_(speed_per_pstate) { xbt_assert(core > 0, "Host %s must have at least one core, not 0.", host->get_cname()); - speed_.peak = speedPerPstate->front(); + speed_.peak = speed_per_pstate_.front(); speed_.scale = 1; host->pimpl_cpu = this; xbt_assert(speed_.scale > 0, "Speed of host %s must be >0", host->get_cname()); - - // Copy the power peak array: - for (double const& value : *speedPerPstate) { - speed_per_pstate_.push_back(value); - } -} - -Cpu::~Cpu() -{ - if (get_model() == surf_cpu_model_pm) - speed_per_pstate_.clear(); } -int Cpu::get_pstate_count() +int Cpu::get_pstate_count() const { return speed_per_pstate_.size(); } @@ -98,12 +91,12 @@ void Cpu::set_pstate(int pstate_index) on_speed_change(); } -int Cpu::get_pstate() +int Cpu::get_pstate() const { return pstate_; } -double Cpu::get_pstate_peak_speed(int pstate_index) +double Cpu::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)"); @@ -111,7 +104,7 @@ double Cpu::get_pstate_peak_speed(int pstate_index) return speed_per_pstate_[pstate_index]; } -double Cpu::get_speed(double load) +double Cpu::get_speed(double load) const { return load * speed_.peak; } @@ -164,7 +157,7 @@ void CpuAction::update_remains_lazy(double now) set_last_value(get_variable()->get_value()); } -simgrid::xbt::signal CpuAction::on_state_change; +xbt::signal CpuAction::on_state_change; void CpuAction::suspend(){ Action::State previous = get_state(); @@ -194,8 +187,7 @@ std::list CpuAction::cpus() const 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*... - kernel::resource::Resource* resource = - static_cast(get_variable()->get_constraint(i)->get_id()); + Resource* resource = static_cast(get_variable()->get_constraint(i)->get_id()); Cpu* cpu = dynamic_cast(resource); if (cpu != nullptr) retlist.push_back(cpu); @@ -203,6 +195,6 @@ std::list CpuAction::cpus() const return retlist; } - -} -} +} // namespace resource +} // namespace kernel +} // namespace simgrid