xbt_assert(speed_.scale > 0, "Speed of host %s must be >0", host->name().c_str());
// Copy the power peak array:
- speedPerPstate_ = new std::vector<double>();
unsigned long n = speedPerPstate->size();
for (unsigned long i = 0; i != n; ++i) {
double value = speedPerPstate->at(i);
- speedPerPstate_->push_back(value);
+ speedPerPstate_.push_back(value);
}
xbt_assert(model == surf_cpu_model_pm || core==1, "Currently, VM cannot be multicore");
}
-Cpu::~Cpu()
-{
- delete speedPerPstate_;
-}
+Cpu::~Cpu() = default;
double Cpu::getPstateSpeedCurrent()
{
int Cpu::getNbPStates()
{
- return speedPerPstate_->size();
+ return speedPerPstate_.size();
}
void Cpu::setPState(int pstate_index)
{
- std::vector<double> *plist = speedPerPstate_;
- xbt_assert(pstate_index <= static_cast<int>(plist->size()),
+ xbt_assert(pstate_index <= static_cast<int>(speedPerPstate_.size()),
"Invalid parameters for CPU %s (pstate %d > length of pstates %d)", getName(), pstate_index,
- static_cast<int>(plist->size()));
+ static_cast<int>(speedPerPstate_.size()));
- double new_peak_speed = plist->at(pstate_index);
+ double new_peak_speed = speedPerPstate_[pstate_index];
pstate_ = pstate_index;
speed_.peak = new_peak_speed;
double Cpu::getPstateSpeed(int pstate_index)
{
- std::vector<double> *plist = speedPerPstate_;
- xbt_assert((pstate_index <= static_cast<int>(plist->size())), "Invalid parameters (pstate index out of bounds)");
+ xbt_assert((pstate_index <= static_cast<int>(speedPerPstate_.size())), "Invalid parameters (pstate index out of bounds)");
- return plist->at(pstate_index);
+ return speedPerPstate_[pstate_index];
}
double Cpu::getSpeed(double load)
int coresAmount_ = 1;
simgrid::s4u::Host* host_;
- std::vector<double> *speedPerPstate_ = nullptr; /*< List of supported CPU capacities (pstate related) */
- int pstate_ = 0; /*< Current pstate (index in the speedPeakList)*/
+ std::vector<double> speedPerPstate_; /*< List of supported CPU capacities (pstate related) */
+ int pstate_ = 0; /*< Current pstate (index in the speedPeakList)*/
public:
virtual void setStateTrace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). Trace must contain boolean values (0 or 1). */