Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cosmetics and snake_casing in Action and Model
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 1 Apr 2018 08:00:04 +0000 (10:00 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 1 Apr 2018 08:58:07 +0000 (10:58 +0200)
include/simgrid/kernel/resource/Action.hpp
include/simgrid/kernel/resource/Model.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
src/surf/network_interface.hpp

index c0c0aec..34f05be 100644 (file)
@@ -54,7 +54,12 @@ public:
     sleeping
   };
 
-  enum class Type { LATENCY = 100, MAX_DURATION, NORMAL, NOTSET };
+  enum class Type {
+    latency = 100, /* 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 (timeout) is reached */
+    normal,        /* this is a normal heap entry stating the date to finish transmitting */
+    unset
+  };
 
   /**
    * @brief Action constructor
@@ -189,14 +194,14 @@ private:
   double last_update_                                = 0;
   double last_value_                                 = 0;
   kernel::lmm::Variable* variable_                   = nullptr;
-  Action::Type type_                                 = Action::Type::NOTSET;
+  Action::Type type_                                 = Action::Type::unset;
   boost::optional<heap_type::handle_type> heap_hook_ = boost::none;
 
 public:
-  void heapInsert(double key, Action::Type hat);
+  void heapInsert(double key, Action::Type type);
   void heapRemove();
-  void heapUpdate(double key, Action::Type hat);
-  void clearHeapHandle() { heap_hook_ = boost::none; }
+  void heapUpdate(double key, Action::Type type);
+  void heap_clear_handle();
 
   lmm::Variable* get_variable() const { return variable_; }
   void set_variable(lmm::Variable* var) { variable_ = var; }
index 83076be..1956833 100644 (file)
@@ -52,11 +52,11 @@ public:
   /** @brief Set the maxmin system of the current Model */
   void set_maxmin_system(lmm::System* system) { maxmin_system_ = system; }
 
-  /** @brief Get the update mechanism of the current Model */
-  UpdateAlgo getUpdateMechanism() const { return update_algorithm_; }
+  /** @brief Get the update algorithm of the current Model */
+  UpdateAlgo get_update_algorithm() const { return update_algorithm_; }
 
   /** @brief Get Action heap */
-  heap_type& getActionHeap() { return action_heap_; }
+  heap_type& get_action_heap() { return action_heap_; }
 
   double actionHeapTopDate() const { return action_heap_.top().first; }
   Action* actionHeapPop();
index 44f57ce..f585693 100644 (file)
@@ -100,7 +100,7 @@ void Action::set_bound(double bound)
   if (variable_)
     get_model()->get_maxmin_system()->update_variable_bound(variable_, bound);
 
-  if (get_model()->getUpdateMechanism() == Model::UpdateAlgo::Lazy && get_last_update() != surf_get_clock())
+  if (get_model()->get_update_algorithm() == Model::UpdateAlgo::Lazy && get_last_update() != surf_get_clock())
     heapRemove();
   XBT_OUT();
 }
@@ -118,7 +118,7 @@ void Action::ref()
 void Action::set_max_duration(double duration)
 {
   max_duration_ = duration;
-  if (get_model()->getUpdateMechanism() == Model::UpdateAlgo::Lazy) // remove action from the heap
+  if (get_model()->get_update_algorithm() == Model::UpdateAlgo::Lazy) // remove action from the heap
     heapRemove();
 }
 
@@ -128,7 +128,7 @@ void Action::set_priority(double weight)
   sharing_priority_ = weight;
   get_model()->get_maxmin_system()->update_variable_weight(get_variable(), weight);
 
-  if (get_model()->getUpdateMechanism() == Model::UpdateAlgo::Lazy)
+  if (get_model()->get_update_algorithm() == Model::UpdateAlgo::Lazy)
     heapRemove();
   XBT_OUT();
 }
