/** @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. */
}
/** @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;
action->requested_core() * speed_.scale * speed_.peak);
}
- Cpu::onSpeedChange();
+ Cpu::on_speed_change();
}
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_) {
bool is_used() override;
protected:
- void onSpeedChange() override;
+ void on_speed_change() override;
};
/**********
pstate_ = pstate_index;
speed_.peak = new_peak_speed;
- onSpeedChange();
+ on_speed_change();
}
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<int>(speed_per_pstate_.size())),
"Invalid parameters (pstate index out of bounds)");
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_);
}
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());
/** @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);
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<double> 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)
*/
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 */
return nullptr;
}
CpuAction *sleep(double duration) override;
- double get_available_speed() override;
+ double get_speed_ratio() override;
void set_modified(bool modified);
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);
}
}
/** @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;
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()
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_) {
kernel::resource::Action* sleep(double duration) override;
protected:
- void onSpeedChange() override;
+ void on_speed_change() override;
};
class LinkL07 : public kernel::resource::LinkImpl {
/* 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)
/* 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);
}
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) {