m_pstate = pstate;
- XBT_DEBUG("CPU create: peak=%f, pstate=%d", m_powerPeak, m_pstate);
+ XBT_DEBUG("CPU create: peak=%f, pstate=%d", m_speedPeak, m_pstate);
m_core = core;
if (powerTrace)
/* TODO (Hypervisor): do the same thing for constraint_core[i] */
xbt_assert(m_core == 1, "FIXME: add power scaling code also for constraint_core[i]");
- m_powerScale = value;
+ m_speedScale = value;
lmm_update_constraint_bound(getModel()->getMaxminSystem(), getConstraint(),
- m_core * m_powerScale *
- m_powerPeak);
+ m_core * m_speedScale *
+ m_speedPeak);
TRACE_surf_host_set_power(date, getName(),
- m_core * m_powerScale *
- m_powerPeak);
+ m_core * m_speedScale *
+ m_speedPeak);
while ((var = lmm_get_var_from_cnst
(getModel()->getMaxminSystem(), getConstraint(), &elem))) {
CpuCas01Action *action = static_cast<CpuCas01Action*>(lmm_variable_id(var));
lmm_update_variable_bound(getModel()->getMaxminSystem(),
action->getVariable(),
- m_powerScale * m_powerPeak);
+ m_speedScale * m_speedPeak);
}
if (tmgr_trace_event_free(event_type))
p_powerEvent = NULL;
XBT_IN("(%s,%g)", getName(), size);
CpuCas01Action *action = new CpuCas01Action(getModel(), size, getState() != SURF_RESOURCE_ON,
- m_powerScale * m_powerPeak, getConstraint());
+ m_speedScale * m_speedPeak, getConstraint());
XBT_OUT();
return action;
XBT_IN("(%s,%g)", getName(), duration);
CpuCas01Action *action = new CpuCas01Action(getModel(), 1.0, getState() != SURF_RESOURCE_ON,
- m_powerScale * m_powerPeak, getConstraint());
+ m_speedScale * m_speedPeak, getConstraint());
// FIXME: sleep variables should not consume 1.0 in lmm_expand
double CpuCas01::getCurrentPowerPeak()
{
- return m_powerPeak;
+ return m_speedPeak;
}
double CpuCas01::getPowerPeakAt(int pstate_index)
double new_pstate = xbt_dynar_get_as(plist, pstate_index, double);
m_pstate = pstate_index;
- m_powerPeak = new_pstate;
+ m_speedPeak = new_pstate;
}
int CpuCas01::getPstate()
e_surf_resource_state_t stateInitial)
: Resource(model, name, props, stateInitial)
, m_core(core)
- , m_powerPeak(powerPeak)
- , m_powerScale(powerScale)
+ , m_speedPeak(powerPeak)
+ , m_speedScale(powerScale)
, p_constraintCore(NULL)
, p_constraintCoreId(NULL)
{
double powerScale, e_surf_resource_state_t stateInitial)
: Resource(model, name, props, constraint, stateInitial)
, m_core(core)
- , m_powerPeak(powerPeak)
- , m_powerScale(powerScale)
+ , m_speedPeak(powerPeak)
+ , m_speedScale(powerScale)
{
/* At now, we assume that a VM does not have a multicore CPU. */
if (core > 1)
for (i = 0; i < core; i++) {
/* just for a unique id, never used as a string. */
p_constraintCoreId[i] = bprintf("%s:%i", name, i);
- p_constraintCore[i] = lmm_constraint_new(model->getMaxminSystem(), p_constraintCoreId[i], m_powerScale * m_powerPeak);
+ p_constraintCore[i] = lmm_constraint_new(model->getMaxminSystem(), p_constraintCoreId[i], m_speedScale * m_speedPeak);
}
}
}
double Cpu::getCurrentPowerPeak()
{
- return m_powerPeak;
+ return m_speedPeak;
}
double Cpu::getSpeed(double load)
{
- return load * m_powerPeak;
+ return load * m_speedPeak;
}
double Cpu::getAvailableSpeed()
{
/* number between 0 and 1 */
- return m_powerScale;
+ return m_speedScale;
}
int Cpu::getCore()
void setState(e_surf_resource_state_t state);
void addTraces(void);
- int m_core;
- double m_powerPeak; /*< CPU power peak */
- double m_powerScale; /*< Percentage of CPU available */
+ int m_core = 1; /* Amount of cores */
+ double m_speedPeak; /*< CPU speed peak, ie max value */
+ double m_speedScale; /*< Percentage of CPU available according to the trace, in [O,1] */
/* Note (hypervisor): */
lmm_constraint_t *p_constraintCore;
if (cpu->p_availTrace)
delete cpu->p_availTrace;
- cpu->p_availTrace = new CpuTiTgmr(trace, cpu->m_powerScale);
+ cpu->p_availTrace = new CpuTiTgmr(trace, cpu->m_speedScale);
/* add a fake trace event if periodicity == 0 */
if (trace && xbt_dynar_length(trace->s_list.event_list) > 1) {
: Cpu(model, name, properties, core, 0, powerScale, stateInitial)
{
p_powerEvent = NULL;
- m_powerScale = powerScale;
+ m_speedScale = powerScale;
m_core = core;
tmgr_trace_t empty_trace;
s_tmgr_event_t val;
m_lastUpdate = 0;
- xbt_dynar_get_cpy(powerPeak, 0, &m_powerPeak);
- XBT_DEBUG("CPU create: peak=%f", m_powerPeak);
+ xbt_dynar_get_cpy(powerPeak, 0, &m_speedPeak);
+ XBT_DEBUG("CPU create: peak=%f", m_speedPeak);
if (stateTrace)
p_stateEvent = tmgr_history_add_trace(history, stateTrace, 0.0, 0, this);
xbt_dynar_length(power_trace->s_list.event_list) - 1, &val);
/* free old trace */
delete p_availTrace;
- m_powerScale = val.value;
+ m_speedScale = val.value;
trace = new CpuTiTgmr(TRACE_FIXED, val.value);
XBT_DEBUG("value %f", val.value);
(action->getRemains()) * sum_priority *
action->getPriority();
- total_area /= m_powerPeak;
+ total_area /= m_speedPeak;
action->setFinishTime(p_availTrace->solve(now, total_area));
/* verify which event will happen before (max_duration or finish time) */
double CpuTi::getAvailableSpeed()
{
- m_powerScale = p_availTrace->getPowerScale(surf_get_clock());
+ m_speedScale = p_availTrace->getPowerScale(surf_get_clock());
return Cpu::getAvailableSpeed();
}
return;
/* calcule the surface */
- area_total = p_availTrace->integrate(m_lastUpdate, now) * m_powerPeak;
+ area_total = p_availTrace->integrate(m_lastUpdate, now) * m_speedPeak;
XBT_DEBUG("Flops total: %f, Last update %f", area_total,
m_lastUpdate);
: Cpu(model, name, props, lmm_constraint_new(ptask_maxmin_system, this, power_initial * power_scale),
core, power_initial, power_scale, state_initial)
{
- xbt_assert(m_powerScale > 0, "Power has to be >0");
+ xbt_assert(m_speedScale > 0, "Power has to be >0");
if (power_trace)
p_powerEvent = tmgr_history_add_trace(history, power_trace, 0.0, 0, this);
void CpuL07::updateState(tmgr_trace_event_t event_type, double value, double /*date*/){
XBT_DEBUG("Updating cpu %s (%p) with value %g", getName(), this, value);
if (event_type == p_powerEvent) {
- m_powerScale = value;
- lmm_update_constraint_bound(ptask_maxmin_system, getConstraint(), m_powerPeak * m_powerScale);
+ m_speedScale = value;
+ lmm_update_constraint_bound(ptask_maxmin_system, getConstraint(), m_speedPeak * m_speedScale);
if (tmgr_trace_event_free(event_type))
p_powerEvent = NULL;
} else if (event_type == p_stateEvent) {
/* Computes the consumption so far. Called lazily on need. */
static void update_consumption(Host *host, HostEnergy *host_energy) {
- double cpu_load = lmm_constraint_get_usage(host->p_cpu->getConstraint()) / host->p_cpu->m_powerPeak;
+ double cpu_load = lmm_constraint_get_usage(host->p_cpu->getConstraint()) / host->p_cpu->m_speedPeak;
double start_time = host_energy->last_updated;
double finish_time = surf_get_clock();
host_energy->last_updated = finish_time;
XBT_DEBUG("[cpu_update_energy] period=[%.2f-%.2f]; current power peak=%.0E flop/s; consumption change: %.2f J -> %.2f J",
- start_time, finish_time, host->p_cpu->m_powerPeak, previous_energy, energy_this_step);
+ start_time, finish_time, host->p_cpu->m_speedPeak, previous_energy, energy_this_step);
}
static void energyHostDestructedCallback(Host *host){
* @brief Resource which have a metric handled by a maxmin system
*/
typedef struct {
- double scale; /**< The scale of the metric */
- double peak; /**< The peak of the metric */
+ double peak; /**< The peak of the metric, ie its max value */
+ double scale; /**< Current availability of the metric according to the traces, in [0,1] */
tmgr_trace_event_t event; /**< The associated trace event associated to the metric */
} s_surf_metric_t;