@@ -136,7 +136,7 @@ void Action::set_priority(double weight)
 void Action::cancel()
 {
   set_state(Action::State::failed);
-  if (get_model()->getUpdateMechanism() == Model::UpdateAlgo::Lazy) {
+  if (get_model()->get_update_algorithm() == Model::UpdateAlgo::Lazy) {
     if (modified_set_hook_.is_linked())
       simgrid::xbt::intrusive_erase(*get_model()->get_modified_set(), *this);
     heapRemove();
@@ -158,7 +158,7 @@ void Action::suspend()
   XBT_IN("(%p)", this);
   if (suspended_ != SuspendStates::sleeping) {
     get_model()->get_maxmin_system()->update_variable_weight(get_variable(), 0.0);
-    if (get_model()->getUpdateMechanism() == Model::UpdateAlgo::Lazy) {
+    if (get_model()->get_update_algorithm() == Model::UpdateAlgo::Lazy) {
       heapRemove();
       if (state_set_ == get_model()->get_running_action_set() && sharing_priority_ > 0) {
         // If we have a lazy model, we need to update the remaining value accordingly
@@ -176,7 +176,7 @@ void Action::resume()
   if (suspended_ != SuspendStates::sleeping) {
     get_model()->get_maxmin_system()->update_variable_weight(get_variable(), get_priority());
     suspended_ = SuspendStates::not_suspended;
-    if (get_model()->getUpdateMechanism() == Model::UpdateAlgo::Lazy)
+    if (get_model()->get_update_algorithm() == Model::UpdateAlgo::Lazy)
       heapRemove();
   }
   XBT_OUT();
@@ -186,35 +186,33 @@ bool Action::is_suspended()
 {
   return suspended_ == SuspendStates::suspended;
 }
-/* insert action on heap using a given key and a hat (heap_action_type)
- * a hat can be of three types for communications:
- *
- * NORMAL = this is a normal heap entry stating the date to finish transmitting
- * 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(double key, Action::Type hat)
+/* insert action on heap using a given key and a type  */
+void Action::heapInsert(double key, Action::Type type)
 {
-  type_       = hat;
-  heap_hook_  = get_model()->getActionHeap().emplace(std::make_pair(key, this));
+  type_      = type;
+  heap_hook_ = get_model()->get_action_heap().emplace(std::make_pair(key, this));
 }
 
 void Action::heapRemove()
 {
-  type_ = Action::Type::NOTSET;
+  type_ = Action::Type::unset;
   if (heap_hook_) {
-    get_model()->getActionHeap().erase(*heap_hook_);
-    clearHeapHandle();
+    get_model()->get_action_heap().erase(*heap_hook_);
+    heap_hook_ = boost::none;
   }
 }
+void Action::heap_clear_handle()
+{
+  heap_hook_ = boost::none;
+}
 
-void Action::heapUpdate(double key, Action::Type hat)
+void Action::heapUpdate(double key, Action::Type type)
 {
-  type_ = hat;
+  type_ = type;
   if (heap_hook_) {
-    get_model()->getActionHeap().update(*heap_hook_, std::make_pair(key, this));
+    get_model()->get_action_heap().update(*heap_hook_, std::make_pair(key, this));
   } else {
-    heap_hook_ = get_model()->getActionHeap().emplace(std::make_pair(key, this));
+    heap_hook_ = get_model()->get_action_heap().emplace(std::make_pair(key, this));
   }
 }
 
@@ -222,7 +220,7 @@ double Action::get_remains()
 {
   XBT_IN("(%p)", this);
   /* update remains before return it */
-  if (get_model()->getUpdateMechanism() == Model::UpdateAlgo::Lazy) /* update remains before return it */
+  if (get_model()->get_update_algorithm() == Model::UpdateAlgo::Lazy) /* update remains before return it */
     update_remains_lazy(surf_get_clock());
   XBT_OUT();
   return remains_;
index ee43169..3eb402d 100644 (file)
@@ -27,7 +27,7 @@ Action* Model::actionHeapPop()
 {
   Action* action = action_heap_.top().second;
   action_heap_.pop();
-  action->clearHeapHandle();
+  action->heap_clear_handle();
   return action;
 }
 
@@ -62,7 +62,7 @@ double Model::next_occuring_event_lazy(double now)
       continue;
 
     /* bogus priority, skip it */
-    if (action->get_priority() <= 0 || action->get_type() == Action::Type::LATENCY)
+    if (action->get_priority() <= 0 || action->get_type() == Action::Type::latency)
       continue;
 
     action->update_remains_lazy(now);
@@ -93,7 +93,7 @@ double Model::next_occuring_event_lazy(double now)
               action->get_start_time(), min, share, action->get_max_duration());
 
     if (min > -1) {
-      action->heapUpdate(min, max_duration_flag ? Action::Type::MAX_DURATION : Action::Type::NORMAL);
+      action->heapUpdate(min, max_duration_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 4f105a5..213ec2e 100644 (file)
@@ -199,7 +199,7 @@ CpuAction *CpuCas01::sleep(double duration)
   }
 
   model()->get_maxmin_system()->update_variable_weight(action->get_variable(), 0.0);
-  if (model()->getUpdateMechanism() == kernel::resource::Model::UpdateAlgo::Lazy) { // remove action from the heap
+  if (model()->get_update_algorithm() == kernel::resource::Model::UpdateAlgo::Lazy) { // remove action from the heap
     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
@@ -219,7 +219,7 @@ CpuCas01Action::CpuCas01Action(kernel::resource::Model* model, double cost, bool
                 model->get_maxmin_system()->variable_new(this, 1.0 / requestedCore, requestedCore * speed, 1))
     , requestedCore_(requestedCore)
 {
-  if (model->getUpdateMechanism() == kernel::resource::Model::UpdateAlgo::Lazy) {
+  if (model->get_update_algorithm() == kernel::resource::Model::UpdateAlgo::Lazy) {
     set_last_update();
     set_last_value(0.0);
   }
index 06a7f58..a76da40 100644 (file)
@@ -485,7 +485,7 @@ void CpuTi::update_actions_finish_time(double now)
     }
     /* add in action heap */
     if (min_finish > NO_MAX_DURATION)
-      action.heapUpdate(min_finish, kernel::resource::Action::Type::NOTSET);
+      action.heapUpdate(min_finish, kernel::resource::Action::Type::unset);
     else
       action.heapRemove();
 
@@ -663,7 +663,7 @@ void CpuTiAction::set_max_duration(double duration)
     min_finish = get_finish_time();
 
   /* add in action heap */
-  heapUpdate(min_finish, Action::Type::NOTSET);
+  heapUpdate(min_finish, Action::Type::unset);
 
   XBT_OUT();
 }
index aa9df6d..157456c 100644 (file)
@@ -176,15 +176,15 @@ void NetworkCm02Model::update_actions_state_lazy(double now, double /*delta*/)
     }
 
     // if I am wearing a latency hat
-    if (action->get_type() == kernel::resource::Action::Type::LATENCY) {
+    if (action->get_type() == kernel::resource::Action::Type::latency) {
       XBT_DEBUG("Latency paid for action %p. Activating", action);
       get_maxmin_system()->update_variable_weight(action->get_variable(), action->weight_);
       action->heapRemove();
       action->set_last_update();
 
       // if I am wearing a max_duration or normal hat
-    } else if (action->get_type() == kernel::resource::Action::Type::MAX_DURATION ||
-               action->get_type() == kernel::resource::Action::Type::NORMAL) {
+    } else if (action->get_type() == kernel::resource::Action::Type::max_duration ||
+               action->get_type() == kernel::resource::Action::Type::normal) {
       // no need to communicate anymore
       // assume that flows that reached max_duration have remaining of 0
       XBT_DEBUG("Action %p finished", action);
@@ -270,7 +270,7 @@ kernel::resource::Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Hos
   action->weight_ = latency;
   action->latency_ = latency;
   action->rate_ = rate;
-  if (getUpdateMechanism() == kernel::resource::Model::UpdateAlgo::Lazy) {
+  if (get_update_algorithm() == kernel::resource::Model::UpdateAlgo::Lazy) {
     action->set_last_update();
   }
 
@@ -284,7 +284,7 @@ kernel::resource::Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Hos
     bandwidth_bound = (bandwidth_bound < 0.0) ? bb : std::min(bandwidth_bound, bb);
   }
 
-  action->latCurrent_ = action->latency_;
+  action->lat_current_ = action->latency_;
   action->latency_ *= latencyFactor(size);
   action->rate_ = bandwidthConstraint(action->rate_, bandwidth_bound, size);
 
@@ -293,24 +293,24 @@ kernel::resource::Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Hos
 
   if (action->latency_ > 0) {
     action->set_variable(get_maxmin_system()->variable_new(action, 0.0, -1.0, constraints_per_variable));
-    if (getUpdateMechanism() == kernel::resource::Model::UpdateAlgo::Lazy) {
+    if (get_update_algorithm() == kernel::resource::Model::UpdateAlgo::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(action->latency_ + action->get_last_update(), route.empty()
-                                                                           ? kernel::resource::Action::Type::NORMAL
-                                                                           : kernel::resource::Action::Type::LATENCY);
+                                                                           ? kernel::resource::Action::Type::normal
+                                                                           : kernel::resource::Action::Type::latency);
     }
   } else
     action->set_variable(get_maxmin_system()->variable_new(action, 1.0, -1.0, constraints_per_variable));
 
   if (action->rate_ < 0) {
     get_maxmin_system()->update_variable_bound(
-        action->get_variable(), (action->latCurrent_ > 0) ? sg_tcp_gamma / (2.0 * action->latCurrent_) : -1.0);
+        action->get_variable(), (action->lat_current_ > 0) ? sg_tcp_gamma / (2.0 * action->lat_current_) : -1.0);
   } else {
-    get_maxmin_system()->update_variable_bound(action->get_variable(),
-                                               (action->latCurrent_ > 0)
-                                                   ? std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_))
-                                                   : action->rate_);
+    get_maxmin_system()->update_variable_bound(
+        action->get_variable(), (action->lat_current_ > 0)
+                                    ? std::min(action->rate_, sg_tcp_gamma / (2.0 * action->lat_current_))
+                                    : action->rate_);
   }
 
   for (auto const& link : route)
@@ -424,19 +424,19 @@ void NetworkCm02Link::setLatency(double value)
 
   while ((var = constraint()->get_variable_safe(&elem, &nextelem, &numelem))) {
     NetworkCm02Action* action = static_cast<NetworkCm02Action*>(var->get_id());
-    action->latCurrent_ += delta;
+    action->lat_current_ += delta;
     action->weight_ += delta;
     if (action->rate_ < 0)
       model()->get_maxmin_system()->update_variable_bound(action->get_variable(),
-                                                          sg_tcp_gamma / (2.0 * action->latCurrent_));
+                                                          sg_tcp_gamma / (2.0 * action->lat_current_));
     else {
       model()->get_maxmin_system()->update_variable_bound(
-          action->get_variable(), std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_)));
+          action->get_variable(), std::min(action->rate_, sg_tcp_gamma / (2.0 * action->lat_current_)));
 
-      if (action->rate_ < sg_tcp_gamma / (2.0 * action->latCurrent_)) {
+      if (action->rate_ < sg_tcp_gamma / (2.0 * action->lat_current_)) {
         XBT_INFO("Flow is limited BYBANDWIDTH");
       } else {
-        XBT_INFO("Flow is limited BYLATENCY, latency of flow is %f", action->latCurrent_);
+        XBT_INFO("Flow is limited BYLATENCY, latency of flow is %f", action->lat_current_);
       }
     }
     if (not action->is_suspended())
index a04496e..f29e835 100644 (file)
@@ -211,7 +211,7 @@ public:
   virtual std::list<LinkImpl*> links();
 
   double latency_    = {};
-  double latCurrent_ = {};
+  double lat_current_ = {};
   double weight_     = {};
   double rate_       = {};
 };