Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
make Model::update_algo a constant field, set at initialization only
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 31 Mar 2018 20:48:24 +0000 (22:48 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 31 Mar 2018 20:50:27 +0000 (22:50 +0200)
12 files changed:
include/simgrid/kernel/resource/Model.hpp
src/kernel/resource/Model.cpp
src/surf/HostImpl.hpp
src/surf/StorageImpl.cpp
src/surf/cpu_cas01.hpp
src/surf/cpu_interface.hpp
src/surf/cpu_ti.hpp
src/surf/network_cm02.cpp
src/surf/network_constant.hpp
src/surf/network_interface.hpp
src/surf/network_ns3.cpp
src/surf/ptask_L07.cpp

index b803d87..83076be 100644 (file)
@@ -20,16 +20,14 @@ class XBT_PUBLIC Model {
 public:
   /** @brief Possible update mechanisms */
   enum class UpdateAlgo {
 public:
   /** @brief Possible update mechanisms */
   enum class UpdateAlgo {
-    Full,     /**< Full update mechanism: the remaining time of every action is recomputed at each step */
-    Lazy,     /**< Lazy update mechanism: only the modified actions get recomputed.
-                      It may be slower than full if your system is tightly coupled to the point where every action
-                      gets recomputed anyway. In that case, you'd better not try to be cleaver with lazy and go for
-                      a simple full update.  */
-    Undefined /**< Mechanism not defined */
+    Full, /**< Full update mechanism: the remaining time of every action is recomputed at each step */
+    Lazy  /**< Lazy update mechanism: only the modified actions get recomputed.
+                   It may be slower than full if your system is tightly coupled to the point where every action
+                   gets recomputed anyway. In that case, you'd better not try to be cleaver with lazy and go for
+                   a simple full update.  */
   };
 
   };
 
-  Model();
-  Model(Model::UpdateAlgo algo);
+  explicit Model(Model::UpdateAlgo algo);
 
   virtual ~Model();
 
 
   virtual ~Model();
 
@@ -55,8 +53,7 @@ public:
   void set_maxmin_system(lmm::System* system) { maxmin_system_ = system; }
 
   /** @brief Get the update mechanism 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_mechanism_; }
-  void setUpdateMechanism(UpdateAlgo mechanism) { update_mechanism_ = mechanism; }
+  UpdateAlgo getUpdateMechanism() const { return update_algorithm_; }
 
   /** @brief Get Action heap */
   heap_type& getActionHeap() { return action_heap_; }
 
   /** @brief Get Action heap */
   heap_type& getActionHeap() { return action_heap_; }
@@ -94,7 +91,7 @@ public:
 
 private:
   lmm::System* maxmin_system_           = nullptr;
 
 private:
   lmm::System* maxmin_system_           = nullptr;
-  UpdateAlgo update_mechanism_          = UpdateAlgo::Undefined;
+  const UpdateAlgo update_algorithm_;
   Action::StateSet* ready_action_set_   = new Action::StateSet(); /**< Actions in state SURF_ACTION_READY */
   Action::StateSet* running_action_set_ = new Action::StateSet(); /**< Actions in state SURF_ACTION_RUNNING */
   Action::StateSet* failed_action_set_  = new Action::StateSet(); /**< Actions in state SURF_ACTION_FAILED */
   Action::StateSet* ready_action_set_   = new Action::StateSet(); /**< Actions in state SURF_ACTION_READY */
   Action::StateSet* running_action_set_ = new Action::StateSet(); /**< Actions in state SURF_ACTION_RUNNING */
   Action::StateSet* failed_action_set_  = new Action::StateSet(); /**< Actions in state SURF_ACTION_FAILED */
index e463d99..ee43169 100644 (file)
@@ -12,8 +12,7 @@ namespace simgrid {
 namespace kernel {
 namespace resource {
 
 namespace kernel {
 namespace resource {
 
-Model::Model() = default;
-Model::Model(Model::UpdateAlgo algo) : update_mechanism_(algo) {}
+Model::Model(Model::UpdateAlgo algo) : update_algorithm_(algo) {}
 
 Model::~Model()
 {
 
 Model::~Model()
 {
@@ -40,9 +39,9 @@ Action::ModifiedSet* Model::get_modified_set() const
 double Model::next_occuring_event(double now)
 {
   // FIXME: set the good function once and for all
 double Model::next_occuring_event(double now)
 {
   // FIXME: set the good function once and for all
-  if (update_mechanism_ == Model::UpdateAlgo::Lazy)
+  if (update_algorithm_ == Model::UpdateAlgo::Lazy)
     return next_occuring_event_lazy(now);
     return next_occuring_event_lazy(now);
-  else if (update_mechanism_ == Model::UpdateAlgo::Full)
+  else if (update_algorithm_ == Model::UpdateAlgo::Full)
     return next_occuring_event_full(now);
   else
     xbt_die("Invalid cpu update mechanism!");
     return next_occuring_event_full(now);
   else
     xbt_die("Invalid cpu update mechanism!");
@@ -141,9 +140,9 @@ double Model::next_occuring_event_full(double /*now*/)
 
 void Model::update_actions_state(double now, double delta)
 {
 
 void Model::update_actions_state(double now, double delta)
 {
-  if (update_mechanism_ == Model::UpdateAlgo::Full)
+  if (update_algorithm_ == Model::UpdateAlgo::Full)
     update_actions_state_full(now, delta);
     update_actions_state_full(now, delta);
-  else if (update_mechanism_ == Model::UpdateAlgo::Lazy)
+  else if (update_algorithm_ == Model::UpdateAlgo::Lazy)
     update_actions_state_lazy(now, delta);
   else
     xbt_die("Invalid cpu update mechanism!");
     update_actions_state_lazy(now, delta);
   else
     xbt_die("Invalid cpu update mechanism!");
index 85db47a..02b40c4 100644 (file)
@@ -33,7 +33,7 @@ namespace surf {
  */
 class XBT_PRIVATE HostModel : public kernel::resource::Model {
 public:
  */
 class XBT_PRIVATE HostModel : public kernel::resource::Model {
 public:
-  HostModel() : Model() {}
+  HostModel() : Model(Model::UpdateAlgo::Full) {}
 
   virtual void ignore_empty_vm_in_pm_LMM();
   virtual kernel::resource::Action* execute_parallel(int host_nb, sg_host_t* host_list, double* flops_amount,
 
   virtual void ignore_empty_vm_in_pm_LMM();
   virtual kernel::resource::Action* execute_parallel(int host_nb, sg_host_t* host_list, double* flops_amount,
index 4d4d01a..2916346 100644 (file)
@@ -30,7 +30,7 @@ simgrid::xbt::signal<void(StorageAction*, kernel::resource::Action::State, kerne
  * Model *
  *********/
 
  * Model *
  *********/
 
-StorageModel::StorageModel() : Model()
+StorageModel::StorageModel() : Model(Model::UpdateAlgo::Full)
 {
   set_maxmin_system(new simgrid::kernel::lmm::System(true /* selective update */));
 }
 {
   set_maxmin_system(new simgrid::kernel::lmm::System(true /* selective update */));
 }
index 3671bd8..ae104a0 100644 (file)
@@ -24,7 +24,7 @@ class XBT_PRIVATE CpuCas01Action;
 
 class CpuCas01Model : public simgrid::surf::CpuModel {
 public:
 
 class CpuCas01Model : public simgrid::surf::CpuModel {
 public:
-  CpuCas01Model(kernel::resource::Model::UpdateAlgo algo);
+  explicit CpuCas01Model(kernel::resource::Model::UpdateAlgo algo);
   ~CpuCas01Model() override;
 
   Cpu *createCpu(simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core) override;
   ~CpuCas01Model() override;
 
   Cpu *createCpu(simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core) override;
index 00d095c..81a9cb7 100644 (file)
@@ -26,8 +26,7 @@ namespace surf {
  */
 class XBT_PUBLIC CpuModel : public kernel::resource::Model {
 public:
  */
 class XBT_PUBLIC CpuModel : public kernel::resource::Model {
 public:
-  CpuModel(kernel::resource::Model::UpdateAlgo algo) : Model(algo) {}
-  CpuModel() : Model() {}
+  explicit CpuModel(kernel::resource::Model::UpdateAlgo algo) : Model(algo) {}
 
   /**
    * @brief Create a Cpu
 
   /**
    * @brief Create a Cpu
index 982727d..df6c050 100644 (file)
@@ -139,7 +139,7 @@ typedef boost::intrusive::list<CpuTi, CpuTiListOptions> CpuTiList;
  *********/
 class CpuTiModel : public CpuModel {
 public:
  *********/
 class CpuTiModel : public CpuModel {
 public:
-  CpuTiModel() = default;
+  CpuTiModel() : CpuModel(Model::UpdateAlgo::Full){};
   ~CpuTiModel() override;
   Cpu* createCpu(simgrid::s4u::Host* host, std::vector<double>* speed_per_pstate, int core) override;
   double next_occuring_event(double now) override;
   ~CpuTiModel() override;
   Cpu* createCpu(simgrid::s4u::Host* host, std::vector<double>* speed_per_pstate, int core) override;
   double next_occuring_event(double now) override;
index 41a9f4b..aa9df6d 100644 (file)
@@ -134,20 +134,17 @@ void surf_network_model_init_Vegas()
 namespace simgrid {
 namespace surf {
 
 namespace simgrid {
 namespace surf {
 
-NetworkCm02Model::NetworkCm02Model(kernel::lmm::System* (*make_new_lmm_system)(bool)) : NetworkModel()
+NetworkCm02Model::NetworkCm02Model(kernel::lmm::System* (*make_new_lmm_system)(bool))
+    : NetworkModel(xbt_cfg_get_string("network/optim") == "Full" ? kernel::resource::Model::UpdateAlgo::Full
+                                                                 : kernel::resource::Model::UpdateAlgo::Lazy)
 {
   std::string optim = xbt_cfg_get_string("network/optim");
   bool select = xbt_cfg_get_boolean("network/maxmin-selective-update");
 
 {
   std::string optim = xbt_cfg_get_string("network/optim");
   bool select = xbt_cfg_get_boolean("network/maxmin-selective-update");
 
-  if (optim == "Full") {
-    setUpdateMechanism(kernel::resource::Model::UpdateAlgo::Full);
-  } else if (optim == "Lazy") {
+  if (optim == "Lazy") {
     xbt_assert(select || xbt_cfg_is_default_value("network/maxmin-selective-update"),
                "You cannot disable network selective update when using the lazy update mechanism");
     select = true;
     xbt_assert(select || xbt_cfg_is_default_value("network/maxmin-selective-update"),
                "You cannot disable network selective update when using the lazy update mechanism");
     select = true;
-    setUpdateMechanism(kernel::resource::Model::UpdateAlgo::Lazy);
-  } else {
-    xbt_die("Unsupported optimization (%s) for this model. Accepted: Full, Lazy.", optim.c_str());
   }
 
   set_maxmin_system(make_new_lmm_system(select));
   }
 
   set_maxmin_system(make_new_lmm_system(select));
index 23c37ac..151b2d0 100644 (file)
@@ -25,6 +25,7 @@ namespace simgrid {
      *********/
     class NetworkConstantModel : public NetworkModel {
     public:
      *********/
     class NetworkConstantModel : public NetworkModel {
     public:
+      NetworkConstantModel() : NetworkModel(Model::UpdateAlgo::Full) {}
       kernel::resource::Action* communicate(simgrid::s4u::Host* src, simgrid::s4u::Host* dst, double size,
                                             double rate) override;
       double next_occuring_event(double now) override;
       kernel::resource::Action* communicate(simgrid::s4u::Host* src, simgrid::s4u::Host* dst, double size,
                                             double rate) override;
       double next_occuring_event(double now) override;
index c26d753..a04496e 100644 (file)
@@ -34,7 +34,7 @@ namespace surf {
 class NetworkModel : public kernel::resource::Model {
 public:
   /** @brief Constructor */
 class NetworkModel : public kernel::resource::Model {
 public:
   /** @brief Constructor */
-  NetworkModel() : Model() {}
+  explicit NetworkModel(kernel::resource::Model::UpdateAlgo algo) : Model(algo) {}
 
   /** @brief Destructor */
   ~NetworkModel() override;
 
   /** @brief Destructor */
   ~NetworkModel() override;
index f1ddedf..f133055 100644 (file)
@@ -147,7 +147,8 @@ static simgrid::config::Flag<std::string>
 namespace simgrid {
 namespace surf {
 
 namespace simgrid {
 namespace surf {
 
-NetworkNS3Model::NetworkNS3Model() : NetworkModel() {
+NetworkNS3Model::NetworkNS3Model() : NetworkModel(Model::UpdateAlgo::Full)
+{
   xbt_assert(not sg_link_energy_is_inited(),
              "LinkEnergy plugin and NS3 network models are not compatible. Are you looking for Ecofen, maybe?");
 
   xbt_assert(not sg_link_energy_is_inited(),
              "LinkEnergy plugin and NS3 network models are not compatible. Are you looking for Ecofen, maybe?");
 
index 2a348a9..d0c47f5 100644 (file)
@@ -46,7 +46,8 @@ HostL07Model::~HostL07Model()
   delete surf_cpu_model_pm;
 }
 
   delete surf_cpu_model_pm;
 }
 
-CpuL07Model::CpuL07Model(HostL07Model* hmodel, kernel::lmm::System* sys) : CpuModel(), hostModel_(hmodel)
+CpuL07Model::CpuL07Model(HostL07Model* hmodel, kernel::lmm::System* sys)
+    : CpuModel(Model::UpdateAlgo::Full), hostModel_(hmodel)
 {
   set_maxmin_system(sys);
 }
 {
   set_maxmin_system(sys);
 }
@@ -56,7 +57,8 @@ CpuL07Model::~CpuL07Model()
   set_maxmin_system(nullptr);
 }
 
   set_maxmin_system(nullptr);
 }
 
-NetworkL07Model::NetworkL07Model(HostL07Model* hmodel, kernel::lmm::System* sys) : NetworkModel(), hostModel_(hmodel)
+NetworkL07Model::NetworkL07Model(HostL07Model* hmodel, kernel::lmm::System* sys)
+    : NetworkModel(Model::UpdateAlgo::Full), hostModel_(hmodel)
 {
   set_maxmin_system(sys);
   loopback_     = NetworkL07Model::createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);
 {
   set_maxmin_system(sys);
   loopback_     = NetworkL07Model::createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);