Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Uniform treatment in EngineImpl for all models.
authorBruno Donassolo <bruno.donassolo@inria.fr>
Wed, 10 Mar 2021 14:09:35 +0000 (15:09 +0100)
committerBruno Donassolo <bruno.donassolo@inria.fr>
Wed, 10 Mar 2021 16:24:22 +0000 (17:24 +0100)
Override the update_action_state function in CPUL07 and LinkL07, they
are not necessary since the actions are updated by the HostL07Model, but
they allow to make the same treatment for all models.

src/kernel/EngineImpl.cpp
src/kernel/EngineImpl.hpp
src/surf/ptask_L07.cpp
src/surf/ptask_L07.hpp

index dc0e524..b4f0c4f 100644 (file)
@@ -53,17 +53,13 @@ void EngineImpl::register_default(const actor::ActorCodeFactory& code)
   default_function = code;
 }
 
-void EngineImpl::add_model_ptask(resource::Model::Type type, resource::Model* model, bool is_default)
+void EngineImpl::add_model(resource::Model::Type type, std::shared_ptr<resource::Model> model, bool is_default)
 {
   if (is_default)
-    models_by_type_[type].insert(models_by_type_[type].begin(), model);
+    models_by_type_[type].insert(models_by_type_[type].begin(), model.get());
   else
-    models_by_type_[type].push_back(model);
-}
+    models_by_type_[type].push_back(model.get());
 
-void EngineImpl::add_model(resource::Model::Type type, std::shared_ptr<resource::Model> model, bool is_default)
-{
-  add_model_ptask(type, model.get(), is_default);
   models_.push_back(std::move(model));
 }
 
index 1a12c38..deb5664 100644 (file)
@@ -48,16 +48,6 @@ public:
    * @param is_default Is this the default model for this type of resource in this exp
    */
   void add_model(resource::Model::Type type, std::shared_ptr<resource::Model> model, bool is_default = false);
-  /**
-   * @brief Add a model (specific for ptask)
-   *
-   * Ptask is special. The CPU and NETWORK models need to be in the managed
-   * resources by surf_solve (model_by_type) but cannot be in the list of
-   * all models (old all_existing_models global variable)
-   *
-   * This methods does this job while we cannot handle ptask as the remaining models
-   */
-  void add_model_ptask(resource::Model::Type type, resource::Model* model, bool is_default);
   /** @brief Get current default model for a resource type */
   resource::Model* get_default_model(resource::Model::Type type) const;
 
index 20a97a0..2eb2254 100644 (file)
@@ -34,12 +34,12 @@ HostL07Model::HostL07Model() : HostModel()
   auto* maxmin_system = new simgrid::kernel::lmm::FairBottleneck(true /* selective update */);
   set_maxmin_system(maxmin_system);
 
-  net_model_  = std::make_unique<NetworkL07Model>(this, maxmin_system);
-  auto engine = simgrid::kernel::EngineImpl::get_instance();
-  engine->add_model_ptask(simgrid::kernel::resource::Model::Type::NETWORK, net_model_.get(), true);
+  auto net_model = std::make_shared<NetworkL07Model>(this, maxmin_system);
+  auto engine    = simgrid::kernel::EngineImpl::get_instance();
+  engine->add_model(simgrid::kernel::resource::Model::Type::NETWORK, std::move(net_model), true);
 
-  cpu_model_ = std::make_unique<CpuL07Model>(this, maxmin_system);
-  engine->add_model_ptask(simgrid::kernel::resource::Model::Type::CPU_PM, cpu_model_.get(), true);
+  auto cpu_model = std::make_shared<CpuL07Model>(this, maxmin_system);
+  engine->add_model(simgrid::kernel::resource::Model::Type::CPU_PM, std::move(cpu_model), true);
 }
 
 HostL07Model::~HostL07Model() {}
index fe5fe36..a2192e1 100644 (file)
@@ -44,10 +44,6 @@ public:
   void update_actions_state(double now, double delta) override;
   kernel::resource::CpuAction* execute_parallel(const std::vector<s4u::Host*>& host_list, const double* flops_amount,
                                                 const double* bytes_amount, double rate) override;
-
-private:
-  std::unique_ptr<NetworkL07Model> net_model_;
-  std::unique_ptr<CpuL07Model> cpu_model_;
 };
 
 class CpuL07Model : public kernel::resource::CpuModel {
@@ -56,6 +52,10 @@ public:
   CpuL07Model(const CpuL07Model&) = delete;
   CpuL07Model& operator=(const CpuL07Model&) = delete;
   ~CpuL07Model() override;
+  /* this action is done by HostL07Model which shares the LMM system with the CPU model
+   * Overriding to an empty function here allows us to handle the Cpu07Model as a regular
+   * method in surf_presolve */
+  void update_actions_state(double now, double delta) override{};
 
   kernel::resource::Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
   HostL07Model* hostModel_;
@@ -71,6 +71,10 @@ public:
                                           s4u::Link::SharingPolicy policy) override;
 
   kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
+  /* this action is done by HostL07Model which shares the LMM system with the CPU model
+   * Overriding to an empty function here allows us to handle the Cpu07Model as a regular
+   * method in surf_presolve */
+  void update_actions_state(double now, double delta) override{};
 
   HostL07Model* hostModel_;
 };