From 6e4e5d88c59b12e37b1e49cebf23e50af6482b6a Mon Sep 17 00:00:00 2001 From: Bruno Donassolo Date: Tue, 9 Mar 2021 20:04:53 +0100 Subject: [PATCH] Engine*::add_model: from unique to shared_ptr --- include/simgrid/s4u/Engine.hpp | 2 +- src/kernel/EngineImpl.cpp | 2 +- src/kernel/EngineImpl.hpp | 6 +++--- src/plugins/vm/VirtualMachineImpl.cpp | 2 +- src/s4u/s4u_Engine.cpp | 2 +- src/surf/cpu_cas01.cpp | 4 ++-- src/surf/cpu_ti.cpp | 4 ++-- src/surf/disk_s19.cpp | 2 +- src/surf/host_clm03.cpp | 4 ++-- src/surf/network_cm02.cpp | 4 ++-- src/surf/network_constant.cpp | 2 +- src/surf/network_ib.cpp | 2 +- src/surf/network_ns3.cpp | 2 +- src/surf/network_smpi.cpp | 2 +- src/surf/ptask_L07.cpp | 2 +- 15 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/simgrid/s4u/Engine.hpp b/include/simgrid/s4u/Engine.hpp index d293c9f5f1..30ecfd2646 100644 --- a/include/simgrid/s4u/Engine.hpp +++ b/include/simgrid/s4u/Engine.hpp @@ -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 model); + void add_model(simgrid::kernel::resource::Model::Type type, std::shared_ptr model); /** @brief Retrieves all netzones of the type indicated by the template argument */ template std::vector get_filtered_netzones() const diff --git a/src/kernel/EngineImpl.cpp b/src/kernel/EngineImpl.cpp index b6b12995d3..c7f1443b67 100644 --- a/src/kernel/EngineImpl.cpp +++ b/src/kernel/EngineImpl.cpp @@ -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 model, bool is_default) +void EngineImpl::add_model(resource::Model::Type type, std::shared_ptr model, bool is_default) { add_model_ptask(type, model.get(), is_default); models_.push_back(std::move(model)); diff --git a/src/kernel/EngineImpl.hpp b/src/kernel/EngineImpl.hpp index 98b76d59be..f770aae282 100644 --- a/src/kernel/EngineImpl.hpp +++ b/src/kernel/EngineImpl.hpp @@ -24,7 +24,7 @@ class EngineImpl { std::unordered_map netpoints_; std::unordered_map 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> models_; + std::vector> models_; std::unordered_map> 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 model, bool is_default = false); + void add_model(resource::Model::Type type, std::shared_ptr 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& 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>& get_all_models() { return models_; } + const std::vector>& get_all_models() { return models_; } routing::NetZoneImpl* netzone_root_ = nullptr; static EngineImpl* get_instance() { return simgrid::s4u::Engine::get_instance()->pimpl; } diff --git a/src/plugins/vm/VirtualMachineImpl.cpp b/src/plugins/vm/VirtualMachineImpl.cpp index 371bff41de..9634c6fc11 100644 --- a/src/plugins/vm/VirtualMachineImpl.cpp +++ b/src/plugins/vm/VirtualMachineImpl.cpp @@ -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(); + auto vm_model = std::make_shared(); simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::VM, std::move(vm_model), true); } diff --git a/src/s4u/s4u_Engine.cpp b/src/s4u/s4u_Engine.cpp index 6bc9b005a1..24502707f1 100644 --- a/src/s4u/s4u_Engine.cpp +++ b/src/s4u/s4u_Engine.cpp @@ -74,7 +74,7 @@ double Engine::get_clock() } void Engine::add_model(simgrid::kernel::resource::Model::Type type, - std::unique_ptr model) + std::shared_ptr model) { simgrid::kernel::actor::simcall([this, type, &model] { pimpl->add_model(type, std::move(model)); }); } diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 56e70a743e..4b535e1ad3 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -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(algo); + auto cpu_model_pm = std::make_shared(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(algo); + auto cpu_model_vm = std::make_shared(algo); simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::CPU_VM, std::move(cpu_model_vm), true); } diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 5c24e9a55c..1316a0f782 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -270,10 +270,10 @@ int CpuTiProfile::binary_search(const std::vector& array, double a) void CpuTiModel::create_pm_vm_models() { - auto cpu_model_pm = std::make_unique(); + auto cpu_model_pm = std::make_shared(); 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(); + auto cpu_model_vm = std::make_shared(); simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::CPU_VM, std::move(cpu_model_vm), true); } diff --git a/src/surf/disk_s19.cpp b/src/surf/disk_s19.cpp index 12722e7957..5735522a9e 100644 --- a/src/surf/disk_s19.cpp +++ b/src/surf/disk_s19.cpp @@ -20,7 +20,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_disk); void surf_disk_model_init_default() { - auto disk_model = std::make_unique(); + auto disk_model = std::make_shared(); simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::DISK, std::move(disk_model), true); } diff --git a/src/surf/host_clm03.cpp b/src/surf/host_clm03.cpp index c9bb4c50ad..ed428d47de 100644 --- a/src/surf/host_clm03.cpp +++ b/src/surf/host_clm03.cpp @@ -13,7 +13,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_host); void surf_host_model_init_current_default() { - auto host_model = std::make_unique(); + auto host_model = std::make_shared(); simgrid::config::set_default("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(); + auto host_model = std::make_shared(); simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::HOST, std::move(host_model), true); } diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 57600aea49..856bc11cfb 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -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(); + auto net_model = std::make_shared(); 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("network/bandwidth-factor", 1.0); simgrid::config::set_default("network/weight-S", 0.0); - auto net_model = std::make_unique(); + auto net_model = std::make_shared(); simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK, std::move(net_model), true); } diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index 7c879c8a06..2fc20ce822 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -15,7 +15,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network); *********/ void surf_network_model_init_Constant() { - auto net_model = std::make_unique(); + auto net_model = std::make_shared(); simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK, std::move(net_model), true); } diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index eedd4594eb..6bd014af13 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -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(); + auto net_model = std::make_shared(); simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK, std::move(net_model), true); diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index 8ba3f2ea52..dc283e27d1 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -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(); + auto net_model = std::make_shared(); simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK, std::move(net_model), true); } diff --git a/src/surf/network_smpi.cpp b/src/surf/network_smpi.cpp index 0b03bd9d4e..72e8c02f27 100644 --- a/src/surf/network_smpi.cpp +++ b/src/surf/network_smpi.cpp @@ -33,7 +33,7 @@ std::vector smpi_lat_factor; /* } */ void surf_network_model_init_SMPI() { - auto net_model = std::make_unique(); + auto net_model = std::make_shared(); simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::NETWORK, std::move(net_model), true); diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index de75a275e1..20a97a0003 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -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(); + auto host_model = std::make_shared(); simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::HOST, std::move(host_model), true); } -- 2.20.1