Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Engine*::add_model: from unique to shared_ptr
authorBruno Donassolo <bruno.donassolo@inria.fr>
Tue, 9 Mar 2021 19:04:53 +0000 (20:04 +0100)
committerBruno Donassolo <bruno.donassolo@inria.fr>
Tue, 9 Mar 2021 19:04:53 +0000 (20:04 +0100)
15 files changed:
include/simgrid/s4u/Engine.hpp
src/kernel/EngineImpl.cpp
src/kernel/EngineImpl.hpp
src/plugins/vm/VirtualMachineImpl.cpp
src/s4u/s4u_Engine.cpp
src/surf/cpu_cas01.cpp
src/surf/cpu_ti.cpp
src/surf/disk_s19.cpp
src/surf/host_clm03.cpp
src/surf/network_cm02.cpp
src/surf/network_constant.cpp
src/surf/network_ib.cpp
src/surf/network_ns3.cpp
src/surf/network_smpi.cpp
src/surf/ptask_L07.cpp

index d293c9f..30ecfd2 100644 (file)
@@ -136,7 +136,7 @@ public:
    * @param type Model type (network, disk, etc)
    * @param model Pointer to model
    */
-  void add_model(simgrid::kernel::resource::Model::Type type, std::unique_ptr<simgrid::kernel::resource::Model> model);
+  void add_model(simgrid::kernel::resource::Model::Type type, std::shared_ptr<simgrid::kernel::resource::Model> model);
 
   /** @brief Retrieves all netzones of the type indicated by the template argument */
   template <class T> std::vector<T*> get_filtered_netzones() const
index b6b1299..c7f1443 100644 (file)
@@ -61,7 +61,7 @@ void EngineImpl::add_model_ptask(resource::Model::Type type, resource::Model* mo
     models_by_type_[type].push_back(model);
 }
 
-void EngineImpl::add_model(resource::Model::Type type, std::unique_ptr<resource::Model> model, bool is_default)
+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 98b76d5..f770aae 100644 (file)
@@ -24,7 +24,7 @@ class EngineImpl {
   std::unordered_map<std::string, routing::NetPoint*> netpoints_;
   std::unordered_map<std::string, actor::ActorCodeFactory> registered_functions; // Maps function names to actor code
   actor::ActorCodeFactory default_function; // Function to use as a fallback when the provided name matches nothing
-  std::vector<std::unique_ptr<resource::Model>> models_;
+  std::vector<std::shared_ptr<resource::Model>> models_;
   std::unordered_map<resource::Model::Type, std::vector<resource::Model*>> models_by_type_;
 
   friend s4u::Engine;
@@ -47,7 +47,7 @@ public:
    * @param model Pointer to model
    * @param is_default Is this the default model for this type of resource in this exp
    */
-  void add_model(resource::Model::Type type, std::unique_ptr<resource::Model> model, bool is_default = false);
+  void add_model(resource::Model::Type type, std::shared_ptr<resource::Model> model, bool is_default = false);
   /**
    * @brief Add a model (specific for ptask)
    *
@@ -64,7 +64,7 @@ public:
   /** @brief Get list of models created for a resource type */
   const std::vector<resource::Model*>& get_model_list(resource::Model::Type type) { return models_by_type_[type]; }
   /** @brief Get list of all models managed by this engine */
-  const std::vector<std::unique_ptr<resource::Model>>& get_all_models() { return models_; }
+  const std::vector<std::shared_ptr<resource::Model>>& get_all_models() { return models_; }
 
   routing::NetZoneImpl* netzone_root_ = nullptr;
   static EngineImpl* get_instance() { return simgrid::s4u::Engine::get_instance()->pimpl; }
index 371bff4..9634c6f 100644 (file)
@@ -14,7 +14,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_vm, ker_resource, "Virtual Machines, contain
 
 void surf_vm_model_init_HL13()
 {
-  auto vm_model = std::make_unique<simgrid::vm::VMModel>();
+  auto vm_model = std::make_shared<simgrid::vm::VMModel>();
   simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::VM,
                                                          std::move(vm_model), true);
 }
index 6bc9b00..2450270 100644 (file)
@@ -74,7 +74,7 @@ double Engine::get_clock()
 }
 
 void Engine::add_model(simgrid::kernel::resource::Model::Type type,
-                       std::unique_ptr<simgrid::kernel::resource::Model> model)
+                       std::shared_ptr<simgrid::kernel::resource::Model> model)
 {
   simgrid::kernel::actor::simcall([this, type, &model] { pimpl->add_model(type, std::move(model)); });
 }
index 56e70a7..4b535e1 100644 (file)
@@ -48,10 +48,10 @@ void surf_cpu_model_init_Cas01()
   else
     algo = simgrid::kernel::resource::Model::UpdateAlgo::FULL;
 
-  auto cpu_model_pm = std::make_unique<simgrid::kernel::resource::CpuCas01Model>(algo);
+  auto cpu_model_pm = std::make_shared<simgrid::kernel::resource::CpuCas01Model>(algo);
   simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::CPU_PM,
                                                          std::move(cpu_model_pm), true);
-  auto cpu_model_vm = std::make_unique<simgrid::kernel::resource::CpuCas01Model>(algo);
+  auto cpu_model_vm = std::make_shared<simgrid::kernel::resource::CpuCas01Model>(algo);
   simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::CPU_VM,
                                                          std::move(cpu_model_vm), true);
 }
