From a2444896cc5969f2b9150b035f9ea0744e74789d Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 26 Mar 2016 11:26:15 +0100 Subject: [PATCH] rename the fields of surf::Action --- src/surf/cpu_cas01.cpp | 12 +-- src/surf/cpu_interface.cpp | 16 ++-- src/surf/cpu_ti.cpp | 24 +++--- src/surf/network_cm02.cpp | 38 +++++----- src/surf/network_constant.cpp | 19 ++++- src/surf/network_constant.hpp | 12 +-- src/surf/network_ns3.cpp | 6 +- src/surf/ptask_L07.cpp | 14 ++-- src/surf/storage_n11.cpp | 14 ++-- src/surf/surf_interface.cpp | 134 +++++++++++++++++----------------- src/surf/surf_interface.hpp | 68 ++++++++--------- 11 files changed, 179 insertions(+), 178 deletions(-) diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index d48972e75f..fb91f38ab5 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -200,13 +200,13 @@ CpuAction *CpuCas01::sleep(double duration) speed_.scale * speed_.peak, getConstraint()); // FIXME: sleep variables should not consume 1.0 in lmm_expand - action->m_maxDuration = duration; - action->m_suspended = 2; + 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 */ action->getStateSet()->erase(action->getStateSet()->iterator_to(*action)); - action->p_stateSet = static_cast(getModel())->p_cpuRunningActionSetThatDoesNotNeedBeingChecked; + action->stateSet_ = static_cast(getModel())->p_cpuRunningActionSetThatDoesNotNeedBeingChecked; action->getStateSet()->push_back(*action); } @@ -234,9 +234,9 @@ CpuCas01Action::CpuCas01Action(Model *model, double cost, bool failed, double sp 1.0, speed, 1)) { if (model->getUpdateMechanism() == UM_LAZY) { - m_indexHeap = -1; - m_lastUpdate = surf_get_clock(); - m_lastValue = 0.0; + indexHeap_ = -1; + lastUpdate_ = surf_get_clock(); + lastValue_ = 0.0; } lmm_expand(model->getMaxminSystem(), constraint, getVariable(), 1.0); } diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index cb9e788417..ee3fc09929 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -249,21 +249,21 @@ void CpuAction::updateRemainingLazy(double now) xbt_assert(getStateSet() == getModel()->getRunningActionSet(), "You're updating an action that is not running."); xbt_assert(getPriority() > 0, "You're updating an action that seems suspended."); - double delta = now - m_lastUpdate; + double delta = now - lastUpdate_; - if (m_remains > 0) { - XBT_CDEBUG(surf_kernel, "Updating action(%p): remains was %f, last_update was: %f", this, m_remains, m_lastUpdate); - double_update(&(m_remains), m_lastValue * delta, sg_maxmin_precision*sg_surf_precision); + if (remains_ > 0) { + XBT_CDEBUG(surf_kernel, "Updating action(%p): remains was %f, last_update was: %f", this, remains_, lastUpdate_); + double_update(&(remains_), lastValue_ * delta, sg_maxmin_precision*sg_surf_precision); if (TRACE_is_enabled()) { Cpu *cpu = static_cast(lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0))); - TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), m_lastValue, m_lastUpdate, now - m_lastUpdate); + TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), lastValue_, lastUpdate_, now - lastUpdate_); } - XBT_CDEBUG(surf_kernel, "Updating action(%p): remains is now %f", this, m_remains); + XBT_CDEBUG(surf_kernel, "Updating action(%p): remains is now %f", this, remains_); } - m_lastUpdate = now; - m_lastValue = lmm_variable_getvalue(getVariable()); + lastUpdate_ = now; + lastValue_ = lmm_variable_getvalue(getVariable()); } /* diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 4e7b6e61d5..8e89a04bd6 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -600,10 +600,10 @@ void CpuTi::updateActionsFinishTime(double now) 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) + action->getStartTime() + action->getMaxDuration() < action->finishTime_) min_finish = action->getStartTime() + action->getMaxDuration(); else - min_finish = action->m_finish; + min_finish = action->finishTime_; } else { /* put the max duration time on heap */ if (action->getMaxDuration() != NO_MAX_DURATION) @@ -623,7 +623,7 @@ void CpuTi::updateActionsFinishTime(double now) XBT_DEBUG ("Update finish time: Cpu(%s) Action: %p, Start Time: %f Finish Time: %f Max duration %f", getName(), action, action->getStartTime(), - action->m_finish, + action->finishTime_, action->getMaxDuration()); } /* remove from modified cpu */ @@ -672,12 +672,12 @@ void CpuTi::updateRemainingAmount(double now) continue; /* skip action that are finishing now */ - if (action->m_finish >= 0 && action->m_finish <= now) + if (action->finishTime_ >= 0 && action->finishTime_ <= now) continue; /* update remaining */ action->updateRemains(area_total / (sumPriority_ * action->getPriority())); - XBT_DEBUG("Update remaining action(%p) remaining %f", action, action->m_remains); + XBT_DEBUG("Update remaining action(%p) remaining %f", action, action->remains_); } lastUpdate_ = now; } @@ -702,13 +702,13 @@ CpuAction *CpuTi::sleep(double duration) XBT_IN("(%s,%g)", getName(), duration); CpuTiAction *action = new CpuTiAction(static_cast(getModel()), 1.0, isOff(), this); - action->m_maxDuration = duration; + 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 */ action->getStateSet()->erase(action->getStateSet()->iterator_to(*action)); - action->p_stateSet = static_cast(getModel())->runningActionSetThatDoesNotNeedBeingChecked_; + action->stateSet_ = static_cast(getModel())->runningActionSetThatDoesNotNeedBeingChecked_; action->getStateSet()->push_back(*action); } @@ -756,8 +756,8 @@ void CpuTiAction::setState(Action::State state) int CpuTiAction::unref() { - m_refcount--; - if (!m_refcount) { + refcount_--; + if (!refcount_) { if (action_hook.is_linked()) getStateSet()->erase(getStateSet()->iterator_to(*this)); /* remove from action_set */ @@ -807,7 +807,7 @@ void CpuTiAction::setMaxDuration(double duration) XBT_IN("(%p,%g)", this, duration); - m_maxDuration = duration; + maxDuration_ = duration; if (duration >= 0) min_finish = (getStartTime() + getMaxDuration()) < getFinishTime() ? @@ -830,7 +830,7 @@ void CpuTiAction::setMaxDuration(double duration) void CpuTiAction::setPriority(double priority) { XBT_IN("(%p,%g)", this, priority); - m_priority = priority; + priority_ = priority; cpu_->modified(true); XBT_OUT(); } @@ -840,7 +840,7 @@ double CpuTiAction::getRemains() XBT_IN("(%p)", this); cpu_->updateRemainingAmount(surf_get_clock()); XBT_OUT(); - return m_remains; + return remains_; } } diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 37d0970afe..ff819ffe7f 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -325,8 +325,8 @@ Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst, double size, d action->rate_ = rate; if (updateMechanism_ == UM_LAZY) { - action->m_indexHeap = -1; - action->m_lastUpdate = surf_get_clock(); + action->indexHeap_ = -1; + action->lastUpdate_ = surf_get_clock(); } bandwidth_bound = -1.0; @@ -355,14 +355,14 @@ Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst, double size, d constraints_per_variable += back_route->size(); if (action->latency_ > 0) { - action->p_variable = lmm_variable_new(maxminSystem_, action, 0.0, -1.0, constraints_per_variable); + action->variable_ = lmm_variable_new(maxminSystem_, action, 0.0, -1.0, constraints_per_variable); if (updateMechanism_ == UM_LAZY) { // add to the heap the event when the latency is payed - XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->latency_ + action->m_lastUpdate); - action->heapInsert(actionHeap_, action->latency_ + action->m_lastUpdate, route->empty() ? NORMAL : LATENCY); + XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->latency_ + action->lastUpdate_); + action->heapInsert(actionHeap_, action->latency_ + action->lastUpdate_, route->empty() ? NORMAL : LATENCY); } } else - action->p_variable = lmm_variable_new(maxminSystem_, action, 1.0, -1.0, constraints_per_variable); + action->variable_ = lmm_variable_new(maxminSystem_, action, 1.0, -1.0, constraints_per_variable); if (action->rate_ < 0) { lmm_update_variable_bound(maxminSystem_, action->getVariable(), (action->latCurrent_ > 0) ? sg_tcp_gamma / (2.0 * action->latCurrent_) : -1.0); @@ -514,36 +514,36 @@ void NetworkCm02Action::updateRemainingLazy(double now) { double delta = 0.0; - if (m_suspended != 0) + if (suspended_ != 0) return; - delta = now - m_lastUpdate; + delta = now - lastUpdate_; - if (m_remains > 0) { - XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, m_remains, m_lastUpdate); - double_update(&(m_remains), m_lastValue * delta, sg_maxmin_precision*sg_surf_precision); + if (remains_ > 0) { + XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, remains_, lastUpdate_); + double_update(&(remains_), lastValue_ * delta, sg_maxmin_precision*sg_surf_precision); - XBT_DEBUG("Updating action(%p): remains is now %f", this, m_remains); + XBT_DEBUG("Updating action(%p): remains is now %f", this, remains_); } - if (m_maxDuration != NO_MAX_DURATION) - double_update(&m_maxDuration, delta, sg_surf_precision); + if (maxDuration_ != NO_MAX_DURATION) + double_update(&maxDuration_, delta, sg_surf_precision); - if (m_remains <= 0 && + if (remains_ <= 0 && (lmm_get_variable_weight(getVariable()) > 0)) { finish(); setState(Action::State::done); heapRemove(getModel()->getActionHeap()); - } else if (((m_maxDuration != NO_MAX_DURATION) - && (m_maxDuration <= 0))) { + } else if (((maxDuration_ != NO_MAX_DURATION) + && (maxDuration_ <= 0))) { finish(); setState(Action::State::done); heapRemove(getModel()->getActionHeap()); } - m_lastUpdate = now; - m_lastValue = lmm_variable_getvalue(getVariable()); + lastUpdate_ = now; + lastValue_ = lmm_variable_getvalue(getVariable()); } } diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index fe3356da4f..62f97f3f0a 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -30,6 +30,7 @@ namespace simgrid { xbt_die("Refusing to create the link %s: there is no link in the Constant network model. " "Please remove any link from your platform (and switch to routing='None')", name); + return nullptr; } double NetworkConstantModel::next_occuring_event(double /*now*/) @@ -89,13 +90,24 @@ namespace simgrid { /********** * Action * **********/ + NetworkConstantAction::NetworkConstantAction(NetworkConstantModel *model_, double size, double latency) + : NetworkAction(model_, size, false) + , m_latInit(latency) + { + latency_ = latency; + if (latency_ <= 0.0) { + stateSet_ = getModel()->getDoneActionSet(); + stateSet_->push_back(*this); + } + variable_ = NULL; + }; int NetworkConstantAction::unref() { - m_refcount--; - if (!m_refcount) { + refcount_--; + if (!refcount_) { if (action_hook.is_linked()) - p_stateSet->erase(p_stateSet->iterator_to(*this)); + stateSet_->erase(stateSet_->iterator_to(*this)); delete this; return 1; } @@ -104,7 +116,6 @@ namespace simgrid { void NetworkConstantAction::cancel() { - return; } } diff --git a/src/surf/network_constant.hpp b/src/surf/network_constant.hpp index 214993de62..ce4160634a 100644 --- a/src/surf/network_constant.hpp +++ b/src/surf/network_constant.hpp @@ -42,17 +42,7 @@ namespace simgrid { **********/ class NetworkConstantAction : public NetworkAction { public: - NetworkConstantAction(NetworkConstantModel *model_, double size, double latency) - : NetworkAction(model_, size, false) - , m_latInit(latency) - { - latency_ = latency; - if (latency_ <= 0.0) { - p_stateSet = getModel()->getDoneActionSet(); - p_stateSet->push_back(*this); - } - p_variable = NULL; - }; + NetworkConstantAction(NetworkConstantModel *model_, double size, double latency); int unref() override; void cancel() override; double m_latInit; diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index ceb4afc415..0375f647bc 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -387,10 +387,10 @@ bool NetworkNS3Action::isSuspended() int NetworkNS3Action::unref() { - m_refcount--; - if (!m_refcount) { + refcount_--; + if (!refcount_) { if (action_hook.is_linked()) - p_stateSet->erase(p_stateSet->iterator_to(*this)); + stateSet_->erase(stateSet_->iterator_to(*this)); XBT_DEBUG ("Removing action %p", this); delete this; return 1; diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index e875896e66..f4b4179eb0 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -222,7 +222,7 @@ L07Action::L07Action(Model *model, int host_nb, sg_host_t*host_list, this->m_latency = latency; this->m_rate = rate; - this->p_variable = lmm_variable_new(model->getMaxminSystem(), this, 1.0, + this->variable_ = lmm_variable_new(model->getMaxminSystem(), this, 1.0, (rate > 0 ? rate : -1.0), host_nb + nb_link); @@ -324,8 +324,8 @@ Action *CpuL07::execution_start(double size) Action *CpuL07::sleep(double duration) { L07Action *action = static_cast(execution_start(1.0)); - action->m_maxDuration = duration; - action->m_suspended = 2; + action->maxDuration_ = duration; + action->suspended_ = 2; lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), 0.0); return action; @@ -453,7 +453,7 @@ void L07Action::updateBound() } lat_bound = sg_tcp_gamma / (2.0 * lat_current); XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound); - if ((m_latency == 0.0) && (m_suspended == 0)) { + if ((m_latency == 0.0) && (suspended_ == 0)) { if (m_rate < 0) lmm_update_variable_bound(getModel()->getMaxminSystem(), getVariable(), lat_bound); else @@ -464,10 +464,10 @@ void L07Action::updateBound() int L07Action::unref() { - m_refcount--; - if (!m_refcount) { + refcount_--; + if (!refcount_) { if (action_hook.is_linked()) - p_stateSet->erase(p_stateSet->iterator_to(*this)); + stateSet_->erase(stateSet_->iterator_to(*this)); if (getVariable()) lmm_variable_free(getModel()->getMaxminSystem(), getVariable()); delete this; diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 81308c10d7..4ee6967951 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -69,7 +69,7 @@ StorageN11Model::StorageN11Model() : StorageModel() { XBT_DEBUG("surf_storage_model_init_internal"); storage_running_action_set_that_does_not_need_being_checked = - xbt_swag_new(xbt_swag_offset(*action, p_stateHookup)); + xbt_swag_new(xbt_swag_offset(*action, stateHookup_)); if (!maxminSystem_) { maxminSystem_ = lmm_system_new(storage_selective_update); } @@ -350,10 +350,10 @@ StorageN11Action::StorageN11Action(Model *model, double cost, bool failed, Stora int StorageN11Action::unref() { - m_refcount--; - if (!m_refcount) { + refcount_--; + if (!refcount_) { if (action_hook.is_linked()) - p_stateSet->erase(p_stateSet->iterator_to(*this)); + stateSet_->erase(stateSet_->iterator_to(*this)); if (getVariable()) lmm_variable_free(getModel()->getMaxminSystem(), getVariable()); xbt_free(getCategory()); @@ -372,9 +372,9 @@ void StorageN11Action::cancel() void StorageN11Action::suspend() { XBT_IN("(%p)", this); - if (m_suspended != 2) { + if (suspended_ != 2) { lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), 0.0); - m_suspended = 1; + suspended_ = 1; } XBT_OUT(); } @@ -386,7 +386,7 @@ void StorageN11Action::resume() bool StorageN11Action::isSuspended() { - return m_suspended == 1; + return suspended_ == 1; } void StorageN11Action::setMaxDuration(double /*duration*/) diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index b5c3a805fe..05b3c8bb13 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -632,17 +632,17 @@ namespace surf { void Action::initialize(simgrid::surf::Model *model, double cost, bool failed, lmm_variable_t var) { - m_remains = cost; - m_start = surf_get_clock(); - m_cost = cost; - p_model = model; - p_variable = var; + remains_ = cost; + start_ = surf_get_clock(); + cost_ = cost; + model_ = model; + variable_ = var; if (failed) - p_stateSet = getModel()->getFailedActionSet(); + stateSet_ = getModel()->getFailedActionSet(); else - p_stateSet = getModel()->getRunningActionSet(); + stateSet_ = getModel()->getRunningActionSet(); - p_stateSet->push_back(*this); + stateSet_->push_back(*this); } Action::Action(simgrid::surf::Model *model, double cost, bool failed) @@ -656,60 +656,60 @@ Action::Action(simgrid::surf::Model *model, double cost, bool failed, lmm_variab } Action::~Action() { - xbt_free(p_category); + xbt_free(category_); } void Action::finish() { - m_finish = surf_get_clock(); + finishTime_ = surf_get_clock(); } Action::State Action::getState() { - if (p_stateSet == getModel()->getReadyActionSet()) + if (stateSet_ == getModel()->getReadyActionSet()) return Action::State::ready; - if (p_stateSet == getModel()->getRunningActionSet()) + if (stateSet_ == getModel()->getRunningActionSet()) return Action::State::running; - if (p_stateSet == getModel()->getFailedActionSet()) + if (stateSet_ == getModel()->getFailedActionSet()) return Action::State::failed; - if (p_stateSet == getModel()->getDoneActionSet()) + if (stateSet_ == getModel()->getDoneActionSet()) return Action::State::done; return Action::State::not_in_the_system; } void Action::setState(Action::State state) { - p_stateSet->erase(p_stateSet->iterator_to(*this)); + stateSet_->erase(stateSet_->iterator_to(*this)); switch (state) { case Action::State::ready: - p_stateSet = getModel()->getReadyActionSet(); + stateSet_ = getModel()->getReadyActionSet(); break; case Action::State::running: - p_stateSet = getModel()->getRunningActionSet(); + stateSet_ = getModel()->getRunningActionSet(); break; case Action::State::failed: - p_stateSet = getModel()->getFailedActionSet(); + stateSet_ = getModel()->getFailedActionSet(); break; case Action::State::done: - p_stateSet = getModel()->getDoneActionSet(); + stateSet_ = getModel()->getDoneActionSet(); break; default: - p_stateSet = NULL; + stateSet_ = NULL; break; } - if (p_stateSet) - p_stateSet->push_back(*this); + if (stateSet_) + stateSet_->push_back(*this); } double Action::getBound() { - return (p_variable) ? lmm_variable_getbound(p_variable) : 0; + return (variable_) ? lmm_variable_getbound(variable_) : 0; } void Action::setBound(double bound) { XBT_IN("(%p,%g)", this, bound); - if (p_variable) - lmm_update_variable_bound(getModel()->getMaxminSystem(), p_variable, bound); + if (variable_) + lmm_update_variable_bound(getModel()->getMaxminSystem(), variable_, bound); if (getModel()->getUpdateMechanism() == UM_LAZY && getLastUpdate()!=surf_get_clock()) heapRemove(getModel()->getActionHeap()); @@ -718,35 +718,35 @@ void Action::setBound(double bound) double Action::getStartTime() { - return m_start; + return start_; } double Action::getFinishTime() { /* keep the function behavior, some models (cpu_ti) change the finish time before the action end */ - return m_remains == 0 ? m_finish : -1; + return remains_ == 0 ? finishTime_ : -1; } void Action::setData(void* data) { - p_data = data; + data_ = data; } void Action::setCategory(const char *category) { XBT_IN("(%p,%s)", this, category); - p_category = xbt_strdup(category); + category_ = xbt_strdup(category); XBT_OUT(); } void Action::ref(){ - m_refcount++; + refcount_++; } void Action::setMaxDuration(double duration) { XBT_IN("(%p,%g)", this, duration); - m_maxDuration = duration; + maxDuration_ = duration; if (getModel()->getUpdateMechanism() == UM_LAZY) // remove action from the heap heapRemove(getModel()->getActionHeap()); XBT_OUT(); @@ -757,7 +757,7 @@ void Action::gapRemove() {} void Action::setPriority(double priority) { XBT_IN("(%p,%g)", this, priority); - m_priority = priority; + priority_ = priority; lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), priority); if (getModel()->getUpdateMechanism() == UM_LAZY) @@ -775,10 +775,10 @@ void Action::cancel(){ } int Action::unref(){ - m_refcount--; - if (!m_refcount) { + refcount_--; + if (!refcount_) { if (action_hook.is_linked()) - p_stateSet->erase(p_stateSet->iterator_to(*this)); + stateSet_->erase(stateSet_->iterator_to(*this)); if (getVariable()) lmm_variable_free(getModel()->getMaxminSystem(), getVariable()); if (getModel()->getUpdateMechanism() == UM_LAZY) { @@ -796,9 +796,9 @@ int Action::unref(){ void Action::suspend() { XBT_IN("(%p)", this); - if (m_suspended != 2) { + if (suspended_ != 2) { lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), 0.0); - m_suspended = 1; + suspended_ = 1; if (getModel()->getUpdateMechanism() == UM_LAZY) heapRemove(getModel()->getActionHeap()); } @@ -808,9 +808,9 @@ void Action::suspend() void Action::resume() { XBT_IN("(%p)", this); - if (m_suspended != 2) { - lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), m_priority); - m_suspended = 0; + if (suspended_ != 2) { + lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), priority_); + suspended_ = 0; if (getModel()->getUpdateMechanism() == UM_LAZY) heapRemove(getModel()->getActionHeap()); } @@ -819,7 +819,7 @@ void Action::resume() bool Action::isSuspended() { - return m_suspended == 1; + return suspended_ == 1; } /* insert action on heap using a given key and a hat (heap_action_type) * a hat can be of three types for communications: @@ -830,30 +830,30 @@ bool Action::isSuspended() */ void Action::heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat) { - m_hat = hat; + hat_ = hat; xbt_heap_push(heap, this, key); } void Action::heapRemove(xbt_heap_t heap) { - m_hat = NOTSET; - if (m_indexHeap >= 0) { - xbt_heap_remove(heap, m_indexHeap); + hat_ = NOTSET; + if (indexHeap_ >= 0) { + xbt_heap_remove(heap, indexHeap_); } } void Action::heapUpdate(xbt_heap_t heap, double key, enum heap_action_type hat) { - m_hat = hat; - if (m_indexHeap >= 0) { - xbt_heap_update(heap, m_indexHeap, key); + hat_ = hat; + if (indexHeap_ >= 0) { + xbt_heap_update(heap, indexHeap_, key); }else{ xbt_heap_push(heap, this, key); } } void Action::updateIndexHeap(int i) { - m_indexHeap = i; + indexHeap_ = i; } double Action::getRemains() @@ -863,12 +863,12 @@ double Action::getRemains() if (getModel()->getUpdateMechanism() == UM_LAZY) /* update remains before return it */ updateRemainingLazy(surf_get_clock()); XBT_OUT(); - return m_remains; + return remains_; } double Action::getRemainsNoUpdate() { - return m_remains; + return remains_; } //FIXME split code in the right places @@ -878,54 +878,54 @@ void Action::updateRemainingLazy(double now) if(getModel() == surf_network_model) { - if (m_suspended != 0) + if (suspended_ != 0) return; } else { - xbt_assert(p_stateSet == getModel()->getRunningActionSet(), + xbt_assert(stateSet_ == getModel()->getRunningActionSet(), "You're updating an action that is not running."); /* bogus priority, skip it */ - xbt_assert(m_priority > 0, + xbt_assert(priority_ > 0, "You're updating an action that seems suspended."); } - delta = now - m_lastUpdate; + delta = now - lastUpdate_; - if (m_remains > 0) { - XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, m_remains, m_lastUpdate); - double_update(&m_remains, m_lastValue * delta, sg_surf_precision*sg_maxmin_precision); + if (remains_ > 0) { + XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, remains_, lastUpdate_); + double_update(&remains_, lastValue_ * delta, sg_surf_precision*sg_maxmin_precision); if (getModel() == surf_cpu_model_pm && TRACE_is_enabled()) { simgrid::surf::Resource *cpu = static_cast( lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0))); - TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), m_lastValue, m_lastUpdate, now - m_lastUpdate); + TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), lastValue_, lastUpdate_, now - lastUpdate_); } - XBT_DEBUG("Updating action(%p): remains is now %f", this, m_remains); + XBT_DEBUG("Updating action(%p): remains is now %f", this, remains_); } if(getModel() == surf_network_model) { - if (m_maxDuration != NO_MAX_DURATION) - double_update(&m_maxDuration, delta, sg_surf_precision); + if (maxDuration_ != NO_MAX_DURATION) + double_update(&maxDuration_, delta, sg_surf_precision); //FIXME: duplicated code - if ((m_remains <= 0) && + if ((remains_ <= 0) && (lmm_get_variable_weight(getVariable()) > 0)) { finish(); setState(Action::State::done); heapRemove(getModel()->getActionHeap()); - } else if (((m_maxDuration != NO_MAX_DURATION) - && (m_maxDuration <= 0))) { + } else if (((maxDuration_ != NO_MAX_DURATION) + && (maxDuration_ <= 0))) { finish(); setState(Action::State::done); heapRemove(getModel()->getActionHeap()); } } - m_lastUpdate = now; - m_lastValue = lmm_variable_getvalue(getVariable()); + lastUpdate_ = now; + lastValue_ = lmm_variable_getvalue(getVariable()); } } diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 66ed71dd84..7b13c6cd55 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -156,32 +156,32 @@ public: double getFinishTime(); /** @brief Get the user data associated to the current action */ - void *getData() {return p_data;} + void *getData() {return data_;} /** @brief Set the user data associated to the current action */ void setData(void* data); /** @brief Get the cost of the current action */ - double getCost() {return m_cost;} + double getCost() {return cost_;} /** @brief Set the cost of the current action */ - void setCost(double cost) {m_cost = cost;} + void setCost(double cost) {cost_ = cost;} /** @brief Update the maximum duration of the current action * @param delta Amount to remove from the MaxDuration */ - void updateMaxDuration(double delta) {double_update(&m_maxDuration, delta,sg_surf_precision);} + void updateMaxDuration(double delta) {double_update(&maxDuration_, delta,sg_surf_precision);} /** @brief Update the remaining time of the current action * @param delta Amount to remove from the remaining time */ - void updateRemains(double delta) {double_update(&m_remains, delta, sg_maxmin_precision*sg_surf_precision);} + void updateRemains(double delta) {double_update(&remains_, delta, sg_maxmin_precision*sg_surf_precision);} /** @brief Set the remaining time of the current action */ - void setRemains(double value) {m_remains = value;} + void setRemains(double value) {remains_ = value;} /** @brief Get the remaining time of the current action after updating the resource */ virtual double getRemains(); /** @brief Get the remaining time of the current action without updating the resource */ double getRemainsNoUpdate(); /** @brief Set the finish time of the current action */ - void setFinishTime(double value) {m_finish = value;} + void setFinishTime(double value) {finishTime_ = value;} /**@brief Add a reference to the current action (refcounting) */ void ref(); @@ -203,42 +203,42 @@ public: virtual bool isSuspended(); /** @brief Get the maximum duration of the current action */ - double getMaxDuration() {return m_maxDuration;} + double getMaxDuration() {return maxDuration_;} /** @brief Set the maximum duration of the current Action */ virtual void setMaxDuration(double duration); /** @brief Get the tracing category associated to the current action */ - char *getCategory() {return p_category;} + char *getCategory() {return category_;} /** @brief Set the tracing category of the current Action */ void setCategory(const char *category); /** @brief Get the priority of the current Action */ - double getPriority() {return m_priority;}; + double getPriority() {return priority_;}; /** @brief Set the priority of the current Action */ virtual void setPriority(double priority); /** @brief Get the state set in which the action is */ - ActionList* getStateSet() {return p_stateSet;}; + ActionList* getStateSet() {return stateSet_;}; - s_xbt_swag_hookup_t p_stateHookup = {NULL,NULL}; + s_xbt_swag_hookup_t stateHookup_ = {NULL,NULL}; - simgrid::surf::Model *getModel() {return p_model;} + simgrid::surf::Model *getModel() {return model_;} protected: - ActionList* p_stateSet; - double m_priority = 1.0; /**< priority (1.0 by default) */ - int m_refcount = 1; - double m_remains; /**< How much of that cost remains to be done in the currently running task */ - double m_maxDuration = NO_MAX_DURATION; /*< max_duration (may fluctuate until the task is completed) */ - double m_finish = -1; /**< finish time : this is modified during the run and fluctuates until the task is completed */ + ActionList* stateSet_; + double priority_ = 1.0; /**< priority (1.0 by default) */ + int refcount_ = 1; + double remains_; /**< How much of that cost remains to be done in the currently running task */ + double maxDuration_ = NO_MAX_DURATION; /*< max_duration (may fluctuate until the task is completed) */ + double finishTime_ = -1; /**< finish time : this is modified during the run and fluctuates until the task is completed */ private: - double m_start; /**< start time */ - char *p_category = NULL; /**< tracing category for categorized resource utilization monitoring */ + double start_; /**< start time */ + char *category_ = NULL; /**< tracing category for categorized resource utilization monitoring */ - double m_cost; - simgrid::surf::Model *p_model; - void *p_data = NULL; /**< for your convenience */ + double cost_; + simgrid::surf::Model *model_; + void *data_ = NULL; /**< for your convenience */ /* LMM */ public: @@ -247,20 +247,20 @@ public: void heapRemove(xbt_heap_t heap); void heapUpdate(xbt_heap_t heap, double key, enum heap_action_type hat); void updateIndexHeap(int i); - lmm_variable_t getVariable() {return p_variable;} - double getLastUpdate() {return m_lastUpdate;} - void refreshLastUpdate() {m_lastUpdate = surf_get_clock();} - enum heap_action_type getHat() {return m_hat;} + lmm_variable_t getVariable() {return variable_;} + double getLastUpdate() {return lastUpdate_;} + void refreshLastUpdate() {lastUpdate_ = surf_get_clock();} + enum heap_action_type getHat() {return hat_;} bool is_linked() {return action_lmm_hook.is_linked();} void gapRemove(); protected: - lmm_variable_t p_variable; - double m_lastValue = 0; - double m_lastUpdate = 0; - int m_suspended = 0; - int m_indexHeap; - enum heap_action_type m_hat = NOTSET; + lmm_variable_t variable_; + double lastValue_ = 0; + double lastUpdate_ = 0; + int suspended_ = 0; + int indexHeap_; + enum heap_action_type hat_ = NOTSET; }; typedef Action::ActionList ActionList; -- 2.20.1