Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
refactor: be explicit on what an action's priority is
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 4 Jul 2017 10:00:38 +0000 (12:00 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 4 Jul 2017 11:40:57 +0000 (13:40 +0200)
src/simix/smx_host.cpp
src/surf/HostImpl.cpp
src/surf/cpu_cas01.cpp
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp
src/surf/maxmin_private.hpp
src/surf/storage_n11.cpp
src/surf/storage_n11.hpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp
teshsuite/msg/cloud-sharing/cloud-sharing.c

index 69054e2..4a695aa 100644 (file)
@@ -173,7 +173,7 @@ SIMIX_execution_start(smx_actor_t issuer, const char* name, double flops_amount,
 
     exec->surf_exec = issuer->host->pimpl_cpu->execution_start(flops_amount);
     exec->surf_exec->setData(exec.get());
-    exec->surf_exec->setPriority(priority);
+    exec->surf_exec->setSharingWeight(priority);
 
     if (bound > 0)
       static_cast<simgrid::surf::CpuAction*>(exec->surf_exec)->setBound(bound);
@@ -234,7 +234,7 @@ void SIMIX_execution_set_priority(smx_activity_t synchro, double priority)
   simgrid::kernel::activity::ExecImplPtr exec =
       boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(synchro);
   if(exec->surf_exec)
-    exec->surf_exec->setPriority(priority);
+    exec->surf_exec->setSharingWeight(priority);
 }
 
 void SIMIX_execution_set_bound(smx_activity_t synchro, double bound)
index 4867930..66be41d 100644 (file)
@@ -37,7 +37,10 @@ void HostModel::ignoreEmptyVmInPmLMM()
     int impact = std::min(active_tasks, ws_vm->pimpl_vm_->coreAmount());
 
     XBT_DEBUG("set the weight of the dummy CPU action of VM%p on PM to %d (#tasks: %d)", ws_vm, impact, active_tasks);
-    ws_vm->pimpl_vm_->action_->setPriority(impact);
+    if (impact > 0)
+      ws_vm->pimpl_vm_->action_->setSharingWeight(1. / impact);
+    else
+      ws_vm->pimpl_vm_->action_->setSharingWeight(0.);
   }
 }
 
index 6edd4e9..22eac86 100644 (file)
@@ -209,7 +209,8 @@ CpuAction *CpuCas01::sleep(double duration)
  **********/
 CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint,
                                int requestedCore)
-    : CpuAction(model, cost, failed, lmm_variable_new(model->getMaxminSystem(), this, 1.0, speed, 1))
+    : CpuAction(model, cost, failed,
+                lmm_variable_new(model->getMaxminSystem(), this, 1.0 / requestedCore, requestedCore * speed, 1))
     , requestedCore_(requestedCore)
 {
   if (model->getUpdateMechanism() == UM_LAZY) {
index 79e74a2..9173e1d 100644 (file)
@@ -750,10 +750,10 @@ void CpuTiAction::setMaxDuration(double duration)
   XBT_OUT();
 }
 
-void CpuTiAction::setPriority(double priority)
+void CpuTiAction::setSharingWeight(double priority)
 {
   XBT_IN("(%p,%g)", this, priority);
-  priority_ = priority;
+  sharingWeight_ = priority;
   cpu_->modified(true);
   XBT_OUT();
 }
index e8fdace..3f0fc96 100644 (file)
@@ -92,7 +92,7 @@ public:
   void suspend() override;
   void resume() override;
   void setMaxDuration(double duration) override;
-  void setPriority(double priority) override;
+  void setSharingWeight(double priority) override;
   double getRemains() override;
 
   CpuTi *cpu_;
index c4e3f9c..44fac8c 100644 (file)
@@ -86,11 +86,13 @@ typedef struct lmm_variable {
   s_lmm_element_t *cnsts;
   int cnsts_size;
   int cnsts_number;
+
   // sharing_weight: variable's impact on the resource during the sharing
   //   if == 0, the variable is not considered by LMM
   //   on CPU, actions with N threads have a sharing of N
   //   on network, the actions with higher latency have a lesser sharing_weight
-  double sharing_weight; /* weight == 0 -> not considered by LMM;  */
+  double sharing_weight;
+
   double staged_weight; /* If non-zero, variable is staged for addition as soon as maxconcurrency constraints will be met */
   double bound;
   double value;
index dfe6fcc..0cd5ebd 100644 (file)
@@ -298,7 +298,7 @@ void StorageN11Action::setMaxDuration(double /*duration*/)
   THROW_UNIMPLEMENTED;
 }
 
-void StorageN11Action::setPriority(double /*priority*/)
+void StorageN11Action::setSharingWeight(double /*priority*/)
 {
   THROW_UNIMPLEMENTED;
 }
index 16016d2..4ee60a5 100644 (file)
@@ -65,7 +65,7 @@ public:
   void resume();
   bool isSuspended();
   void setMaxDuration(double duration);
-  void setPriority(double priority);
+  void setSharingWeight(double priority);
 };
 
 }
