if (isOff()) {
simgrid::simix::kernelImmediate([&]{
this->extension<simgrid::simix::Host>()->turnOn();
- this->pimpl_->turnOn();
+ this->pimpl_cpu->turnOn();
});
}
}
xbt_assert((host != nullptr), "Invalid parameters");
if (h->isOn()) {
- h->pimpl_->turnOff();
+ h->pimpl_cpu->turnOff();
/* Clean Simulator data */
if (xbt_swag_size(host->process_list) != 0) {
/* iterate for all virtual machines */
for (VirtualMachine *ws_vm : VirtualMachine::allVms_) {
- Cpu *cpu = ws_vm->cpu_;
+ Cpu* cpu = ws_vm->piface_->pimpl_cpu;
int is_active = lmm_constraint_used(cpu->getModel()->getMaxminSystem(), cpu->getConstraint());
/************
* Resource *
************/
-HostImpl::HostImpl(simgrid::surf::HostModel *model, const char *name, xbt_dynar_t storage, Cpu *cpu)
- : Resource(model, name)
- , PropertyHolder(nullptr)
- , storage_(storage), cpu_(cpu)
+HostImpl::HostImpl(simgrid::surf::HostModel* model, const char* name, xbt_dynar_t storage)
+ : Resource(model, name), PropertyHolder(nullptr), storage_(storage)
{
params_.ramsize = 0;
}
-HostImpl::HostImpl(simgrid::surf::HostModel *model, const char *name, lmm_constraint_t constraint,
- xbt_dynar_t storage, Cpu *cpu)
- : Resource(model, name, constraint)
- , PropertyHolder(nullptr)
- , storage_(storage), cpu_(cpu)
+HostImpl::HostImpl(simgrid::surf::HostModel* model, const char* name, lmm_constraint_t constraint, xbt_dynar_t storage)
+ : Resource(model, name, constraint), PropertyHolder(nullptr), storage_(storage)
{
params_.ramsize = 0;
}
piface_ = host;
}
-bool HostImpl::isOn() const {
- return cpu_->isOn();
-}
-bool HostImpl::isOff() const {
- return cpu_->isOff();
-}
-void HostImpl::turnOn(){
- if (isOff()) {
- cpu_->turnOn();
- simgrid::s4u::Host::onStateChange(*this->piface_);
- }
-}
-void HostImpl::turnOff(){
- if (isOn()) {
- cpu_->turnOff();
- simgrid::s4u::Host::onStateChange(*this->piface_);
- }
-}
-
simgrid::surf::Storage *HostImpl::findStorageOnMountList(const char* mount)
{
simgrid::surf::Storage *st = nullptr;
* @param model HostModel associated to this Host
* @param name The name of the Host
* @param storage The Storage associated to this Host
- * @param cpu The Cpu associated to this Host
*/
- HostImpl(HostModel *model, const char *name, xbt_dynar_t storage, Cpu *cpu);
+ HostImpl(HostModel* model, const char* name, xbt_dynar_t storage);
/**
* @brief Host constructor
* @param name The name of the Host
* @param constraint The lmm constraint associated to this Host if it is part of a LMM component
* @param storage The Storage associated to this Host
- * @param cpu The Cpu associated to this Host
*/
- HostImpl(HostModel *model, const char *name,
- lmm_constraint_t constraint, xbt_dynar_t storage, Cpu *cpu);
+ HostImpl(HostModel* model, const char* name, lmm_constraint_t constraint, xbt_dynar_t storage);
/* Host destruction logic */
/**************************/
}
void attach(simgrid::s4u::Host* host);
- bool isOn() const override;
- bool isOff() const override;
- void turnOn() override;
- void turnOff() override;
-
/** @brief Return the storage of corresponding mount point */
virtual simgrid::surf::Storage *findStorageOnMountList(const char* storage);
public:
xbt_dynar_t storage_ = nullptr;
- Cpu* cpu_ = nullptr;
simgrid::s4u::Host* piface_ = nullptr;
/** @brief Get the list of virtual machines on the current Host */
/* Computes the consumption so far. Called lazily on need. */
void HostEnergy::update()
{
- simgrid::surf::HostImpl* surf_host = host->pimpl_;
double start_time = this->last_updated;
double finish_time = surf_get_clock();
double cpu_load;
- if (surf_host->cpu_->getPstateSpeedCurrent() <= 0)
+ if (host->pimpl_cpu->getPstateSpeedCurrent() <= 0)
// Some users declare a pstate of speed 0 flops (e.g., to model boot time).
// We consider that the machine is then fully loaded. That's arbitrary but it avoids a NaN
cpu_load = 1;
else
- cpu_load = lmm_constraint_get_usage(surf_host->cpu_->getConstraint()) / surf_host->cpu_->getPstateSpeedCurrent();
+ cpu_load = lmm_constraint_get_usage(host->pimpl_cpu->getConstraint()) / host->pimpl_cpu->getPstateSpeedCurrent();
/** Divide by the number of cores here **/
- cpu_load /= surf_host->cpu_->coreCount();
+ cpu_load /= host->pimpl_cpu->coreCount();
if (cpu_load > 1) // A machine with a load > 1 consumes as much as a fully loaded machine, not more
cpu_load = 1;
this->total_energy = previous_energy + energy_this_step;
this->last_updated = finish_time;
- XBT_DEBUG("[update_energy of %s] period=[%.2f-%.2f]; current power peak=%.0E flop/s; consumption change: %.2f J -> %.2f J",
- surf_host->getName(), start_time, finish_time, surf_host->cpu_->speed_.peak, previous_energy, energy_this_step);
+ XBT_DEBUG(
+ "[update_energy of %s] period=[%.2f-%.2f]; current power peak=%.0E flop/s; consumption change: %.2f J -> %.2f J",
+ host->name().c_str(), start_time, finish_time, host->pimpl_cpu->speed_.peak, previous_energy, energy_this_step);
}
HostEnergy::HostEnergy(simgrid::s4u::Host *ptr) : host(ptr), last_updated(surf_get_clock())
if (host->speed_trace)
cpu->setSpeedTrace(host->speed_trace);
- simgrid::surf::HostImpl* hi = new simgrid::surf::HostImpl(surf_host_model, host->id, mount_list, cpu);
+ simgrid::surf::HostImpl* hi = new simgrid::surf::HostImpl(surf_host_model, host->id, mount_list);
hi->attach(h);
xbt_lib_set(storage_lib, host->id, ROUTING_STORAGE_HOST_LEVEL, (void*)mount_list);
/* iterate for all virtual machines */
for (VirtualMachine *ws_vm : VirtualMachine::allVms_) {
- Cpu *cpu = ws_vm->cpu_;
+ Cpu* cpu = ws_vm->piface_->pimpl_cpu;
xbt_assert(cpu, "cpu-less host");
double solved_value = ws_vm->action_->getVariable()->value;
************/
VirtualMachine::VirtualMachine(HostModel* model, const char* name, simgrid::s4u::Host* host_PM)
- : HostImpl(model, name, nullptr /*constraint*/, nullptr /*storage*/, nullptr /*cpu*/), hostPM_(host_PM)
+ : HostImpl(model, name, nullptr /*constraint*/, nullptr /*storage*/), hostPM_(host_PM)
{
/* Register this VM to the list of all VMs */
allVms_.push_back(this);
// Roughly, create a vcpu resource by using the values of the sub_cpu one.
CpuCas01 *sub_cpu = dynamic_cast<CpuCas01*>(host_PM->pimpl_cpu);
- cpu_ = surf_cpu_model_vm->createCpu(piface_, sub_cpu->getSpeedPeakList(), 1 /*cores*/);
+ piface_->pimpl_cpu = surf_cpu_model_vm->createCpu(piface_, sub_cpu->getSpeedPeakList(), 1 /*cores*/);
if (sub_cpu->getPState() != 0)
- cpu_->setPState(sub_cpu->getPState());
+ piface_->pimpl_cpu->setPState(sub_cpu->getPState());
/* We create cpu_action corresponding to a VM process on the host operating system. */
/* FIXME: TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */
/* Free the cpu_action of the VM. */
XBT_ATTRIB_UNUSED int ret = action_->unref();
xbt_assert(ret == 1, "Bug: some resource still remains");
-
- delete cpu_;
}
e_surf_vm_state_t VirtualMachine::getState() {
vmState_ = state;
}
void VirtualMachine::turnOn() {
+ THROW_DEADCODE;
if (isOff()) {
Resource::turnOn();
onVmStateChange(this);
}
}
void VirtualMachine::turnOff() {
+ THROW_DEADCODE;
if (isOn()) {
Resource::turnOff();
onVmStateChange(this);