index 5c24e9a..1316a0f 100644 (file)
@@ -270,10 +270,10 @@ int CpuTiProfile::binary_search(const std::vector<double>& array, double a)
 
 void CpuTiModel::create_pm_vm_models()
 {
-  auto cpu_model_pm = std::make_unique<CpuTiModel>();
+  auto cpu_model_pm = std::make_shared<CpuTiModel>();
   simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::CPU_PM,
                                                          std::move(cpu_model_pm), true);
-  auto cpu_model_vm = std::make_unique<CpuTiModel>();
+  auto cpu_model_vm = std::make_shared<CpuTiModel>();
   simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::CPU_VM,
                                                          std::move(cpu_model_vm), true);
 }
index 12722e7..5735522 100644 (file)
@@ -20,7 +20,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_disk);
 
 void surf_disk_model_init_default()
 {
-  auto disk_model = std::make_unique<simgrid::kernel::resource::DiskS19Model>();
+  auto disk_model = std::make_shared<simgrid::kernel::resource::DiskS19Model>();
   simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::DISK,
                                                          std::move(disk_model), true);
 }
index c9bb4c5..ed428d4 100644 (file)
@@ -13,7 +13,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_host);
 
 void surf_host_model_init_current_default()
 {
-  auto host_model = std::make_unique<simgrid::surf::HostCLM03Model>();
+  auto host_model = std::make_shared<simgrid::surf::HostCLM03Model>();
   simgrid::config::set_default<bool>("network/crosstraffic", true);
   simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::HOST,
                                                          std::move(host_model), true);
@@ -23,7 +23,7 @@ void surf_host_model_init_current_default()
 
 void surf_host_model_init_compound()
 {
-  auto host_model = std::make_unique<simgrid::surf::HostCLM03Model>();
+  auto host_model = std::make_shared<simgrid::surf::HostCLM03Model>();
   simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::HOST,
                                                          std::move(host_model), true);
 }
index 57600ae..856bc11 100644 (file)
@@ -37,7 +37,7 @@ double sg_weight_S_parameter = 0.0; /* default value; can be set by model or fro
 /*  } */
 void surf_network_model_init_LegrandVelho()
 {
-  auto net_model = std::make_unique<simgrid::kernel::resource::NetworkCm02Model>();
+  auto net_model = std::make_shared<simgrid::kernel::resource::NetworkCm02Model>();
   simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK,
                                                          std::move(net_model), true);
 
@@ -63,7 +63,7 @@ void surf_network_model_init_CM02()
   simgrid::config::set_default<double>("network/bandwidth-factor", 1.0);
   simgrid::config::set_default<double>("network/weight-S", 0.0);
 
-  auto net_model = std::make_unique<simgrid::kernel::resource::NetworkCm02Model>();
+  auto net_model = std::make_shared<simgrid::kernel::resource::NetworkCm02Model>();
   simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK,
                                                          std::move(net_model), true);
 }
index 7c879c8..2fc20ce 100644 (file)
@@ -15,7 +15,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network);
  *********/
 void surf_network_model_init_Constant()
 {
-  auto net_model = std::make_unique<simgrid::kernel::resource::NetworkConstantModel>();
+  auto net_model = std::make_shared<simgrid::kernel::resource::NetworkConstantModel>();
   simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK,
                                                          std::move(net_model), true);
 }
index eedd459..6bd014a 100644 (file)
@@ -69,7 +69,7 @@ static void IB_action_init_callback(simgrid::kernel::resource::NetworkAction& ac
 /*  } */
 void surf_network_model_init_IB()
 {
-  auto net_model = std::make_unique<simgrid::kernel::resource::NetworkIBModel>();
+  auto net_model = std::make_shared<simgrid::kernel::resource::NetworkIBModel>();
   simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK,
                                                          std::move(net_model), true);
 
index 8ba3f2e..dc283e2 100644 (file)
@@ -259,7 +259,7 @@ static void routeCreation_cb(bool symmetrical, simgrid::kernel::routing::NetPoin
  *********/
 void surf_network_model_init_NS3()
 {
-  auto net_model = std::make_unique<simgrid::kernel::resource::NetworkNS3Model>();
+  auto net_model = std::make_shared<simgrid::kernel::resource::NetworkNS3Model>();
   simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK,
                                                          std::move(net_model), true);
 }
index 0b03bd9..72e8c02 100644 (file)
@@ -33,7 +33,7 @@ std::vector<s_smpi_factor_t> smpi_lat_factor;
 /*  } */
 void surf_network_model_init_SMPI()
 {
-  auto net_model = std::make_unique<simgrid::kernel::resource::NetworkSmpiModel>();
+  auto net_model = std::make_shared<simgrid::kernel::resource::NetworkSmpiModel>();
   simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK,
                                                          std::move(net_model), true);
 
index de75a27..20a97a0 100644 (file)
@@ -21,7 +21,7 @@ void surf_host_model_init_ptask_L07()
 {
   XBT_CINFO(xbt_cfg, "Switching to the L07 model to handle parallel tasks.");
 
-  auto host_model = std::make_unique<simgrid::surf::HostL07Model>();
+  auto host_model = std::make_shared<simgrid::surf::HostL07Model>();
   simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::HOST,
                                                          std::move(host_model), true);
 }