Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rename Action::priority into Action::sharing_penalty in surf as it should be
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 4 Jun 2019 16:09:38 +0000 (18:09 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 4 Jun 2019 16:10:29 +0000 (18:10 +0200)
This commit contains the following at the s4u -> surf boundary:
  -        .set_priority(1. / priority_)
  +        .set_sharing_penalty(1. / priority_)
The old version was just sick.

This should be further propagated down into LMM, where the
sharing_penalty is still named "sharing_weight". Not a helpful name
for the poor souls who didn't wrote an hdr on this topic :)

14 files changed:
include/simgrid/kernel/resource/Action.hpp
include/simgrid/simix.h
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/ExecImpl.hpp
src/kernel/resource/Action.cpp
src/kernel/resource/Model.cpp
src/plugins/vm/VirtualMachineImpl.cpp
src/s4u/s4u_Exec.cpp
src/simix/libsmx.cpp
src/surf/cpu_interface.cpp
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp
src/surf/storage_n11.cpp
src/surf/storage_n11.hpp

index 475ba17..2821e7f 100644 (file)
@@ -191,11 +191,11 @@ public:
   /** @brief Set the tracing category of the current Action */
   void set_category(const std::string& category) { category_ = category; }
 
-  /** @brief Get the priority of the current Action */
-  double get_priority() const { return sharing_priority_; };
-  /** @brief Set the priority of the current Action */
-  virtual void set_priority(double priority);
-  void set_priority_no_update(double priority) { sharing_priority_ = priority; }
+  /** @brief Get the sharing_penalty (RTT or 1/thread_count) of the current Action */
+  double get_sharing_penalty() const { return sharing_penalty_; };
+  /** @brief Set the sharing_penalty (RTT or 1/thread_count) of the current Action */
+  virtual void set_sharing_penalty(double sharing_penalty);
+  void set_sharing_penalty_no_update(double sharing_penalty) { sharing_penalty_ = sharing_penalty; }
 
   /** @brief Get the state set in which the action is */
   StateSet* get_state_set() const { return state_set_; };
@@ -206,7 +206,7 @@ private:
   StateSet* state_set_;
   Action::SuspendStates suspended_ = Action::SuspendStates::RUNNING;
   int refcount_            = 1;
-  double sharing_priority_ = 1.0;             /**< priority (1.0 by default) */
+  double sharing_penalty_          = 1.0;             /**< priority (1.0 by default) */
   double max_duration_   = NO_MAX_DURATION; /*< max_duration (may fluctuate until the task is completed) */
   double remains_;           /**< How much of that cost remains to be done in the currently running task */
   double start_time_;        /**< start time  */
index 32de0a0..ba069df 100644 (file)
@@ -273,16 +273,14 @@ XBT_ATTRIB_DEPRECATED_v325("Please use Comm::cancel()") XBT_PUBLIC void simcall_
 
 XBT_ATTRIB_DEPRECATED_v325("Please use Exec::cancel()") XBT_PUBLIC
     void simcall_execution_cancel(smx_activity_t execution);
-XBT_ATTRIB_DEPRECATED_v325("Please use Exec::set_priority()") XBT_PUBLIC
-    void simcall_execution_set_priority(smx_activity_t execution, double priority);
 XBT_ATTRIB_DEPRECATED_v325("Please use Exec::set_bound()") XBT_PUBLIC
     void simcall_execution_set_bound(smx_activity_t execution, double bound);
 SG_END_DECL()
 
 #ifdef __cplusplus
 XBT_ATTRIB_DEPRECATED_v325("Please use Exec::start()") XBT_PUBLIC smx_activity_t
-    simcall_execution_start(const std::string& name, const std::string& category, double flops_amount, double priority,
-                            double bound, sg_host_t host);
+    simcall_execution_start(const std::string& name, const std::string& category, double flops_amount,
+                            double sharing_penalty, double bound, sg_host_t host);
 
 // Should be deprecated in v325 too but is still used in other deprecated calls
 XBT_PUBLIC smx_activity_t simcall_execution_parallel_start(const std::string& name, int host_nb,
index 5b60a57..18c816b 100644 (file)
@@ -141,7 +141,7 @@ ExecImpl* ExecImpl::start()
   if (not MC_is_active() && not MC_record_replay_is_active()) {
     if (hosts_.size() == 1) {
       surf_action_ = hosts_.front()->pimpl_cpu->execution_start(flops_amounts_.front());
-      surf_action_->set_priority(priority_);
+      surf_action_->set_sharing_penalty(sharing_penalty_);
       surf_action_->set_category(get_tracing_category());
 
       if (bound_ > 0)
@@ -174,9 +174,9 @@ ExecImpl& ExecImpl::set_bound(double bound)
   return *this;
 }
 
-ExecImpl& ExecImpl::set_priority(double priority)
+ExecImpl& ExecImpl::set_sharing_penalty(double sharing_penalty)
 {
-  priority_ = priority;
+  sharing_penalty_ = sharing_penalty;
   return *this;
 }
 
@@ -292,7 +292,7 @@ ActivityImpl* ExecImpl::migrate(s4u::Host* to)
     resource::Action* new_action = to->pimpl_cpu->execution_start(old_action->get_cost());
     new_action->set_remains(old_action->get_remains());
     new_action->set_activity(this);
-    new_action->set_priority(old_action->get_priority());
+    new_action->set_sharing_penalty(old_action->get_sharing_penalty());
 
     // FIXME: the user-defined bound seem to not be kept by LMM, that seem to overwrite it for the multi-core modeling.
     // I hope that the user did not provide any.
index 9e35d73..524e3d1 100644 (file)
@@ -16,7 +16,7 @@ namespace activity {
 
 class XBT_PUBLIC ExecImpl : public ActivityImpl_T<ExecImpl> {
   resource::Action* timeout_detector_ = nullptr;
-  double priority_                    = 1.0;
+  double sharing_penalty_             = 1.0;
   double bound_                       = 0.0;
   std::vector<s4u::Host*> hosts_;
   std::vector<double> flops_amounts_;
@@ -26,7 +26,7 @@ class XBT_PUBLIC ExecImpl : public ActivityImpl_T<ExecImpl> {
 public:
   ExecImpl& set_timeout(double timeout);
   ExecImpl& set_bound(double bound);
-  ExecImpl& set_priority(double priority);
+  ExecImpl& set_sharing_penalty(double sharing_penalty);
 
   ExecImpl& set_flops_amount(double flop_amount);
   ExecImpl& set_host(s4u::Host* host);
index ee1c70a..871842d 100644 (file)
@@ -121,11 +121,11 @@ void Action::set_max_duration(double duration)
     get_model()->get_action_heap().remove(this);
 }
 
-void Action::set_priority(double weight)
+void Action::set_sharing_penalty(double sharing_penalty)
 {
-  XBT_IN("(%p,%g)", this, weight);
-  sharing_priority_ = weight;
-  get_model()->get_maxmin_system()->update_variable_weight(get_variable(), weight);
+  XBT_IN("(%p,%g)", this, sharing_penalty);
+  sharing_penalty_ = sharing_penalty;
+  get_model()->get_maxmin_system()->update_variable_weight(get_variable(), sharing_penalty);
 
   if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY)
     get_model()->get_action_heap().remove(this);
@@ -159,7 +159,7 @@ void Action::suspend()
     get_model()->get_maxmin_system()->update_variable_weight(get_variable(), 0.0);
     if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) {
       get_model()->get_action_heap().remove(this);
-      if (state_set_ == get_model()->get_started_action_set() && sharing_priority_ > 0) {
+      if (state_set_ == get_model()->get_started_action_set() && sharing_penalty_ > 0) {
         // If we have a lazy model, we need to update the remaining value accordingly
         update_remains_lazy(surf_get_clock());
       }
@@ -173,7 +173,7 @@ void Action::resume()
 {
   XBT_IN("(%p)", this);
   if (suspended_ != SuspendStates::SLEEPING) {
-    get_model()->get_maxmin_system()->update_variable_weight(get_variable(), get_priority());
+    get_model()->get_maxmin_system()->update_variable_weight(get_variable(), get_sharing_penalty());
     suspended_ = SuspendStates::RUNNING;
     if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY)
       get_model()->get_action_heap().remove(this);
index 635f0b9..6f392e4 100644 (file)
@@ -52,7 +52,7 @@ double Model::next_occuring_event_lazy(double now)
       continue;
 
     /* bogus priority, skip it */
-    if (action->get_priority() <= 0 || action->get_type() == ActionHeap::Type::latency)
+    if (action->get_sharing_penalty() <= 0 || action->get_type() == ActionHeap::Type::latency)
       continue;
 
     action->update_remains_lazy(now);
index 9e20699..191d5cf 100644 (file)
@@ -300,9 +300,9 @@ void VirtualMachineImpl::update_action_weight(){
   XBT_DEBUG("set the weight of the dummy CPU action of VM%p on PM to %d (#tasks: %d)", this, impact, active_tasks_);
 
   if (impact > 0)
-    action_->set_priority(1. / impact);
+    action_->set_sharing_penalty(1. / impact);
   else
-    action_->set_priority(0.);
+    action_->set_sharing_penalty(0.);
 
   action_->set_bound(std::min(impact * physical_host_->get_speed(), user_bound_));
 }
index feecbdd..17fa93c 100644 (file)
@@ -138,7 +138,7 @@ Exec* ExecSeq::start()
     (*boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_))
         .set_name(name_)
         .set_tracing_category(tracing_category_)
-        .set_priority(1. / priority_)
+        .set_sharing_penalty(1. / priority_)
         .set_bound(bound_)
         .set_flops_amount(flops_amount_)
         .start();
@@ -177,7 +177,7 @@ double ExecSeq::get_remaining()
       [this]() { return boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(pimpl_)->get_remaining(); });
 }
 
-/** @brief Returns the ratio of elements that are still to do
+/** @brief Returns the ratio of elements that are still to do
  *
  * The returned value is between 0 (completely done) and 1 (nothing done yet).
  */
index 9261394..e1b7856 100644 (file)
@@ -368,12 +368,6 @@ void simcall_execution_cancel(smx_activity_t exec)
 {
   simgrid::simix::simcall([exec] { boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(exec)->cancel(); });
 }
-void simcall_execution_set_priority(smx_activity_t exec, double priority)
-{
-  simgrid::simix::simcall([exec, priority] {
-    boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(exec)->set_priority(priority);
-  });
-}
 
 void simcall_execution_set_bound(smx_activity_t exec, double bound)
 {
@@ -383,15 +377,15 @@ void simcall_execution_set_bound(smx_activity_t exec, double bound)
 
 // deprecated
 smx_activity_t simcall_execution_start(const std::string& name, const std::string& category, double flops_amount,
-                                       double priority, double bound, sg_host_t host)
+                                       double sharing_penalty, double bound, sg_host_t host)
 {
-  return simgrid::simix::simcall([name, category, flops_amount, priority, bound, host] {
+  return simgrid::simix::simcall([name, category, flops_amount, sharing_penalty, bound, host] {
     simgrid::kernel::activity::ExecImpl* exec = new simgrid::kernel::activity::ExecImpl();
     (*exec)
         .set_name(name)
         .set_tracing_category(category)
         .set_host(host)
-        .set_priority(priority)
+        .set_sharing_penalty(sharing_penalty)
         .set_bound(bound)
         .set_flops_amount(flops_amount)
         .start();
index 7342a03..76d5691 100644 (file)
@@ -142,7 +142,7 @@ void CpuAction::update_remains_lazy(double now)
 {
   xbt_assert(get_state_set() == get_model()->get_started_action_set(),
              "You're updating an action that is not running.");
-  xbt_assert(get_priority() > 0, "You're updating an action that seems suspended.");
+  xbt_assert(get_sharing_penalty() > 0, "You're updating an action that seems suspended.");
 
   double delta = now - get_last_update();
 
index eb5574a..73f35fd 100644 (file)
@@ -414,14 +414,14 @@ void CpuTi::update_actions_finish_time(double now)
       continue;
 
     /* bogus priority, skip it */
-    if (action.get_priority() <= 0)
+    if (action.get_sharing_penalty() <= 0)
       continue;
 
     /* action suspended, skip it */
     if (not action.is_running())
       continue;
 
-    sum_priority_ += 1.0 / action.get_priority();
+    sum_priority_ += 1.0 / action.get_sharing_penalty();
   }
 
   for (CpuTiAction& action : action_set_) {
@@ -431,9 +431,9 @@ void CpuTi::update_actions_finish_time(double now)
       continue;
 
     /* verify if the action is really running on cpu */
-    if (action.is_running() && action.get_priority() > 0) {
+    if (action.is_running() && action.get_sharing_penalty() > 0) {
       /* total area needed to finish the action. Used in trace integration */
-      double total_area = (action.get_remains() * sum_priority_ * action.get_priority()) / speed_.peak;
+      double total_area = (action.get_remains() * sum_priority_ * action.get_sharing_penalty()) / speed_.peak;
 
       action.set_finish_time(speed_integrated_trace_->solve(now, total_area));
       /* verify which event will happen before (max_duration or finish time) */
@@ -487,7 +487,7 @@ void CpuTi::update_remaining_amount(double now)
       continue;
 
     /* bogus priority, skip it */
-    if (action.get_priority() <= 0)
+    if (action.get_sharing_penalty() <= 0)
       continue;
 
     /* action suspended, skip it */
@@ -503,7 +503,7 @@ void CpuTi::update_remaining_amount(double now)
       continue;
 
     /* update remaining */
-    action.update_remains(area_total / (sum_priority_ * action.get_priority()));
+    action.update_remains(area_total / (sum_priority_ * action.get_sharing_penalty()));
     XBT_DEBUG("Update remaining action(%p) remaining %f", &action, action.get_remains_no_update());
   }
   last_update_ = now;
@@ -624,10 +624,10 @@ void CpuTiAction::set_max_duration(double duration)
   XBT_OUT();
 }
 
-void CpuTiAction::set_priority(double priority)
+void CpuTiAction::set_sharing_penalty(double sharing_penalty)
 {
-  XBT_IN("(%p,%g)", this, priority);
-  set_priority_no_update(priority);
+  XBT_IN("(%p,%g)", this, sharing_penalty);
+  set_sharing_penalty_no_update(sharing_penalty);
   cpu_->set_modified(true);
   XBT_OUT();
 }
index 0378104..7ad6573 100644 (file)
@@ -83,7 +83,7 @@ public:
   void suspend() override;
   void resume() override;
   void set_max_duration(double duration) override;
-  void set_priority(double priority) override;
+  void set_sharing_penalty(double sharing_penalty) override;
   double get_remains() override;
 
   CpuTi *cpu_;
index 6518688..6704150 100644 (file)
@@ -163,7 +163,7 @@ void StorageN11Action::set_max_duration(double /*duration*/)
   THROW_UNIMPLEMENTED;
 }
 
-void StorageN11Action::set_priority(double /*priority*/)
+void StorageN11Action::set_sharing_penalty(double)
 {
   THROW_UNIMPLEMENTED;
 }
index 309b7c5..6ac7cc7 100644 (file)
@@ -61,7 +61,7 @@ public:
   void cancel() override;
   void resume() override;
   void set_max_duration(double duration) override;
-  void set_priority(double priority) override;
+  void set_sharing_penalty(double sharing_penalty) override;
   void update_remains_lazy(double now) override;
 };