From 4580d8ca126c4e18a4b98263ab3a3da47db009f8 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 14 Mar 2016 22:09:16 +0100 Subject: [PATCH] surf::cpu: apply the latest naming convention of fields and methods --- src/surf/cpu_cas01.cpp | 34 ++++++++-------- src/surf/cpu_interface.cpp | 60 ++++++++++++++--------------- src/surf/cpu_interface.hpp | 18 ++++----- src/surf/cpu_ti.cpp | 32 +++++++-------- src/surf/cpu_ti.hpp | 2 +- src/surf/plugins/energy.cpp | 6 +-- src/surf/ptask_L07.cpp | 18 ++++----- src/surf/xml/surfxml_parseplatf.cpp | 4 +- 8 files changed, 87 insertions(+), 87 deletions(-) diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 6a00daf3d5..deed4fd36b 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -107,24 +107,24 @@ CpuCas01::CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, xbt_dynar_t s speedPeak, core, xbt_dynar_get_as(speedPeak, 0/*pstate*/, double)) { - XBT_DEBUG("CPU create: peak=%f, pstate=%d", p_speed.peak, m_pstate); + XBT_DEBUG("CPU create: peak=%f, pstate=%d", speed_.peak, pstate_); - m_core = core; + coresAmount_ = core; if (speedTrace) - p_speed.event = future_evt_set->add_trace(speedTrace, 0.0, this); + speed_.event = future_evt_set->add_trace(speedTrace, 0.0, this); if (stateTrace) - p_stateEvent = future_evt_set->add_trace(stateTrace, 0.0, this); + stateEvent_ = future_evt_set->add_trace(stateTrace, 0.0, this); } CpuCas01::~CpuCas01() { if (getModel() == surf_cpu_model_pm) - xbt_dynar_free(&p_speedPeakList); + xbt_dynar_free(&speedPeakList_); } xbt_dynar_t CpuCas01::getSpeedPeakList(){ - return p_speedPeakList; + return speedPeakList_; } bool CpuCas01::isUsed() @@ -138,14 +138,14 @@ void CpuCas01::onSpeedChange() { lmm_element_t elem = NULL; lmm_update_constraint_bound(getModel()->getMaxminSystem(), getConstraint(), - m_core * p_speed.scale * p_speed.peak); + coresAmount_ * speed_.scale * speed_.peak); 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(), - p_speed.scale * p_speed.peak); + speed_.scale * speed_.peak); } Cpu::onSpeedChange(); @@ -153,17 +153,17 @@ void CpuCas01::onSpeedChange() { void CpuCas01::apply_event(tmgr_trace_iterator_t event, double value) { - if (event == p_speed.event) { + if (event == speed_.event) { /* TODO (Hypervisor): do the same thing for constraint_core[i] */ - xbt_assert(m_core == 1, "FIXME: add speed scaling code also for constraint_core[i]"); + xbt_assert(coresAmount_ == 1, "FIXME: add speed scaling code also for constraint_core[i]"); - p_speed.scale = value; + speed_.scale = value; onSpeedChange(); - tmgr_trace_event_unref(&p_speed.event); - } else if (event == p_stateEvent) { + tmgr_trace_event_unref(&speed_.event); + } else if (event == stateEvent_) { /* TODO (Hypervisor): do the same thing for constraint_core[i] */ - xbt_assert(m_core == 1, "FIXME: add state change code also for constraint_core[i]"); + xbt_assert(coresAmount_ == 1, "FIXME: add state change code also for constraint_core[i]"); if (value > 0) { if(isOff()) @@ -188,7 +188,7 @@ void CpuCas01::apply_event(tmgr_trace_iterator_t event, double value) } } } - tmgr_trace_event_unref(&p_stateEvent); + tmgr_trace_event_unref(&stateEvent_); } else { xbt_die("Unknown event!\n"); @@ -200,7 +200,7 @@ CpuAction *CpuCas01::execution_start(double size) XBT_IN("(%s,%g)", getName(), size); CpuCas01Action *action = new CpuCas01Action(getModel(), size, isOff(), - p_speed.scale * p_speed.peak, getConstraint()); + speed_.scale * speed_.peak, getConstraint()); XBT_OUT(); return action; @@ -213,7 +213,7 @@ CpuAction *CpuCas01::sleep(double duration) XBT_IN("(%s,%g)", getName(), duration); CpuCas01Action *action = new CpuCas01Action(getModel(), 1.0, isOff(), - p_speed.scale * p_speed.peak, getConstraint()); + speed_.scale * speed_.peak, getConstraint()); // FIXME: sleep variables should not consume 1.0 in lmm_expand diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index e6a50ecba5..e084657416 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -137,20 +137,20 @@ Cpu::Cpu(Model *model, simgrid::s4u::Host *host, Cpu::Cpu(Model *model, simgrid::s4u::Host *host, lmm_constraint_t constraint, xbt_dynar_t speedPeakList, int core, double speedPeak) : Resource(model, host->name().c_str(), constraint) - , m_core(core) - , m_host(host) + , coresAmount_(core) + , host_(host) { - p_speed.peak = speedPeak; - p_speed.scale = 1; + speed_.peak = speedPeak; + speed_.scale = 1; host->pimpl_cpu = this; - xbt_assert(p_speed.scale > 0, "Available speed has to be >0"); + xbt_assert(speed_.scale > 0, "Available speed has to be >0"); // Copy the power peak array: - p_speedPeakList = xbt_dynar_new(sizeof(double), nullptr); + speedPeakList_ = xbt_dynar_new(sizeof(double), nullptr); unsigned long n = xbt_dynar_length(speedPeakList); for (unsigned long i = 0; i != n; ++i) { double value = xbt_dynar_get_as(speedPeakList, i, double); - xbt_dynar_push(p_speedPeakList, &value); + xbt_dynar_push(speedPeakList_, &value); } /* Currently, we assume that a VM does not have a multicore CPU. */ @@ -165,7 +165,7 @@ Cpu::Cpu(Model *model, simgrid::s4u::Host *host, lmm_constraint_t constraint, for (i = 0; i < core; i++) { /* just for a unique id, never used as a string. */ p_constraintCoreId[i] = bprintf("%s:%i", host->name().c_str(), i); - p_constraintCore[i] = lmm_constraint_new(model->getMaxminSystem(), p_constraintCoreId[i], p_speed.scale * p_speed.peak); + p_constraintCore[i] = lmm_constraint_new(model->getMaxminSystem(), p_constraintCoreId[i], speed_.scale * speed_.peak); } } } @@ -173,48 +173,48 @@ Cpu::Cpu(Model *model, simgrid::s4u::Host *host, lmm_constraint_t constraint, Cpu::~Cpu() { if (p_constraintCoreId){ - for (int i = 0; i < m_core; i++) { + for (int i = 0; i < coresAmount_; i++) { xbt_free(p_constraintCoreId[i]); } xbt_free(p_constraintCore); } if (p_constraintCoreId) xbt_free(p_constraintCoreId); - if (p_speedPeakList) - xbt_dynar_free(&p_speedPeakList); + if (speedPeakList_) + xbt_dynar_free(&speedPeakList_); } double Cpu::getCurrentPowerPeak() { - return p_speed.peak; + return speed_.peak; } int Cpu::getNbPStates() { - return xbt_dynar_length(p_speedPeakList); + return xbt_dynar_length(speedPeakList_); } void Cpu::setPState(int pstate_index) { - xbt_dynar_t plist = p_speedPeakList; + xbt_dynar_t plist = speedPeakList_; xbt_assert(pstate_index <= (int)xbt_dynar_length(plist), "Invalid parameters for CPU %s (pstate %d > length of pstates %d)", getName(), pstate_index, (int)xbt_dynar_length(plist)); double new_peak_speed = xbt_dynar_get_as(plist, pstate_index, double); - m_pstate = pstate_index; - p_speed.peak = new_peak_speed; + pstate_ = pstate_index; + speed_.peak = new_peak_speed; onSpeedChange(); } int Cpu::getPState() { - return m_pstate; + return pstate_; } double Cpu::getPowerPeakAt(int pstate_index) { - xbt_dynar_t plist = p_speedPeakList; + xbt_dynar_t plist = speedPeakList_; xbt_assert((pstate_index <= (int)xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)"); return xbt_dynar_get_as(plist, pstate_index, double); @@ -222,37 +222,37 @@ double Cpu::getPowerPeakAt(int pstate_index) double Cpu::getSpeed(double load) { - return load * p_speed.peak; + return load * speed_.peak; } double Cpu::getAvailableSpeed() { /* number between 0 and 1 */ - return p_speed.scale; + return speed_.scale; } void Cpu::onSpeedChange() { TRACE_surf_host_set_speed(surf_get_clock(), getName(), - m_core * p_speed.scale * p_speed.peak); + coresAmount_ * speed_.scale * speed_.peak); } int Cpu::getCore() { - return m_core; + return coresAmount_; } -void Cpu::set_state_trace(tmgr_trace_t trace) +void Cpu::setStateTrace(tmgr_trace_t trace) { - xbt_assert(p_stateEvent==NULL,"Cannot set a second state trace to Host %s", m_host->name().c_str()); + xbt_assert(stateEvent_==NULL,"Cannot set a second state trace to Host %s", host_->name().c_str()); - p_stateEvent = future_evt_set->add_trace(trace, 0.0, this); + stateEvent_ = future_evt_set->add_trace(trace, 0.0, this); } -void Cpu::set_speed_trace(tmgr_trace_t trace) +void Cpu::setSpeedTrace(tmgr_trace_t trace) { - xbt_assert(p_speed.event==NULL,"Cannot set a second speed trace to Host %s", m_host->name().c_str()); + xbt_assert(speed_.event==NULL,"Cannot set a second speed trace to Host %s", host_->name().c_str()); - p_speed.event = future_evt_set->add_trace(trace, 0.0, this); + speed_.event = future_evt_set->add_trace(trace, 0.0, this); } @@ -317,7 +317,7 @@ void CpuAction::setAffinity(Cpu *cpu, unsigned long mask) unsigned long nbits = 0; /* FIXME: There is much faster algorithms doing this. */ - for (int i = 0; i < cpu->m_core; i++) { + for (int i = 0; i < cpu->coresAmount_; i++) { unsigned long has_affinity = (1UL << i) & mask; if (has_affinity) nbits += 1; @@ -330,7 +330,7 @@ void CpuAction::setAffinity(Cpu *cpu, unsigned long mask) } } - for (int i = 0; i < cpu->m_core; i++) { + for (int i = 0; i < cpu->coresAmount_; i++) { XBT_DEBUG("clear affinity %p to cpu-%d@%s", this, i, cpu->getName()); lmm_shrink(cpu->getModel()->getMaxminSystem(), cpu->p_constraintCore[i], var_obj); diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 768d8d6e9a..5aa2b4bd4b 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -133,25 +133,25 @@ public: virtual void setPState(int pstate_index); virtual int getPState(); - simgrid::s4u::Host* getHost() { return m_host; } + simgrid::s4u::Host* getHost() { return host_; } public: - int m_core = 1; /* Amount of cores */ - simgrid::s4u::Host* m_host; + int coresAmount_ = 1; + simgrid::s4u::Host* host_; - xbt_dynar_t p_speedPeakList = NULL; /*< List of supported CPU capacities (pstate related) */ - int m_pstate = 0; /*< Current pstate (index in the speedPeakList)*/ + xbt_dynar_t speedPeakList_ = NULL; /*< List of supported CPU capacities (pstate related) */ + int pstate_ = 0; /*< Current pstate (index in the speedPeakList)*/ /* Note (hypervisor): */ lmm_constraint_t *p_constraintCore=NULL; void **p_constraintCoreId=NULL; public: - virtual void set_state_trace(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) */ + 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 setSpeedTrace(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_iterator_t p_stateEvent = nullptr; - s_surf_metric_t p_speed = {1.0, 0, nullptr}; + tmgr_trace_iterator_t stateEvent_ = nullptr; + s_surf_metric_t speed_ = {1.0, 0, nullptr}; }; /********** diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 20392ff927..81ca378472 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -472,17 +472,17 @@ CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeak, : Cpu(model, host, NULL, core, 0) { xbt_assert(core==1,"Multi-core not handled by this model yet"); - m_core = core; + coresAmount_ = core; availTrace_ = new CpuTiTgmr(speedTrace, 1/*scale*/); actionSet_ = new ActionTiList(); - xbt_dynar_get_cpy(speedPeak, 0, &p_speed.peak); - XBT_DEBUG("CPU create: peak=%f", p_speed.peak); + xbt_dynar_get_cpy(speedPeak, 0, &speed_.peak); + XBT_DEBUG("CPU create: peak=%f", speed_.peak); if (stateTrace) - p_stateEvent = future_evt_set->add_trace(stateTrace, 0.0, this); + stateEvent_ = future_evt_set->add_trace(stateTrace, 0.0, this); if (speedTrace && xbt_dynar_length(speedTrace->event_list) > 1) { s_tmgr_event_t val; @@ -490,7 +490,7 @@ CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeak, xbt_dynar_get_cpy(speedTrace->event_list, xbt_dynar_length(speedTrace->event_list) - 1, &val); if (val.delta == 0) { - p_speed.event = + speed_.event = future_evt_set->add_trace(tmgr_empty_trace_new(), availTrace_->lastTime_, this); } } @@ -502,25 +502,25 @@ CpuTi::~CpuTi() delete availTrace_; delete actionSet_; } -void CpuTi::set_speed_trace(tmgr_trace_t trace) +void CpuTi::setSpeedTrace(tmgr_trace_t trace) { if (availTrace_) delete availTrace_; - availTrace_ = new CpuTiTgmr(trace, p_speed.scale); + availTrace_ = new CpuTiTgmr(trace, speed_.scale); /* add a fake trace event if periodicity == 0 */ if (trace && xbt_dynar_length(trace->event_list) > 1) { s_tmgr_event_t val; xbt_dynar_get_cpy(trace->event_list, xbt_dynar_length(trace->event_list) - 1, &val); if (val.delta == 0) - p_speed.event = future_evt_set->add_trace(tmgr_empty_trace_new(), 0.0, this); + speed_.event = future_evt_set->add_trace(tmgr_empty_trace_new(), 0.0, this); } } void CpuTi::apply_event(tmgr_trace_iterator_t event, double value) { - if (event == p_speed.event) { + if (event == speed_.event) { tmgr_trace_t speedTrace; CpuTiTgmr *trace; s_tmgr_event_t val; @@ -534,16 +534,16 @@ void CpuTi::apply_event(tmgr_trace_iterator_t event, double value) speedTrace = availTrace_->speedTrace_; xbt_dynar_get_cpy(speedTrace->event_list, xbt_dynar_length(speedTrace->event_list) - 1, &val); delete availTrace_; - p_speed.scale = val.value; + speed_.scale = val.value; trace = new CpuTiTgmr(TRACE_FIXED, val.value); XBT_DEBUG("value %f", val.value); availTrace_ = trace; - tmgr_trace_event_unref(&p_speed.event); + tmgr_trace_event_unref(&speed_.event); - } else if (event == p_stateEvent) { + } else if (event == stateEvent_) { if (value > 0) { if(isOff()) xbt_dynar_push_as(host_that_restart, char*, (char *)getName()); @@ -571,7 +571,7 @@ void CpuTi::apply_event(tmgr_trace_iterator_t event, double value) } } } - tmgr_trace_event_unref(&p_stateEvent); + tmgr_trace_event_unref(&stateEvent_); } else { xbt_die("Unknown event!\n"); @@ -619,7 +619,7 @@ void CpuTi::updateActionsFinishTime(double now) (action->getRemains()) * sum_priority * action->getPriority(); - total_area /= p_speed.peak; + total_area /= speed_.peak; action->setFinishTime(availTrace_->solve(now, total_area)); /* verify which event will happen before (max_duration or finish time) */ @@ -661,7 +661,7 @@ bool CpuTi::isUsed() double CpuTi::getAvailableSpeed() { - p_speed.scale = availTrace_->getPowerScale(surf_get_clock()); + speed_.scale = availTrace_->getPowerScale(surf_get_clock()); return Cpu::getAvailableSpeed(); } @@ -674,7 +674,7 @@ void CpuTi::updateRemainingAmount(double now) return; /* compute the integration area */ - double area_total = availTrace_->integrate(lastUpdate_, now) * p_speed.peak; + double area_total = availTrace_->integrate(lastUpdate_, now) * speed_.peak; XBT_DEBUG("Flops total: %f, Last update %f", area_total, lastUpdate_); for(ActionTiList::iterator it(actionSet_->begin()), itend(actionSet_->end()) ; it != itend ; ++it) { diff --git a/src/surf/cpu_ti.hpp b/src/surf/cpu_ti.hpp index 2f01f7fc10..2b37326c97 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -115,7 +115,7 @@ public: tmgr_trace_t stateTrace) ; ~CpuTi(); - void set_speed_trace(tmgr_trace_t trace) override; + void setSpeedTrace(tmgr_trace_t trace) override; void apply_event(tmgr_trace_iterator_t event, double value) override; void updateActionsFinishTime(double now); diff --git a/src/surf/plugins/energy.cpp b/src/surf/plugins/energy.cpp index c5c9f3aa4f..c972873381 100644 --- a/src/surf/plugins/energy.cpp +++ b/src/surf/plugins/energy.cpp @@ -69,13 +69,13 @@ void HostEnergy::update() 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; @@ -94,7 +94,7 @@ void HostEnergy::update() 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) : diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index b94e7ce4d0..1a8eaaaa35 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -306,10 +306,10 @@ CpuL07::CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, p_constraint = lmm_constraint_new(model->getMaxminSystem(), this, xbt_dynar_get_as(speedPeakList,0,double)); if (speedTrace) - p_speed.event = future_evt_set->add_trace(speedTrace, 0.0, this); + speed_.event = future_evt_set->add_trace(speedTrace, 0.0, this); if (state_trace) - p_stateEvent = future_evt_set->add_trace(state_trace, 0.0, this); + stateEvent_ = future_evt_set->add_trace(state_trace, 0.0, this); } CpuL07::~CpuL07() @@ -358,14 +358,14 @@ void CpuL07::onSpeedChange() { lmm_variable_t var = NULL; lmm_element_t elem = NULL; - lmm_update_constraint_bound(getModel()->getMaxminSystem(), getConstraint(), p_speed.peak * p_speed.scale); + lmm_update_constraint_bound(getModel()->getMaxminSystem(), getConstraint(), speed_.peak * speed_.scale); while ((var = lmm_get_var_from_cnst (getModel()->getMaxminSystem(), getConstraint(), &elem))) { Action *action = static_cast(lmm_variable_id(var)); lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), - p_speed.scale * p_speed.peak); + speed_.scale * speed_.peak); } Cpu::onSpeedChange(); @@ -378,17 +378,17 @@ bool LinkL07::isUsed(){ void CpuL07::apply_event(tmgr_trace_iterator_t triggered, double value){ XBT_DEBUG("Updating cpu %s (%p) with value %g", getName(), this, value); - if (triggered == p_speed.event) { - p_speed.scale = value; + if (triggered == speed_.event) { + speed_.scale = value; onSpeedChange(); - tmgr_trace_event_unref(&p_speed.event); + tmgr_trace_event_unref(&speed_.event); - } else if (triggered == p_stateEvent) { + } else if (triggered == stateEvent_) { if (value > 0) turnOn(); else turnOff(); - tmgr_trace_event_unref(&p_stateEvent); + tmgr_trace_event_unref(&stateEvent_); } else { xbt_die("Unknown event!\n"); diff --git a/src/surf/xml/surfxml_parseplatf.cpp b/src/surf/xml/surfxml_parseplatf.cpp index 283098c153..a63728748c 100644 --- a/src/surf/xml/surfxml_parseplatf.cpp +++ b/src/surf/xml/surfxml_parseplatf.cpp @@ -190,7 +190,7 @@ void parse_platform_file(const char *file) xbt_assert(host, "Host %s undefined", elm); simgrid::surf::Cpu *cpu = host->pimpl_cpu; - cpu->set_state_trace(trace); + cpu->setStateTrace(trace); } xbt_dict_foreach(trace_connect_list_host_speed, cursor, trace_name, elm) { tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); @@ -200,7 +200,7 @@ void parse_platform_file(const char *file) xbt_assert(host, "Host %s undefined", elm); simgrid::surf::Cpu *cpu = host->pimpl_cpu; - cpu->set_speed_trace(trace); + cpu->setSpeedTrace(trace); } xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) { tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); -- 2.20.1