double start_time = this->last_updated;
double finish_time = surf_get_clock();
double cpu_load;
- if (surf_host->p_cpu->p_speed.peak == 0)
+ if (surf_host->p_cpu->speed_.peak == 0)
// Some users declare a pstate of speed 0 flops (eg 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->p_cpu->getConstraint())
- / surf_host->p_cpu->p_speed.peak;
+ / surf_host->p_cpu->speed_.peak;
if (cpu_load > 1) // A machine with a load > 1 consumes as much as a fully loaded machine, not mores
cpu_load = 1;
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->p_cpu->p_speed.peak, previous_energy, energy_this_step);
+ surf_host->getName(), start_time, finish_time, surf_host->p_cpu->speed_.peak, previous_energy, energy_this_step);
}
HostEnergy::HostEnergy(simgrid::s4u::Host *ptr) :
}
static void onActionStateChange(simgrid::surf::CpuAction *action, e_surf_action_state_t previous) {
- const char *name = getActionCpu(action)->getName();
- simgrid::surf::HostImpl *host = sg_host_by_name(name)->extension<simgrid::surf::HostImpl>();
- simgrid::surf::VirtualMachine *vm = dynamic_cast<simgrid::surf::VirtualMachine*>(host);
- if (vm) // If it's a VM, take the corresponding PM
- host = vm->getPm()->extension<simgrid::surf::HostImpl>();
-
- HostEnergy *host_energy = host->p_host->extension<HostEnergy>();
-
- if(host_energy->last_updated < surf_get_clock())
- host_energy->update();
+ std::list<simgrid::surf::Cpu*> cpus = getActionCpus(action);
+ for(simgrid::surf::Cpu* cpu : cpus) {
+ const char *name = cpu->getName();
+ sg_host_t sghost = sg_host_by_name(name);
+ if(sghost == NULL)
+ continue;
+ simgrid::surf::HostImpl *host = sghost->extension<simgrid::surf::HostImpl>();
+ simgrid::surf::VirtualMachine *vm = dynamic_cast<simgrid::surf::VirtualMachine*>(host);
+ if (vm) // If it's a VM, take the corresponding PM
+ host = vm->getPm()->extension<simgrid::surf::HostImpl>();
+
+ HostEnergy *host_energy = host->p_host->extension<HostEnergy>();
+
+ if(host_energy->last_updated < surf_get_clock())
+ host_energy->update();
+ }
}
static void onHostStateChange(simgrid::s4u::Host &host) {