From: Martin Quinson Date: Tue, 22 May 2018 06:29:33 +0000 (+0200) Subject: cleanings in k:r:Cpu X-Git-Tag: v3.20~201 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/4576fd50919e2cffe68e4b86943709f42eaea60f cleanings in k:r:Cpu --- diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index cdbc5a9f9c..3ac5c472ff 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -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. */ diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index e06a155768..92d582d361 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -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_) { diff --git a/src/surf/cpu_cas01.hpp b/src/surf/cpu_cas01.hpp index 84f7fb9c1c..139c30310a 100644 --- a/src/surf/cpu_cas01.hpp +++ b/src/surf/cpu_cas01.hpp @@ -45,7 +45,7 @@ public: bool is_used() override; protected: - void onSpeedChange() override; + void on_speed_change() override; }; /********** diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 7fffcb5ab7..245c019b8f 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -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(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()); diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 73f12a1f2c..5cb44640c4 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -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 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) */ diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index d903ac8bc3..519bf989b2 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -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 */ diff --git a/src/surf/cpu_ti.hpp b/src/surf/cpu_ti.hpp index c371e8e439..5e961dba56 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -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); diff --git a/src/surf/plugins/host_energy.cpp b/src/surf/plugins/host_energy.cpp index 8e3fa2da23..4f4ecc9092 100644 --- a/src/surf/plugins/host_energy.cpp +++ b/src/surf/plugins/host_energy.cpp @@ -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); } diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 84e6aa6093..22b73e9c5b 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -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_) { diff --git a/src/surf/ptask_L07.hpp b/src/surf/ptask_L07.hpp index 9cd64429c7..01f1c809ec 100644 --- a/src/surf/ptask_L07.hpp +++ b/src/surf/ptask_L07.hpp @@ -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 { diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 4ecc5c44b8..3b0eed0673 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -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); } diff --git a/src/surf/xml/surfxml_parseplatf.cpp b/src/surf/xml/surfxml_parseplatf.cpp index 460bba8411..e3cb42bd64 100644 --- a/src/surf/xml/surfxml_parseplatf.cpp +++ b/src/surf/xml/surfxml_parseplatf.cpp @@ -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) {