From 1aaf3e3fc120f9434c692f1c49d03a00b24e55a1 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 26 Mar 2018 20:53:19 +0200 Subject: [PATCH] these functions always take exactly the same parameter, thus inlining it --- include/simgrid/kernel/resource/Action.hpp | 6 ++--- src/kernel/resource/Action.cpp | 28 +++++++++++----------- src/kernel/resource/Model.cpp | 2 +- src/surf/cpu_cas01.cpp | 2 +- src/surf/cpu_ti.cpp | 14 +++++------ src/surf/network_cm02.cpp | 12 +++++----- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/include/simgrid/kernel/resource/Action.hpp b/include/simgrid/kernel/resource/Action.hpp index 141df6402d..4961cef1d9 100644 --- a/include/simgrid/kernel/resource/Action.hpp +++ b/include/simgrid/kernel/resource/Action.hpp @@ -193,9 +193,9 @@ private: boost::optional heap_hook_ = boost::none; public: - void heapInsert(heap_type& heap, double key, Action::Type hat); - void heapRemove(heap_type& heap); - void heapUpdate(heap_type& heap, double key, Action::Type hat); + void heapInsert(double key, Action::Type hat); + void heapRemove(); + void heapUpdate(double key, Action::Type hat); void clearHeapHandle() { heap_hook_ = boost::none; } lmm::Variable* get_variable() const { return variable_; } diff --git a/src/kernel/resource/Action.cpp b/src/kernel/resource/Action.cpp index 919e06e54d..52a857cf3e 100644 --- a/src/kernel/resource/Action.cpp +++ b/src/kernel/resource/Action.cpp @@ -38,7 +38,7 @@ Action::~Action() get_model()->getMaxminSystem()->variable_free(get_variable()); if (get_model()->getUpdateMechanism() == UM_LAZY) { /* remove from heap */ - heapRemove(get_model()->getActionHeap()); + heapRemove(); if (modified_set_hook_.is_linked()) simgrid::xbt::intrusive_erase(*get_model()->getModifiedSet(), *this); } @@ -102,7 +102,7 @@ void Action::set_bound(double bound) get_model()->getMaxminSystem()->update_variable_bound(variable_, bound); if (get_model()->getUpdateMechanism() == UM_LAZY && get_last_update() != surf_get_clock()) - heapRemove(get_model()->getActionHeap()); + heapRemove(); XBT_OUT(); } @@ -120,7 +120,7 @@ void Action::set_max_duration(double duration) { max_duration_ = duration; if (get_model()->getUpdateMechanism() == UM_LAZY) // remove action from the heap - heapRemove(get_model()->getActionHeap()); + heapRemove(); } void Action::set_priority(double weight) @@ -130,7 +130,7 @@ void Action::set_priority(double weight) get_model()->getMaxminSystem()->update_variable_weight(get_variable(), weight); if (get_model()->getUpdateMechanism() == UM_LAZY) - heapRemove(get_model()->getActionHeap()); + heapRemove(); XBT_OUT(); } @@ -140,7 +140,7 @@ void Action::cancel() if (get_model()->getUpdateMechanism() == UM_LAZY) { if (modified_set_hook_.is_linked()) simgrid::xbt::intrusive_erase(*get_model()->getModifiedSet(), *this); - heapRemove(get_model()->getActionHeap()); + heapRemove(); } } @@ -160,7 +160,7 @@ void Action::suspend() if (suspended_ != SuspendStates::sleeping) { get_model()->getMaxminSystem()->update_variable_weight(get_variable(), 0.0); if (get_model()->getUpdateMechanism() == UM_LAZY) { - heapRemove(get_model()->getActionHeap()); + heapRemove(); if (state_set_ == get_model()->getRunningActionSet() && sharing_priority_ > 0) { // If we have a lazy model, we need to update the remaining value accordingly update_remains_lazy(surf_get_clock()); @@ -178,7 +178,7 @@ void Action::resume() get_model()->getMaxminSystem()->update_variable_weight(get_variable(), get_priority()); suspended_ = SuspendStates::not_suspended; if (get_model()->getUpdateMechanism() == UM_LAZY) - heapRemove(get_model()->getActionHeap()); + heapRemove(); } XBT_OUT(); } @@ -194,28 +194,28 @@ bool Action::is_suspended() * LATENCY = this is a heap entry to warn us when the latency is payed * MAX_DURATION =this is a heap entry to warn us when the max_duration limit is reached */ -void Action::heapInsert(heap_type& heap, double key, Action::Type hat) +void Action::heapInsert(double key, Action::Type hat) { type_ = hat; - heap_hook_ = heap.emplace(std::make_pair(key, this)); + heap_hook_ = get_model()->getActionHeap().emplace(std::make_pair(key, this)); } -void Action::heapRemove(heap_type& heap) +void Action::heapRemove() { type_ = Action::Type::NOTSET; if (heap_hook_) { - heap.erase(*heap_hook_); + get_model()->getActionHeap().erase(*heap_hook_); clearHeapHandle(); } } -void Action::heapUpdate(heap_type& heap, double key, Action::Type hat) +void Action::heapUpdate(double key, Action::Type hat) { type_ = hat; if (heap_hook_) { - heap.update(*heap_hook_, std::make_pair(key, this)); + get_model()->getActionHeap().update(*heap_hook_, std::make_pair(key, this)); } else { - heap_hook_ = heap.emplace(std::make_pair(key, this)); + heap_hook_ = get_model()->getActionHeap().emplace(std::make_pair(key, this)); } } diff --git a/src/kernel/resource/Model.cpp b/src/kernel/resource/Model.cpp index 2b2954c63d..c257fffb86 100644 --- a/src/kernel/resource/Model.cpp +++ b/src/kernel/resource/Model.cpp @@ -93,7 +93,7 @@ double Model::nextOccuringEventLazy(double now) action->get_start_time(), min, share, action->get_max_duration()); if (min > -1) { - action->heapUpdate(action_heap_, min, max_dur_flag ? Action::Type::MAX_DURATION : Action::Type::NORMAL); + action->heapUpdate(min, max_dur_flag ? Action::Type::MAX_DURATION : Action::Type::NORMAL); XBT_DEBUG("Insert at heap action(%p) min %f now %f", action, min, now); } else DIE_IMPOSSIBLE; diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 477e392809..b19c922120 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -182,7 +182,7 @@ CpuAction *CpuCas01::sleep(double duration) model()->getMaxminSystem()->update_variable_weight(action->get_variable(), 0.0); if (model()->getUpdateMechanism() == UM_LAZY) { // remove action from the heap - action->heapRemove(model()->getActionHeap()); + action->heapRemove(); // 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 model()->getModifiedSet()->push_front(*action); diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 1fb74c02ff..f4db720924 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -442,7 +442,7 @@ void CpuTi::apply_event(tmgr_trace_event_t event, double value) action.get_state() == kernel::resource::Action::State::not_in_the_system) { action.set_finish_time(date); action.set_state(kernel::resource::Action::State::failed); - action.heapRemove(model()->getActionHeap()); + action.heapRemove(); } } } @@ -505,9 +505,9 @@ void CpuTi::updateActionsFinishTime(double now) } /* add in action heap */ if (min_finish > NO_MAX_DURATION) - action.heapUpdate(model()->getActionHeap(), min_finish, kernel::resource::Action::Type::NOTSET); + action.heapUpdate(min_finish, kernel::resource::Action::Type::NOTSET); else - action.heapRemove(model()->getActionHeap()); + action.heapRemove(); XBT_DEBUG("Update finish time: Cpu(%s) Action: %p, Start Time: %f Finish Time: %f Max duration %f", getCname(), &action, action.get_start_time(), action.get_finish_time(), action.get_max_duration()); @@ -629,7 +629,7 @@ CpuTiAction::~CpuTiAction() if (action_ti_hook.is_linked()) simgrid::xbt::intrusive_erase(cpu_->actionSet_, *this); /* remove from heap */ - heapRemove(get_model()->getActionHeap()); + heapRemove(); cpu_->modified(true); } @@ -642,7 +642,7 @@ void CpuTiAction::set_state(Action::State state) void CpuTiAction::cancel() { this->set_state(Action::State::failed); - heapRemove(get_model()->getActionHeap()); + heapRemove(); cpu_->modified(true); } @@ -651,7 +651,7 @@ void CpuTiAction::suspend() XBT_IN("(%p)", this); if (suspended_ != Action::SuspendStates::sleeping) { suspended_ = Action::SuspendStates::suspended; - heapRemove(get_model()->getActionHeap()); + heapRemove(); cpu_->modified(true); } XBT_OUT(); @@ -682,7 +682,7 @@ void CpuTiAction::set_max_duration(double duration) min_finish = get_finish_time(); /* add in action heap */ - heapUpdate(get_model()->getActionHeap(), min_finish, Action::Type::NOTSET); + heapUpdate(min_finish, Action::Type::NOTSET); XBT_OUT(); } diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index f3e83138a0..01a14eaa91 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -191,7 +191,7 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) if (action->get_type() == kernel::resource::Action::Type::LATENCY) { XBT_DEBUG("Latency paid for action %p. Activating", action); maxmin_system_->update_variable_weight(action->get_variable(), action->weight_); - action->heapRemove(getActionHeap()); + action->heapRemove(); action->set_last_update(); // if I am wearing a max_duration or normal hat @@ -201,7 +201,7 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) // assume that flows that reached max_duration have remaining of 0 XBT_DEBUG("Action %p finished", action); action->finish(kernel::resource::Action::State::done); - action->heapRemove(getActionHeap()); + action->heapRemove(); } } } @@ -309,9 +309,9 @@ kernel::resource::Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Hos if (getUpdateMechanism() == 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->get_last_update()); - action->heapInsert(getActionHeap(), action->latency_ + action->get_last_update(), - route.empty() ? kernel::resource::Action::Type::NORMAL - : kernel::resource::Action::Type::LATENCY); + action->heapInsert(action->latency_ + action->get_last_update(), route.empty() + ? kernel::resource::Action::Type::NORMAL + : kernel::resource::Action::Type::LATENCY); } } else action->set_variable(maxmin_system_->variable_new(action, 1.0, -1.0, constraints_per_variable)); @@ -485,7 +485,7 @@ void NetworkCm02Action::update_remains_lazy(double now) if ((get_remains_no_update() <= 0 && (get_variable()->get_weight() > 0)) || ((max_duration > NO_MAX_DURATION) && (max_duration <= 0))) { finish(Action::State::done); - heapRemove(get_model()->getActionHeap()); + heapRemove(); } set_last_update(); -- 2.20.1