From 6a53589d043ef92bb71eeac8dae8a6b1497b2f97 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 19 Mar 2016 03:36:48 +0100 Subject: [PATCH 1/1] uniformize how CpuTI creates SpeedTrace with other models --- src/surf/cpu_interface.hpp | 2 +- src/surf/cpu_ti.cpp | 29 +++++++++++------------------ src/surf/cpu_ti.hpp | 8 ++++---- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index cdefec3f0e..1b050c8082 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -44,7 +44,7 @@ public: * * @param host The host that will have this CPU * @param speedPeak The peak spead (max speed in Flops when no external load comes from a trace) - * @param speedTrace Trace variations + * @param speedTrace Speed variations * @param core The number of core of this Cpu */ virtual Cpu *createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPeak, tmgr_trace_t speedTrace, int core)=0; diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 0bf0d2503d..1b21c4511e 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -471,34 +471,27 @@ CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeak, xbt_assert(core==1,"Multi-core not handled by this model yet"); coresAmount_ = core; - availTrace_ = new CpuTiTgmr(speedTrace, 1/*scale*/); actionSet_ = new ActionTiList(); xbt_dynar_get_cpy(speedPeak, 0, &speed_.peak); XBT_DEBUG("CPU create: peak=%f", speed_.peak); - if (speedTrace && xbt_dynar_length(speedTrace->event_list) > 1) { - s_tmgr_event_t val; - // add a fake trace event if periodicity == 0 - xbt_dynar_get_cpy(speedTrace->event_list, xbt_dynar_length(speedTrace->event_list) - 1, &val); - if (val.delta == 0) - speed_.event = future_evt_set->add_trace(tmgr_empty_trace_new(), availTrace_->lastTime_, this); - } + setSpeedTrace(speedTrace); } CpuTi::~CpuTi() { modified(false); - delete availTrace_; + delete speedIntegratedTrace_; delete actionSet_; } void CpuTi::setSpeedTrace(tmgr_trace_t trace) { - if (availTrace_) - delete availTrace_; + if (speedIntegratedTrace_) + delete speedIntegratedTrace_; - availTrace_ = new CpuTiTgmr(trace, speed_.scale); + speedIntegratedTrace_ = new CpuTiTgmr(trace, speed_.scale); /* add a fake trace event if periodicity == 0 */ if (trace && xbt_dynar_length(trace->event_list) > 1) { @@ -522,15 +515,15 @@ void CpuTi::apply_event(tmgr_trace_iterator_t event, double value) modified(true); - speedTrace = availTrace_->speedTrace_; + speedTrace = speedIntegratedTrace_->speedTrace_; xbt_dynar_get_cpy(speedTrace->event_list, xbt_dynar_length(speedTrace->event_list) - 1, &val); - delete availTrace_; + delete speedIntegratedTrace_; speed_.scale = val.value; trace = new CpuTiTgmr(TRACE_FIXED, val.value); XBT_DEBUG("value %f", val.value); - availTrace_ = trace; + speedIntegratedTrace_ = trace; tmgr_trace_event_unref(&speed_.event); @@ -612,7 +605,7 @@ void CpuTi::updateActionsFinishTime(double now) total_area /= speed_.peak; - action->setFinishTime(availTrace_->solve(now, total_area)); + action->setFinishTime(speedIntegratedTrace_->solve(now, total_area)); /* verify which event will happen before (max_duration or finish time) */ if (action->getMaxDuration() != NO_MAX_DURATION && action->getStartTime() + action->getMaxDuration() < action->m_finish) @@ -652,7 +645,7 @@ bool CpuTi::isUsed() double CpuTi::getAvailableSpeed() { - speed_.scale = availTrace_->getPowerScale(surf_get_clock()); + speed_.scale = speedIntegratedTrace_->getPowerScale(surf_get_clock()); return Cpu::getAvailableSpeed(); } @@ -665,7 +658,7 @@ void CpuTi::updateRemainingAmount(double now) return; /* compute the integration area */ - double area_total = availTrace_->integrate(lastUpdate_, now) * speed_.peak; + double area_total = speedIntegratedTrace_->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 45f95fa906..3f531d8921 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -126,10 +126,10 @@ public: void modified(bool modified); - CpuTiTgmr *availTrace_; /*< Structure with data needed to integrate trace file */ - ActionTiList *actionSet_; /*< set with all actions running on cpu */ - double sumPriority_; /*< the sum of actions' priority that are running on cpu */ - double lastUpdate_ = 0; /*< last update of actions' remaining amount done */ + CpuTiTgmr *speedIntegratedTrace_ = NULL;/*< Structure with data needed to integrate trace file */ + ActionTiList *actionSet_ = NULL; /*< set with all actions running on cpu */ + double sumPriority_ = 0; /*< the sum of actions' priority that are running on cpu */ + double lastUpdate_ = 0; /*< last update of actions' remaining amount done */ double currentFrequency_; -- 2.20.1