Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
these functions always take exactly the same parameter, thus inlining it
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 26 Mar 2018 18:53:19 +0000 (20:53 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 26 Mar 2018 18:53:19 +0000 (20:53 +0200)
include/simgrid/kernel/resource/Action.hpp
src/kernel/resource/Action.cpp
src/kernel/resource/Model.cpp
src/surf/cpu_cas01.cpp
src/surf/cpu_ti.cpp
src/surf/network_cm02.cpp

index 141df64..4961cef 100644 (file)
@@ -193,9 +193,9 @@ private:
   boost::optional<heap_type::handle_type> 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_; }
index 919e06e..52a857c 100644 (file)
@@ -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));
   }
 }
 
index 2b2954c..c257fff 100644 (file)
@@ -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;
index 477e392..b19c922 100644 (file)
@@ -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);
index 1fb74c0..f4db720 100644 (file)
@@ -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();
 }
index f3e8313..01a14ea 100644 (file)
@@ -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();