index 4bbbdfb..5011054 100644 (file)
@@ -735,11 +735,11 @@ void Action::setMaxDuration(double duration)
 
 void Action::gapRemove() {}
 
-void Action::setPriority(double priority)
+void Action::setSharingWeight(double weight)
 {
-  XBT_IN("(%p,%g)", this, priority);
-  priority_ = priority;
-  lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), priority);
+  XBT_IN("(%p,%g)", this, weight);
+  sharingWeight_ = weight;
+  lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), weight);
 
   if (getModel()->getUpdateMechanism() == UM_LAZY)
     heapRemove(getModel()->getActionHeap());
@@ -781,7 +781,8 @@ void Action::suspend()
     lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), 0.0);
     if (getModel()->getUpdateMechanism() == UM_LAZY){
       heapRemove(getModel()->getActionHeap());
-      if (getModel()->getUpdateMechanism() == UM_LAZY  && stateSet_ == getModel()->getRunningActionSet() && priority_ > 0){
+      if (getModel()->getUpdateMechanism() == UM_LAZY && stateSet_ == getModel()->getRunningActionSet() &&
+          sharingWeight_ > 0) {
         //If we have a lazy model, we need to update the remaining value accordingly
         updateRemainingLazy(surf_get_clock());
       }
@@ -795,7 +796,7 @@ void Action::resume()
 {
   XBT_IN("(%p)", this);
   if (suspended_ != 2) {
-    lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), priority_);
+    lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), sharingWeight_);
     suspended_ = 0;
     if (getModel()->getUpdateMechanism() == UM_LAZY)
       heapRemove(getModel()->getActionHeap());
@@ -870,7 +871,7 @@ void Action::updateRemainingLazy(double now)
   else
   {
     xbt_assert(stateSet_ == getModel()->getRunningActionSet(), "You're updating an action that is not running.");
-    xbt_assert(priority_ > 0, "You're updating an action that seems suspended.");
+    xbt_assert(sharingWeight_ > 0, "You're updating an action that seems suspended.");
   }
 
   delta = now - lastUpdate_;
index f544d2f..b9e8b2c 100644 (file)
@@ -200,9 +200,9 @@ public:
   void setCategory(const char *category);
 
   /** @brief Get the priority of the current Action */
-  double getPriority() {return priority_;};
+  double getPriority() { return sharingWeight_; };
   /** @brief Set the priority of the current Action */
-  virtual void setPriority(double priority);
+  virtual void setSharingWeight(double priority);
 
   /** @brief Get the state set in which the action is */
   ActionList* getStateSet() {return stateSet_;};
@@ -213,7 +213,7 @@ public:
 
 protected:
   ActionList* stateSet_;
-  double priority_ = 1.0; /**< priority (1.0 by default) */
+  double sharingWeight_ = 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) */
index 9fa9a44..a24b7e7 100644 (file)
@@ -519,10 +519,10 @@ static int master_main(int argc, char* argv[])
 
   XBT_INFO("## Check impact of a single VM collocated with a task (there is no degradation for the moment)");
   run_test("( [ ]2 o )2");
-  run_test("( [o]2 o )2");
 #endif
-  run_test("( [oo]2 o )2");
+  run_test("( [o]2 o )2");
 #ifdef IGNORE_ME
+  run_test("( [oo]2 o )2");
   run_test("( [ooo]2 o )2");
   run_test("( [ ]2 oo )2");
   run_test("( [o]2 oo )2");