From 2653a7d76628a32b362df6a1336fd36a744796d2 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 4 Dec 2015 12:38:50 +0100 Subject: [PATCH] every occurence of power in surf should be renamed to speed, as it is not the electical power --- src/surf/cpu_cas01.cpp | 22 +++++++++++----------- src/surf/cpu_interface.cpp | 16 ++++++++-------- src/surf/cpu_interface.hpp | 6 +++--- src/surf/cpu_ti.cpp | 16 ++++++++-------- src/surf/host_ptask_L07.cpp | 6 +++--- src/surf/plugins/energy.cpp | 4 ++-- src/surf/surf_interface.hpp | 4 ++-- 7 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index a8412b0975..cd0b597e60 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -174,7 +174,7 @@ CpuCas01::CpuCas01(CpuCas01Model *model, const char *name, xbt_dynar_t powerPeak 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) @@ -222,20 +222,20 @@ void CpuCas01::updateState(tmgr_trace_event_t event_type, double value, double d /* 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(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; @@ -278,7 +278,7 @@ CpuAction *CpuCas01::execute(double size) 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; @@ -291,7 +291,7 @@ CpuAction *CpuCas01::sleep(double duration) 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 @@ -321,7 +321,7 @@ CpuAction *CpuCas01::sleep(double duration) double CpuCas01::getCurrentPowerPeak() { - return m_powerPeak; + return m_speedPeak; } double CpuCas01::getPowerPeakAt(int pstate_index) @@ -344,7 +344,7 @@ void CpuCas01::setPstate(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() diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 0513ad6517..59bdfcd94e 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -138,8 +138,8 @@ Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, 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) { @@ -151,8 +151,8 @@ Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, 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) @@ -168,7 +168,7 @@ Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, 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); } } } @@ -197,18 +197,18 @@ Cpu::~Cpu(){ 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() diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index e28550a524..5ccd0c3e52 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -171,9 +171,9 @@ public: 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; diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index b2242fac7d..881cde6447 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -517,7 +517,7 @@ void CpuTiModel::addTraces() 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) { @@ -545,7 +545,7 @@ CpuTi::CpuTi(CpuTiModel *model, const char *name, xbt_dynar_t powerPeak, : 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; @@ -557,8 +557,8 @@ CpuTi::CpuTi(CpuTiModel *model, const char *name, xbt_dynar_t powerPeak, 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); @@ -603,7 +603,7 @@ void CpuTi::updateState(tmgr_trace_event_t event_type, 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); @@ -693,7 +693,7 @@ updateRemainingAmount(now); (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) */ @@ -735,7 +735,7 @@ bool CpuTi::isUsed() double CpuTi::getAvailableSpeed() { - m_powerScale = p_availTrace->getPowerScale(surf_get_clock()); + m_speedScale = p_availTrace->getPowerScale(surf_get_clock()); return Cpu::getAvailableSpeed(); } @@ -754,7 +754,7 @@ void CpuTi::updateRemainingAmount(double now) 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); diff --git a/src/surf/host_ptask_L07.cpp b/src/surf/host_ptask_L07.cpp index b4434d5b6d..10c4af5f93 100644 --- a/src/surf/host_ptask_L07.cpp +++ b/src/surf/host_ptask_L07.cpp @@ -414,7 +414,7 @@ CpuL07::CpuL07(CpuL07Model *model, const char* name, xbt_dict_t props, : 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); @@ -489,8 +489,8 @@ bool LinkL07::isUsed(){ 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) { diff --git a/src/surf/plugins/energy.cpp b/src/surf/plugins/energy.cpp index 0a7f9ab6d7..87bd154583 100644 --- a/src/surf/plugins/energy.cpp +++ b/src/surf/plugins/energy.cpp @@ -65,7 +65,7 @@ static void energyVMCreatedCallback(VirtualMachine* vm) { /* 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(); @@ -83,7 +83,7 @@ static void update_consumption(Host *host, HostEnergy *host_energy) { 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){ diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 01623b2d57..1d5611f615 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -399,8 +399,8 @@ private: * @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; -- 2.20.1