Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
CpuCas01: set updateAlgo as initializer
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 30 Mar 2018 23:13:57 +0000 (01:13 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 30 Mar 2018 23:14:02 +0000 (01:14 +0200)
My goal here is to make updateAlgo a constant in each Model object.

include/simgrid/kernel/resource/Model.hpp
src/kernel/resource/Model.cpp
src/surf/cpu_cas01.cpp
src/surf/cpu_cas01.hpp
src/surf/cpu_interface.hpp
src/surf/cpu_ti.cpp

index 7703923..b803d87 100644 (file)
@@ -29,6 +29,8 @@ public:
   };
 
   Model();
   };
 
   Model();
+  Model(Model::UpdateAlgo algo);
+
   virtual ~Model();
 
   /** @brief Get the set of [actions](@ref Action) in *ready* state */
   virtual ~Model();
 
   /** @brief Get the set of [actions](@ref Action) in *ready* state */
@@ -52,10 +54,7 @@ public:
   /** @brief Set the maxmin system of the current Model */
   void set_maxmin_system(lmm::System* system) { maxmin_system_ = system; }
 
   /** @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
-   * @see e_UM_t
-   */
+  /** @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_mechanism_; }
   void setUpdateMechanism(UpdateAlgo mechanism) { update_mechanism_ = mechanism; }
 
index 5e73044..e463d99 100644 (file)
@@ -13,6 +13,7 @@ namespace kernel {
 namespace resource {
 
 Model::Model() = default;
 namespace resource {
 
 Model::Model() = default;
+Model::Model(Model::UpdateAlgo algo) : update_mechanism_(algo) {}
 
 Model::~Model()
 {
 
 Model::~Model()
 {
index 019d540..d9f5f14 100644 (file)
@@ -42,32 +42,35 @@ void surf_cpu_model_init_Cas01()
     return;
   }
 
     return;
   }
 
-  surf_cpu_model_pm = new simgrid::surf::CpuCas01Model(cpu_optim_opt == "Lazy");
+  simgrid::kernel::resource::Model::UpdateAlgo algo;
+  if (cpu_optim_opt == "Lazy")
+    algo = simgrid::kernel::resource::Model::UpdateAlgo::Lazy;
+  else
+    algo = simgrid::kernel::resource::Model::UpdateAlgo::Full;
+
+  surf_cpu_model_pm = new simgrid::surf::CpuCas01Model(algo);
   all_existing_models->push_back(surf_cpu_model_pm);
 
   all_existing_models->push_back(surf_cpu_model_pm);
 
-  surf_cpu_model_vm = new simgrid::surf::CpuCas01Model(cpu_optim_opt == "Lazy");
+  surf_cpu_model_vm = new simgrid::surf::CpuCas01Model(algo);
   all_existing_models->push_back(surf_cpu_model_vm);
 }
 
 namespace simgrid {
 namespace surf {
 
   all_existing_models->push_back(surf_cpu_model_vm);
 }
 
 namespace simgrid {
 namespace surf {
 
-CpuCas01Model::CpuCas01Model(bool optim_lazy) : simgrid::surf::CpuModel()
+CpuCas01Model::CpuCas01Model(kernel::resource::Model::UpdateAlgo algo) : simgrid::surf::CpuModel(algo)
 {
   bool select = xbt_cfg_get_boolean("cpu/maxmin-selective-update");
 
 {
   bool select = xbt_cfg_get_boolean("cpu/maxmin-selective-update");
 
-  if (optim_lazy) {
+  if (algo == Model::UpdateAlgo::Lazy) {
     xbt_assert(select || xbt_cfg_is_default_value("cpu/maxmin-selective-update"),
                "You cannot disable cpu selective update when using the lazy update mechanism");
     xbt_assert(select || xbt_cfg_is_default_value("cpu/maxmin-selective-update"),
                "You cannot disable cpu selective update when using the lazy update mechanism");
-    setUpdateMechanism(Model::UpdateAlgo::Lazy);
     select = true;
     select = true;
-  } else {
-    setUpdateMechanism(Model::UpdateAlgo::Full);
   }
 
   set_maxmin_system(new simgrid::kernel::lmm::System(select));
 
   }
 
   set_maxmin_system(new simgrid::kernel::lmm::System(select));
 
-  if (optim_lazy)
+  if (algo == Model::UpdateAlgo::Lazy)
     get_maxmin_system()->modified_set_ = new kernel::resource::Action::ModifiedSet();
 }
 
     get_maxmin_system()->modified_set_ = new kernel::resource::Action::ModifiedSet();
 }
 
index 7683a08..ba1f13d 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(bool optim_lazy);
+  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 375c1d7..72a99af 100644 (file)
@@ -26,6 +26,9 @@ 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() {}
+
   /**
    * @brief Create a Cpu
    *
   /**
    * @brief Create a Cpu
    *
index 4fc9b6c..c04b25a 100644 (file)
@@ -373,8 +373,7 @@ void CpuTiModel::update_actions_state(double now, double /*delta*/)
 CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core)
   : Cpu(model, host, speedPerPstate, core)
 {
 CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core)
   : Cpu(model, host, speedPerPstate, core)
 {
-  xbt_assert(core==1,"Multi-core not handled by this model yet");
-  coresAmount_ = core;
+  xbt_assert(core == 1, "Multi-core not handled by this model yet");
 
   speed_.peak = speedPerPstate->front();
   XBT_DEBUG("CPU create: peak=%f", speed_.peak);
 
   speed_.peak = speedPerPstate->front();
   XBT_DEBUG("CPU create: peak=%f", speed_.peak);