Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move modifiedSet from Resource to lmm::System
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 24 Mar 2018 10:00:05 +0000 (11:00 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 24 Mar 2018 10:07:11 +0000 (11:07 +0100)
include/simgrid/kernel/resource/Model.hpp
src/kernel/lmm/maxmin.cpp
src/kernel/lmm/maxmin.hpp
src/kernel/resource/Model.cpp
src/surf/cpu_cas01.cpp
src/surf/network_cm02.cpp

index 3478fee..9ef9a46 100644 (file)
@@ -47,7 +47,7 @@ public:
   ActionList* getDoneActionSet() const { return doneActionSet_; }
 
   /** @brief Get the set of modified [actions](@ref Action) */
-  ActionLmmListPtr getModifiedSet() const { return modifiedSet_; }
+  ActionLmmListPtr getModifiedSet() const;
 
   /** @brief Get the maxmin system of the current Model */
   lmm_system_t getMaxminSystem() const { return maxminSystem_; }
@@ -94,7 +94,6 @@ public:
   virtual bool nextOccuringEventIsIdempotent() { return true; }
 
 protected:
-  ActionLmmListPtr modifiedSet_ = nullptr;
   lmm_system_t maxminSystem_ = nullptr;
 
 private:
index b9c5b41..879813e 100644 (file)
@@ -150,7 +150,6 @@ System::System(bool selective_update) : selective_update_active(selective_update
 
   XBT_DEBUG("Setting selective_update_active flag to %d", selective_update_active);
 
-  keep_track          = nullptr;
   variable_mallocator =
       xbt_mallocator_new(65536, System::variable_mallocator_new_f, System::variable_mallocator_free_f, nullptr);
   solve_fun = &lmm_solve;
@@ -171,6 +170,7 @@ System::~System()
     cnst_free(cnst);
 
   xbt_mallocator_free(variable_mallocator);
+  delete modified_set_;
 }
 
 void System::cnst_free(Constraint* cnst)
@@ -536,8 +536,8 @@ template <class CnstList> void System::solve(CnstList& cnst_list)
 
         elem.make_active();
         simgrid::kernel::resource::Action* action = static_cast<simgrid::kernel::resource::Action*>(elem.variable->id);
-        if (keep_track && not action->isLinkedModifiedSet())
-          keep_track->push_back(*action);
+        if (modified_set_ && not action->isLinkedModifiedSet())
+          modified_set_->push_back(*action);
       }
     }
     XBT_DEBUG("Constraint '%d' usage: %f remaining: %f concurrency: %i<=%i<=%i", cnst.id_int, cnst.usage,
index c37a5aa..f294e72 100644 (file)
@@ -601,7 +601,7 @@ public:
                                                                    &Constraint::saturated_constraint_set_hook>>
       saturated_constraint_set;
 
-  simgrid::kernel::resource::ActionLmmListPtr keep_track;
+  simgrid::kernel::resource::ActionLmmListPtr modified_set_ = nullptr;
 
   void (*solve_fun)(lmm_system_t self);
 
index 54b0392..2755f5d 100644 (file)
@@ -20,7 +20,6 @@ Model::~Model()
   delete runningActionSet_;
   delete failedActionSet_;
   delete doneActionSet_;
-  delete modifiedSet_;
   delete maxminSystem_;
 }
 
@@ -32,6 +31,11 @@ Action* Model::actionHeapPop()
   return action;
 }
 
+ActionLmmListPtr Model::getModifiedSet() const
+{
+  return maxminSystem_->modified_set_;
+}
+
 double Model::nextOccuringEvent(double now)
 {
   // FIXME: set the good function once and for all
@@ -45,13 +49,13 @@ double Model::nextOccuringEvent(double now)
 
 double Model::nextOccuringEventLazy(double now)
 {
-  XBT_DEBUG("Before share resources, the size of modified actions set is %zu", modifiedSet_->size());
+  XBT_DEBUG("Before share resources, the size of modified actions set is %zu", maxminSystem_->modified_set_->size());
   lmm_solve(maxminSystem_);
-  XBT_DEBUG("After share resources, The size of modified actions set is %zu", modifiedSet_->size());
+  XBT_DEBUG("After share resources, The size of modified actions set is %zu", maxminSystem_->modified_set_->size());
 
-  while (not modifiedSet_->empty()) {
-    Action* action = &(modifiedSet_->front());
-    modifiedSet_->pop_front();
+  while (not maxminSystem_->modified_set_->empty()) {
+    Action* action = &(maxminSystem_->modified_set_->front());
+    maxminSystem_->modified_set_->pop_front();
     bool max_dur_flag = false;
 
     if (action->getStateSet() != runningActionSet_)
index de2b88e..3e41647 100644 (file)
@@ -53,10 +53,8 @@ CpuCas01Model::CpuCas01Model() : simgrid::surf::CpuModel()
 
   maxminSystem_ = new simgrid::kernel::lmm::System(select);
 
-  if (getUpdateMechanism() == UM_LAZY) {
-    modifiedSet_              = new kernel::resource::ActionLmmList();
-    maxminSystem_->keep_track = modifiedSet_;
-  }
+  if (getUpdateMechanism() == UM_LAZY)
+    maxminSystem_->modified_set_ = new kernel::resource::ActionLmmList();
 }
 
 CpuCas01Model::~CpuCas01Model()
index 05778dc..44d21c9 100644 (file)
@@ -154,10 +154,8 @@ NetworkCm02Model::NetworkCm02Model()
   maxminSystem_ = new simgrid::kernel::lmm::System(select);
   loopback_     = NetworkCm02Model::createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);
 
-  if (getUpdateMechanism() == UM_LAZY) {
-    modifiedSet_              = new kernel::resource::ActionLmmList();
-    maxminSystem_->keep_track = modifiedSet_;
-  }
+  if (getUpdateMechanism() == UM_LAZY)
+    maxminSystem_->modified_set_ = new kernel::resource::ActionLmmList();
 }
 
 NetworkCm02Model::NetworkCm02Model(void (*specificSolveFun)(lmm_system_t self)) : NetworkCm02Model()