int getPstatesCount() const;
void setPstate(int pstate_index);
int getPstate();
+
std::vector<const char*> get_attached_storages();
XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_attached_storages() instead.") void getAttachedStorages(
std::vector<const char*>* storages);
pimpl_netpoint = pm->pimpl_netpoint;
// Create a VCPU for this VM
- std::vector<double>* speeds = new std::vector<double>();
+ std::vector<double> speeds;
for (int i = 0; i < pm->getPstatesCount(); i++)
- speeds->push_back(pm->getPstateSpeed(i));
+ speeds.push_back(pm->getPstateSpeed(i));
- surf_cpu_model_vm->createCpu(this, speeds, pm->getCoreCount());
+ surf_cpu_model_vm->createCpu(this, &speeds, pm->getCoreCount());
if (pm->getPstate() != 0)
setPstate(pm->getPstate());
int Host::getPstatesCount() const
{
- return this->pimpl_cpu->getNbPStates();
+ return this->pimpl_cpu->get_pstates_count();
}
/**
return simgrid::simix::simcall([this, pstate_index] { return this->pimpl_cpu->getPstateSpeed(pstate_index); });
}
-/** @brief Get the peak processor speed (under full load (=1.0), in flops/s), at the current pstate */
+/** @brief Get the peak processor speed in flops/s, (under full load (=1.0), at the current pstate) */
double Host::getSpeed()
{
- return pimpl_cpu->getSpeed(1.0);
+ return this->pimpl_cpu->getSpeed(1.0);
}
double Host::get_available_speed()
{
- return pimpl_cpu->get_available_speed();
+ return this->pimpl_cpu->get_available_speed();
}
/** @brief Returns the number of core of the processor. */
int Host::getCoreCount()
{
- return pimpl_cpu->coreCount();
+ return this->pimpl_cpu->get_cores_count();
}
/** @brief Set the pstate at which the host should run */
void Host::setPstate(int pstate_index)
{
- simgrid::simix::simcall([this, pstate_index] { this->pimpl_cpu->setPState(pstate_index); });
+ simgrid::simix::simcall([this, pstate_index] { this->pimpl_cpu->set_pstate(pstate_index); });
}
/** @brief Retrieve the pstate at which the host is currently running */
int Host::getPstate()
{
- return this->pimpl_cpu->getPState();
+ return this->pimpl_cpu->get_pstate();
}
/**
CpuCas01::~CpuCas01()
{
if (get_model() == surf_cpu_model_pm)
- speedPerPstate_.clear();
+ speed_per_pstate_.clear();
}
std::vector<double> * CpuCas01::getSpeedPeakList(){
- return &speedPerPstate_;
+ return &speed_per_pstate_;
}
bool CpuCas01::is_used()
const kernel::lmm::Element* elem = nullptr;
get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(),
- coresAmount_ * speed_.scale * speed_.peak);
+ get_cores_count() * speed_.scale * speed_.peak);
while ((var = get_constraint()->get_variable(&elem))) {
CpuCas01Action* action = static_cast<CpuCas01Action*>(var->get_id());
{
if (event == speed_.event) {
/* TODO (Hypervisor): do the same thing for constraint_core[i] */
- xbt_assert(coresAmount_ == 1, "FIXME: add speed scaling code also for constraint_core[i]");
+ xbt_assert(get_cores_count() == 1, "FIXME: add speed scaling code also for constraint_core[i]");
speed_.scale = value;
onSpeedChange();
tmgr_trace_event_unref(&speed_.event);
- } else if (event == stateEvent_) {
+ } else if (event == state_event_) {
/* TODO (Hypervisor): do the same thing for constraint_core[i] */
- xbt_assert(coresAmount_ == 1, "FIXME: add state change code also for constraint_core[i]");
+ xbt_assert(get_cores_count() == 1, "FIXME: add state change code also for constraint_core[i]");
if (value > 0) {
if (is_off())
- host_that_restart.push_back(getHost());
+ host_that_restart.push_back(get_host());
turn_on();
} else {
kernel::lmm::Constraint* cnst = get_constraint();
}
}
}
- tmgr_trace_event_unref(&stateEvent_);
+ tmgr_trace_event_unref(&state_event_);
} else {
xbt_die("Unknown event!\n");
Cpu::Cpu(kernel::resource::Model* model, simgrid::s4u::Host* host, kernel::lmm::Constraint* constraint,
std::vector<double>* speedPerPstate, int core)
- : Resource(model, host->get_cname(), constraint), coresAmount_(core), host_(host)
+ : Resource(model, host->get_cname(), constraint), cores_count_(core), host_(host)
{
xbt_assert(core > 0, "Host %s must have at least one core, not 0.", host->get_cname());
// Copy the power peak array:
for (double const& value : *speedPerPstate) {
- speedPerPstate_.push_back(value);
+ speed_per_pstate_.push_back(value);
}
}
Cpu::~Cpu() = default;
-int Cpu::getNbPStates()
+int Cpu::get_pstates_count()
{
- return speedPerPstate_.size();
+ return speed_per_pstate_.size();
}
-void Cpu::setPState(int pstate_index)
+void Cpu::set_pstate(int pstate_index)
{
- xbt_assert(pstate_index <= static_cast<int>(speedPerPstate_.size()),
+ 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 "
"call to change the pstate.",
- get_cname(), pstate_index, static_cast<int>(speedPerPstate_.size()));
+ get_cname(), pstate_index, static_cast<int>(speed_per_pstate_.size()));
- double new_peak_speed = speedPerPstate_[pstate_index];
+ double new_peak_speed = speed_per_pstate_[pstate_index];
pstate_ = pstate_index;
speed_.peak = new_peak_speed;
onSpeedChange();
}
-int Cpu::getPState()
+int Cpu::get_pstate()
{
return pstate_;
}
double Cpu::getPstateSpeed(int pstate_index)
{
- xbt_assert((pstate_index <= static_cast<int>(speedPerPstate_.size())), "Invalid parameters (pstate index out of bounds)");
+ xbt_assert((pstate_index <= static_cast<int>(speed_per_pstate_.size())),
+ "Invalid parameters (pstate index out of bounds)");
- return speedPerPstate_[pstate_index];
+ return speed_per_pstate_[pstate_index];
}
double Cpu::getSpeed(double load)
s4u::Host::on_speed_change(*host_);
}
-int Cpu::coreCount()
+int Cpu::get_cores_count()
{
- return coresAmount_;
+ return cores_count_;
}
void Cpu::setStateTrace(tmgr_trace_t trace)
{
- xbt_assert(stateEvent_ == nullptr, "Cannot set a second state trace to Host %s", host_->get_cname());
+ xbt_assert(state_event_ == nullptr, "Cannot set a second state trace to Host %s", host_->get_cname());
- stateEvent_ = future_evt_set->add_trace(trace, this);
+ state_event_ = future_evt_set->add_trace(trace, this);
}
void Cpu::set_speed_trace(tmgr_trace_t trace)
{
virtual simgrid::kernel::resource::Action* sleep(double duration) = 0;
/** @brief Get the amount of cores */
- virtual int coreCount();
+ 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 the current Cpu computational speed */
virtual double getPstateSpeed(int pstate_index);
- virtual int getNbPStates();
- virtual void setPState(int pstate_index);
- virtual int getPState();
+ virtual int get_pstates_count();
+ virtual void set_pstate(int pstate_index);
+ virtual int get_pstate();
- simgrid::s4u::Host* getHost() { return host_; }
+ simgrid::s4u::Host* get_host() { return host_; }
- int coresAmount_ = 1;
+private:
+ int cores_count_ = 1;
simgrid::s4u::Host* host_;
- std::vector<double> speedPerPstate_; /*< List of supported CPU capacities (pstate related) */
int pstate_ = 0; /*< Current pstate (index in the speedPeakList)*/
+protected:
+ std::vector<double> speed_per_pstate_; /*< List of supported CPU capacities (pstate related) */
+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). */
virtual void
set_speed_trace(tmgr_trace_t trace); /*< setup the trace file with availability events (peak speed changes due to
external load). Trace must contain relative values (ratio between 0 and 1) */
- tmgr_trace_event_t stateEvent_ = nullptr;
+ tmgr_trace_event_t state_event_ = nullptr;
Metric speed_ = {1.0, 0, nullptr};
};
tmgr_trace_event_unref(&speed_.event);
- } else if (event == stateEvent_) {
+ } else if (event == state_event_) {
if (value > 0) {
if (is_off())
- host_that_restart.push_back(getHost());
+ host_that_restart.push_back(get_host());
turn_on();
} else {
turn_off();
}
}
}
- tmgr_trace_event_unref(&stateEvent_);
+ tmgr_trace_event_unref(&state_event_);
} else {
xbt_die("Unknown event!\n");
cpu_load = host->pimpl_cpu->get_constraint()->get_usage() / current_speed;
/** Divide by the number of cores here **/
- cpu_load /= host->pimpl_cpu->coreCount();
+ cpu_load /= host->pimpl_cpu->get_cores_count();
if (cpu_load > 1) // A machine with a load > 1 consumes as much as a fully loaded machine, not more
cpu_load = 1;
static void onActionStateChange(simgrid::surf::CpuAction* action, simgrid::kernel::resource::Action::State previous)
{
for (simgrid::surf::Cpu* const& cpu : action->cpus()) {
- simgrid::s4u::Host* host = cpu->getHost();
+ simgrid::s4u::Host* host = cpu->get_host();
if (host != nullptr) {
// If it's a VM, take the corresponding PM
static void onActionStateChange(simgrid::surf::CpuAction* action, simgrid::kernel::resource::Action::State /*previous*/)
{
for (simgrid::surf::Cpu* const& cpu : action->cpus()) {
- simgrid::s4u::Host* host = cpu->getHost();
+ simgrid::s4u::Host* host = cpu->get_host();
if (dynamic_cast<simgrid::s4u::VirtualMachine*>(host)) // Ignore virtual machines
return;
sg_host_t* host_list = new sg_host_t[1]();
double* flops_amount = new double[1]();
- host_list[0] = getHost();
+ host_list[0] = get_host();
flops_amount[0] = size;
return static_cast<CpuL07Model*>(get_model())->hostModel_->execute_parallel(1, host_list, flops_amount, nullptr, -1);
onSpeedChange();
tmgr_trace_event_unref(&speed_.event);
- } else if (triggered == stateEvent_) {
+ } else if (triggered == state_event_) {
if (value > 0)
turn_on();
else
turn_off();
- tmgr_trace_event_unref(&stateEvent_);
+ tmgr_trace_event_unref(&state_event_);
} else {
xbt_die("Unknown event!\n");
if (args->speed_trace)
host->pimpl_cpu->set_speed_trace(args->speed_trace);
if (args->pstate != 0)
- host->pimpl_cpu->setPState(args->pstate);
+ host->pimpl_cpu->set_pstate(args->pstate);
if (args->coord && strcmp(args->coord, ""))
new simgrid::kernel::routing::vivaldi::Coords(host->pimpl_netpoint, args->coord);
}