From 17ec0354e5b48f8b724d87b20828daa80bfe0bad Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Fri, 12 Aug 2016 16:15:35 +0200 Subject: [PATCH] dynar to std::vector for pstates --- src/surf/cpu_cas01.cpp | 42 ++++++++++++-------------------- src/surf/cpu_cas01.hpp | 9 +++---- src/surf/cpu_interface.cpp | 33 +++++++++++++------------ src/surf/cpu_interface.hpp | 10 ++++---- src/surf/cpu_ti.cpp | 6 ++--- src/surf/cpu_ti.hpp | 4 +-- src/surf/instr_routing.cpp | 3 +-- src/surf/ptask_L07.cpp | 43 ++++++++++++--------------------- src/surf/ptask_L07.hpp | 23 +++++------------- src/surf/sg_platf.cpp | 18 +++++++------- src/surf/xml/platf_private.hpp | 2 +- src/surf/xml/surfxml_sax_cb.cpp | 8 +++--- 12 files changed, 82 insertions(+), 119 deletions(-) diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 6321e49c0f..8299e08506 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -77,7 +77,7 @@ CpuCas01Model::~CpuCas01Model() delete p_cpuRunningActionSetThatDoesNotNeedBeingChecked; } -Cpu *CpuCas01Model::createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core) +Cpu *CpuCas01Model::createCpu(simgrid::s4u::Host *host, std::vector *speedPerPstate, int core) { return new CpuCas01(this, host, speedPerPstate, core); } @@ -90,9 +90,8 @@ double CpuCas01Model::next_occuring_event_full(double /*now*/) /************ * Resource * ************/ -CpuCas01::CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core) -: Cpu(model, host, - lmm_constraint_new(model->getMaxminSystem(), this, core * xbt_dynar_get_as(speedPerPstate, 0/*pstate*/, double)), +CpuCas01::CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, std::vector *speedPerPstate, int core) +: Cpu(model, host, lmm_constraint_new(model->getMaxminSystem(), this, core * speedPerPstate->front()), speedPerPstate, core) { } @@ -100,10 +99,10 @@ CpuCas01::CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, xbt_dynar_t s CpuCas01::~CpuCas01() { if (getModel() == surf_cpu_model_pm) - xbt_dynar_free(&speedPerPstate_); + speedPerPstate_->clear(); } -xbt_dynar_t CpuCas01::getSpeedPeakList(){ +std::vector * CpuCas01::getSpeedPeakList(){ return speedPerPstate_; } @@ -119,13 +118,10 @@ void CpuCas01::onSpeedChange() { lmm_update_constraint_bound(getModel()->getMaxminSystem(), getConstraint(), coresAmount_ * speed_.scale * speed_.peak); - while ((var = lmm_get_var_from_cnst - (getModel()->getMaxminSystem(), getConstraint(), &elem))) { + 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(), - speed_.scale * speed_.peak); + lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), speed_.scale * speed_.peak); } Cpu::onSpeedChange(); @@ -177,10 +173,8 @@ void CpuCas01::apply_event(tmgr_trace_iterator_t event, double value) CpuAction *CpuCas01::execution_start(double size) { - XBT_IN("(%s,%g)", getName(), size); - CpuCas01Action *action = new CpuCas01Action(getModel(), size, isOff(), - speed_.scale * speed_.peak, getConstraint()); + CpuCas01Action *action = new CpuCas01Action(getModel(), size, isOff(), speed_.scale * speed_.peak, getConstraint()); XBT_OUT(); return action; @@ -192,27 +186,23 @@ CpuAction *CpuCas01::sleep(double duration) duration = MAX(duration, sg_surf_precision); XBT_IN("(%s,%g)", getName(), duration); - CpuCas01Action *action = new CpuCas01Action(getModel(), 1.0, isOff(), - speed_.scale * speed_.peak, getConstraint()); + CpuCas01Action *action = new CpuCas01Action(getModel(), 1.0, isOff(), speed_.scale * speed_.peak, getConstraint()); // FIXME: sleep variables should not consume 1.0 in lmm_expand action->maxDuration_ = duration; action->suspended_ = 2; if (duration == NO_MAX_DURATION) { - /* Move to the *end* of the corresponding action set. This convention - is used to speed up update_resource_state */ + /* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */ action->getStateSet()->erase(action->getStateSet()->iterator_to(*action)); action->stateSet_ = static_cast(getModel())->p_cpuRunningActionSetThatDoesNotNeedBeingChecked; action->getStateSet()->push_back(*action); } - lmm_update_variable_weight(getModel()->getMaxminSystem(), - action->getVariable(), 0.0); + lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), 0.0); if (getModel()->getUpdateMechanism() == UM_LAZY) { // remove action from the heap action->heapRemove(getModel()->getActionHeap()); - // this is necessary for a variable with weight 0 since such - // variables are ignored in lmm and we need to set its max_duration - // correctly at the next call to share_resources + // this is necessary for a variable with weight 0 since such variables are ignored in lmm and we need to set its + // max_duration correctly at the next call to share_resources getModel()->getModifiedSet()->push_front(*action); } @@ -225,9 +215,7 @@ CpuAction *CpuCas01::sleep(double duration) **********/ CpuCas01Action::CpuCas01Action(Model *model, double cost, bool failed, double speed, lmm_constraint_t constraint) - : CpuAction(model, cost, failed, - lmm_variable_new(model->getMaxminSystem(), this, - 1.0, speed, 1)) + : CpuAction(model, cost, failed, lmm_variable_new(model->getMaxminSystem(), this, 1.0, speed, 1)) { if (model->getUpdateMechanism() == UM_LAZY) { indexHeap_ = -1; @@ -237,7 +225,7 @@ CpuCas01Action::CpuCas01Action(Model *model, double cost, bool failed, double sp lmm_expand(model->getMaxminSystem(), constraint, getVariable(), 1.0); } -CpuCas01Action::~CpuCas01Action() {} +CpuCas01Action::~CpuCas01Action()=default; } } diff --git a/src/surf/cpu_cas01.hpp b/src/surf/cpu_cas01.hpp index cd6151c84d..39f1a372fe 100644 --- a/src/surf/cpu_cas01.hpp +++ b/src/surf/cpu_cas01.hpp @@ -27,7 +27,7 @@ public: CpuCas01Model(); ~CpuCas01Model() override; - Cpu *createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core) override; + Cpu *createCpu(simgrid::s4u::Host *host, std::vector *speedPerPstate, int core) override; double next_occuring_event_full(double now) override; ActionList *p_cpuRunningActionSetThatDoesNotNeedBeingChecked; }; @@ -38,7 +38,7 @@ public: class CpuCas01 : public Cpu { public: - CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core); + CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, std::vector *speedPerPstate, int core); ~CpuCas01() override; void apply_event(tmgr_trace_iterator_t event, double value) override; CpuAction *execution_start(double size) override; @@ -46,7 +46,7 @@ public: bool isUsed() override; - xbt_dynar_t getSpeedPeakList(); // FIXME: killme to hide our internals + std::vector * getSpeedPeakList(); // FIXME: killme to hide our internals protected: void onSpeedChange() override; @@ -59,8 +59,7 @@ class CpuCas01Action: public CpuAction { friend CpuAction *CpuCas01::execution_start(double size); friend CpuAction *CpuCas01::sleep(double duration); public: - CpuCas01Action(Model *model, double cost, bool failed, double speed, - lmm_constraint_t constraint); + CpuCas01Action(Model *model, double cost, bool failed, double speed, lmm_constraint_t constraint); ~CpuCas01Action() override; }; diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 5c95964896..d9f658bd1c 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -125,30 +125,30 @@ bool CpuModel::next_occuring_event_isIdempotent() /************ * Resource * ************/ -Cpu::Cpu(Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core) +Cpu::Cpu(Model *model, simgrid::s4u::Host *host, std::vector *speedPerPstate, int core) : Cpu(model, host, nullptr/*constraint*/, speedPerPstate, core) { } Cpu::Cpu(Model *model, simgrid::s4u::Host *host, lmm_constraint_t constraint, - xbt_dynar_t speedPerPstate, int core) + std::vector * speedPerPstate, int core) : Resource(model, host->name().c_str(), constraint) , coresAmount_(core) , host_(host) { xbt_assert(core > 0, "Host %s must have at least one core, not 0.", host->name().c_str()); - speed_.peak = xbt_dynar_get_as(speedPerPstate, 0/*pstate*/, double); + speed_.peak = speedPerPstate->front(); speed_.scale = 1; host->pimpl_cpu = this; xbt_assert(speed_.scale > 0, "Speed of host %s must be >0", host->name().c_str()); // Copy the power peak array: - speedPerPstate_ = xbt_dynar_new(sizeof(double), nullptr); - unsigned long n = xbt_dynar_length(speedPerPstate); + speedPerPstate_ = new std::vector(); + unsigned long n = speedPerPstate->size(); for (unsigned long i = 0; i != n; ++i) { - double value = xbt_dynar_get_as(speedPerPstate, i, double); - xbt_dynar_push(speedPerPstate_, &value); + double value = speedPerPstate->at(i); + speedPerPstate_->push_back(value); } xbt_assert(model == surf_cpu_model_pm || core==1, "Currently, VM cannot be multicore"); @@ -156,7 +156,7 @@ Cpu::Cpu(Model *model, simgrid::s4u::Host *host, lmm_constraint_t constraint, Cpu::~Cpu() { - xbt_dynar_free(&speedPerPstate_); + delete speedPerPstate_; } double Cpu::getPstateSpeedCurrent() @@ -166,16 +166,17 @@ double Cpu::getPstateSpeedCurrent() int Cpu::getNbPStates() { - return xbt_dynar_length(speedPerPstate_); + return speedPerPstate_->size(); } void Cpu::setPState(int pstate_index) { - xbt_dynar_t plist = speedPerPstate_; - 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)); + std::vector *plist = speedPerPstate_; + xbt_assert(pstate_index <= static_cast(plist->size()), + "Invalid parameters for CPU %s (pstate %d > length of pstates %d)", getName(), pstate_index, + static_cast(plist->size())); - double new_peak_speed = xbt_dynar_get_as(plist, pstate_index, double); + double new_peak_speed = plist->at(pstate_index); pstate_ = pstate_index; speed_.peak = new_peak_speed; @@ -189,10 +190,10 @@ int Cpu::getPState() double Cpu::getPstateSpeed(int pstate_index) { - xbt_dynar_t plist = speedPerPstate_; - xbt_assert((pstate_index <= (int)xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)"); + std::vector *plist = speedPerPstate_; + xbt_assert((pstate_index <= static_cast(plist->size())), "Invalid parameters (pstate index out of bounds)"); - return xbt_dynar_get_as(plist, pstate_index, double); + return plist->at(pstate_index); } double Cpu::getSpeed(double load) diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 2e72b9a94e..c1379c0016 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -7,7 +7,6 @@ #include #include -#include #include #include @@ -49,7 +48,7 @@ public: * @param speedPerPstate Processor speed (in Flops) of each pstate. This ignores any potential external load coming from a trace. * @param core The number of core of this Cpu */ - virtual Cpu *createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core)=0; + virtual Cpu *createCpu(simgrid::s4u::Host *host, std::vector *, int core)=0; void updateActionsStateLazy(double now, double delta) override; void updateActionsStateFull(double now, double delta) override; @@ -75,7 +74,8 @@ public: * @param speedPerPstate Processor speed (in flop per second) for each pstate * @param core The number of core of this Cpu */ - Cpu(simgrid::surf::Model *model, simgrid::s4u::Host *host, lmm_constraint_t constraint, xbt_dynar_t speedPerPstate, int core); + Cpu(simgrid::surf::Model *model, simgrid::s4u::Host *host, lmm_constraint_t constraint, + std::vector *speedPerPstate, int core); /** * @brief Cpu constructor @@ -85,7 +85,7 @@ public: * @param speedPerPstate Processor speed (in flop per second) for each pstate * @param core The number of core of this Cpu */ - Cpu(simgrid::surf::Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core); + Cpu(simgrid::surf::Model *model, simgrid::s4u::Host *host, std::vector *speedPerPstate, int core); ~Cpu(); @@ -133,7 +133,7 @@ public: int coresAmount_ = 1; simgrid::s4u::Host* host_; - xbt_dynar_t speedPerPstate_ = nullptr; /*< List of supported CPU capacities (pstate related) */ + std::vector *speedPerPstate_ = nullptr; /*< List of supported CPU capacities (pstate related) */ int pstate_ = 0; /*< Current pstate (index in the speedPeakList)*/ public: diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index c6e5c23c21..fdcdf176da 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -361,7 +361,7 @@ CpuTiModel::~CpuTiModel() xbt_heap_free(tiActionHeap_); } -Cpu *CpuTiModel::createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core) +Cpu *CpuTiModel::createCpu(simgrid::s4u::Host *host, std::vector* speedPerPstate, int core) { return new CpuTi(this, host, speedPerPstate, core); } @@ -403,7 +403,7 @@ void CpuTiModel::updateActionsState(double now, double /*delta*/) /************ * Resource * ************/ -CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core) +CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, std::vector *speedPerPstate, int core) : Cpu(model, host, speedPerPstate, core) { xbt_assert(core==1,"Multi-core not handled by this model yet"); @@ -411,7 +411,7 @@ CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, xbt_dynar_t speedPerPs actionSet_ = new ActionTiList(); - xbt_dynar_get_cpy(speedPerPstate, 0, &speed_.peak); + speed_.peak = speedPerPstate->front(); XBT_DEBUG("CPU create: peak=%f", speed_.peak); speedIntegratedTrace_ = new CpuTiTgmr(nullptr, 1/*scale*/); diff --git a/src/surf/cpu_ti.hpp b/src/surf/cpu_ti.hpp index 93417f705f..b99ecd3dea 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -111,7 +111,7 @@ typedef boost::intrusive::list ActionTiList; ************/ class CpuTi : public Cpu { public: - CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core); + CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, std::vector *speedPerPstate, int core); ~CpuTi() override; void setSpeedTrace(tmgr_trace_t trace) override; @@ -148,7 +148,7 @@ class CpuTiModel : public CpuModel { public: CpuTiModel(); ~CpuTiModel() override; - Cpu *createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core) override; + Cpu *createCpu(simgrid::s4u::Host *host, std::vector* speedPerPstate, int core) override; double next_occuring_event(double now) override; void updateActionsState(double now, double delta) override; diff --git a/src/surf/instr_routing.cpp b/src/surf/instr_routing.cpp index ca2809b283..92d32b3d55 100644 --- a/src/surf/instr_routing.cpp +++ b/src/surf/instr_routing.cpp @@ -265,8 +265,7 @@ void sg_instr_new_host(sg_platf_host_cbarg_t host) speed = PJ_type_variable_new ("power", nullptr, container->type); } - double current_speed_state; - xbt_dynar_get_cpy(host->speed_per_pstate, host->pstate, ¤t_speed_state); + double current_speed_state = host->speed_per_pstate->at(host->pstate); new_pajeSetVariable (0, container, speed, current_speed_state); } if (TRACE_uncategorized()){ diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 437bd9c813..be3dcaf7af 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -76,22 +76,17 @@ double HostL07Model::next_occuring_event(double /*now*/) L07Action *action; ActionList *running_actions = getRunningActionSet(); - double min = this->shareResourcesMaxMin(running_actions, - maxminSystem_, - bottleneck_solve); + double min = this->shareResourcesMaxMin(running_actions, maxminSystem_, bottleneck_solve); - for(ActionList::iterator it(running_actions->begin()), itend(running_actions->end()) - ; it != itend ; ++it) { + for(ActionList::iterator it(running_actions->begin()), itend(running_actions->end()); it != itend ; ++it) { action = static_cast(&*it); if (action->m_latency > 0) { if (min < 0) { min = action->m_latency; - XBT_DEBUG("Updating min (value) with %p (start %f): %f", action, - action->getStartTime(), min); + XBT_DEBUG("Updating min (value) with %p (start %f): %f", action, action->getStartTime(), min); } else if (action->m_latency < min) { min = action->m_latency; - XBT_DEBUG("Updating min (latency) with %p (start %f): %f", action, - action->getStartTime(), min); + XBT_DEBUG("Updating min (latency) with %p (start %f): %f", action, action->getStartTime(), min); } } } @@ -165,14 +160,13 @@ void HostL07Model::updateActionsState(double /*now*/, double delta) { } Action *HostL07Model::executeParallelTask(int host_nb, sg_host_t *host_list, - double *flops_amount, double *bytes_amount, - double rate) { + double *flops_amount, double *bytes_amount,double rate) { return new L07Action(this, host_nb, host_list, flops_amount, bytes_amount, rate); } -L07Action::L07Action(Model *model, int host_nb, sg_host_t*host_list, - double *flops_amount, double *bytes_amount, double rate) +L07Action::L07Action(Model *model, int host_nb, sg_host_t *host_list, + double *flops_amount, double *bytes_amount, double rate) : CpuAction(model, 1, 0) { int nb_link = 0; @@ -267,7 +261,7 @@ Action *NetworkL07Model::communicate(kernel::routing::NetCard *src, kernel::rout return p_hostModel->executeParallelTask(2, host_list, flops_amount, bytes_amount, rate); } -Cpu *CpuL07Model::createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core) +Cpu *CpuL07Model::createCpu(simgrid::s4u::Host *host, std::vector *speedPerPstate, int core) { return new CpuL07(this, host, speedPerPstate, core); } @@ -282,15 +276,13 @@ Link* NetworkL07Model::createLink(const char *name, double bandwidth, double lat * Resource * ************/ -CpuL07::CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core) +CpuL07::CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, std::vector *speedPerPstate, int core) : Cpu(model, host, speedPerPstate, core) { - constraint_ = lmm_constraint_new(model->getMaxminSystem(), this, xbt_dynar_get_as(speedPerPstate,0,double)); + constraint_ = lmm_constraint_new(model->getMaxminSystem(), this, speedPerPstate->front()); } -CpuL07::~CpuL07() -{ -} +CpuL07::~CpuL07()=default; LinkL07::LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props, double bandwidth, double latency, e_surf_link_sharing_policy_t policy) @@ -313,8 +305,7 @@ Action *CpuL07::execution_start(double size) host_list[0] = getHost(); flops_amount[0] = size; - return static_cast(getModel())->p_hostModel - ->executeParallelTask( 1, host_list, flops_amount, nullptr, -1); + return static_cast(getModel())->p_hostModel->executeParallelTask(1, host_list, flops_amount, nullptr, -1); } Action *CpuL07::sleep(double duration) @@ -337,13 +328,10 @@ void CpuL07::onSpeedChange() { lmm_element_t elem = nullptr; lmm_update_constraint_bound(getModel()->getMaxminSystem(), getConstraint(), speed_.peak * speed_.scale); - while ((var = lmm_get_var_from_cnst - (getModel()->getMaxminSystem(), getConstraint(), &elem))) { + 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(), - speed_.scale * speed_.peak); + lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), speed_.scale * speed_.peak); } Cpu::onSpeedChange(); @@ -453,8 +441,7 @@ void L07Action::updateBound() if (m_rate < 0) lmm_update_variable_bound(getModel()->getMaxminSystem(), getVariable(), lat_bound); else - lmm_update_variable_bound(getModel()->getMaxminSystem(), getVariable(), - std::min(m_rate, lat_bound)); + lmm_update_variable_bound(getModel()->getMaxminSystem(), getVariable(), std::min(m_rate, lat_bound)); } } diff --git a/src/surf/ptask_L07.hpp b/src/surf/ptask_L07.hpp index 5f8a8283b4..9d0422345e 100644 --- a/src/surf/ptask_L07.hpp +++ b/src/surf/ptask_L07.hpp @@ -5,11 +5,8 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include - #include - #include - #include "src/surf/HostImpl.hpp" #ifndef HOST_L07_HPP_ @@ -45,8 +42,7 @@ public: double next_occuring_event(double now) override; void updateActionsState(double now, double delta) override; Action *executeParallelTask(int host_nb, sg_host_t *host_list, - double *flops_amount, double *bytes_amount, - double rate) override; + double *flops_amount, double *bytes_amount, double rate) override; }; class CpuL07Model : public CpuModel { @@ -54,7 +50,7 @@ public: CpuL07Model(HostL07Model *hmodel,lmm_system_t sys); ~CpuL07Model(); - Cpu *createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPerPstate, int core) override; + Cpu *createCpu(simgrid::s4u::Host *host, std::vector *speedPerPstate, int core) override; HostL07Model *p_hostModel; }; @@ -78,7 +74,7 @@ public: class CpuL07 : public Cpu { public: - CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedList, int core); + CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, std::vector * speedPerPstate, int core); ~CpuL07(); bool isUsed() override; void apply_event(tmgr_trace_iterator_t event, double value) override; @@ -105,17 +101,10 @@ public: class L07Action : public CpuAction { friend Action *CpuL07::execution_start(double size); friend Action *CpuL07::sleep(double duration); - friend Action *HostL07Model::executeParallelTask(int host_nb, - sg_host_t*host_list, - double *flops_amount, - double *bytes_amount, - double rate); + friend Action *HostL07Model::executeParallelTask(int host_nb, sg_host_t*host_list, + double *flops_amount, double *bytes_amount, double rate); public: - L07Action(Model *model, int host_nb, - sg_host_t*host_list, - double *flops_amount, - double *bytes_amount, - double rate); + L07Action(Model *model, int host_nb, sg_host_t *host_list, double *flops_amount, double *bytes_amount, double rate); ~L07Action(); void updateBound(); diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index f51d08f359..9e3d11b939 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -301,13 +301,13 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster) } } - host.speed_per_pstate = xbt_dynar_new(sizeof(double), nullptr); - xbt_dynar_push(host.speed_per_pstate,&cluster->speed); + host.speed_per_pstate = new std::vector(); + host.speed_per_pstate->push_back(cluster->speed); host.pstate = 0; host.core_amount = cluster->core_amount; host.coord = ""; sg_platf_new_host(&host); - xbt_dynar_free(&host.speed_per_pstate); + // delete host.speed_per_pstate; XBT_DEBUG(""); XBT_DEBUG("", link_id, cluster->bw, cluster->lat); @@ -422,10 +422,10 @@ void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet) host.pstate = 0; host.core_amount = 1; host.id = hostname; - host.speed_per_pstate = xbt_dynar_new(sizeof(double), nullptr); - xbt_dynar_push(host.speed_per_pstate,&cabinet->speed); + host.speed_per_pstate = new std::vector(); + host.speed_per_pstate->push_back(cabinet->speed); sg_platf_new_host(&host); - xbt_dynar_free(&host.speed_per_pstate); + delete host.speed_per_pstate; s_sg_platf_link_cbarg_t link; memset(&link, 0, sizeof(link)); @@ -667,14 +667,14 @@ void sg_platf_new_peer(sg_platf_peer_cbarg_t peer) memset(&host, 0, sizeof(host)); host.id = host_id; - host.speed_per_pstate = xbt_dynar_new(sizeof(double), nullptr); - xbt_dynar_push(host.speed_per_pstate,&peer->speed); + host.speed_per_pstate = new std::vector(); + host.speed_per_pstate->push_back(peer->speed); host.pstate = 0; host.speed_trace = peer->availability_trace; host.state_trace = peer->state_trace; host.core_amount = 1; sg_platf_new_host(&host); - xbt_dynar_free(&host.speed_per_pstate); + delete host.speed_per_pstate; s_sg_platf_link_cbarg_t link; memset(&link, 0, sizeof(link)); diff --git a/src/surf/xml/platf_private.hpp b/src/surf/xml/platf_private.hpp index 84ee316fd4..0a5d3ebfb8 100644 --- a/src/surf/xml/platf_private.hpp +++ b/src/surf/xml/platf_private.hpp @@ -42,7 +42,7 @@ typedef enum { typedef struct { const char* id; - xbt_dynar_t speed_per_pstate; + std::vector *speed_per_pstate; int pstate; int core_amount; tmgr_trace_t speed_trace; diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index 9b2af1b727..e81955b2c4 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -456,10 +456,10 @@ void ETag_surfxml_host() { buf = A_surfxml_host_speed; XBT_DEBUG("Buffer: %s", buf); - host.speed_per_pstate = xbt_dynar_new(sizeof(double), nullptr); + host.speed_per_pstate = new std::vector(); if (strchr(buf, ',') == nullptr){ double speed = surf_parse_get_speed(A_surfxml_host_speed,"speed of host", host.id); - xbt_dynar_push_as(host.speed_per_pstate,double, speed); + host.speed_per_pstate->push_back(speed); } else { xbt_dynar_t pstate_list = xbt_str_split(buf, ","); @@ -468,7 +468,7 @@ void ETag_surfxml_host() { xbt_dynar_foreach(pstate_list, i, speed_str) { xbt_str_trim(speed_str, nullptr); double speed = surf_parse_get_speed(speed_str,"speed of host", host.id); - xbt_dynar_push_as(host.speed_per_pstate, double, speed); + host.speed_per_pstate->push_back(speed); XBT_DEBUG("Speed value: %f", speed); } xbt_dynar_free(&pstate_list); @@ -482,7 +482,7 @@ void ETag_surfxml_host() { host.coord = A_surfxml_host_coordinates; sg_platf_new_host(&host); - xbt_dynar_free(&host.speed_per_pstate); + delete host.speed_per_pstate; current_property_set = nullptr; } -- 2.20.1