From 685040f3a8779f848f54d8bc8f8d1d1bf003a622 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 9 Jul 2018 01:32:22 +0200 Subject: [PATCH] prefer automatic mem handling (std::vector<>* becomes std::vector<>) --- include/simgrid/kernel/resource/Model.hpp | 2 +- src/plugins/vm/VirtualMachineImpl.cpp | 2 +- src/simdag/sd_global.cpp | 2 +- src/simix/smx_global.cpp | 2 +- src/surf/cpu_cas01.cpp | 4 ++-- src/surf/cpu_ti.cpp | 2 +- src/surf/host_clm03.cpp | 2 +- src/surf/network_cm02.cpp | 10 +++++----- 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 +- src/surf/storage_n11.cpp | 2 +- src/surf/surf_c_bindings.cpp | 6 +++--- src/surf/surf_interface.cpp | 7 ++----- teshsuite/surf/surf_usage2/surf_usage2.cpp | 2 +- 17 files changed, 25 insertions(+), 28 deletions(-) diff --git a/include/simgrid/kernel/resource/Model.hpp b/include/simgrid/kernel/resource/Model.hpp index ce391afc37..5985e4b49b 100644 --- a/include/simgrid/kernel/resource/Model.hpp +++ b/include/simgrid/kernel/resource/Model.hpp @@ -114,6 +114,6 @@ private: /** \ingroup SURF_models * \brief List of initialized models */ -XBT_PUBLIC_DATA std::vector* all_existing_models; +XBT_PUBLIC_DATA std::vector all_existing_models; #endif diff --git a/src/plugins/vm/VirtualMachineImpl.cpp b/src/plugins/vm/VirtualMachineImpl.cpp index ceae075f23..088f09a97d 100644 --- a/src/plugins/vm/VirtualMachineImpl.cpp +++ b/src/plugins/vm/VirtualMachineImpl.cpp @@ -17,7 +17,7 @@ void surf_vm_model_init_HL13() { if (surf_cpu_model_vm) { surf_vm_model = new simgrid::vm::VMModel(); - all_existing_models->push_back(surf_vm_model); + all_existing_models.push_back(surf_vm_model); } } diff --git a/src/simdag/sd_global.cpp b/src/simdag/sd_global.cpp index 193b5f444b..09236e02a9 100644 --- a/src/simdag/sd_global.cpp +++ b/src/simdag/sd_global.cpp @@ -56,7 +56,7 @@ std::set* simulate(double how_long){ total_time += elapsed_time; /* let's see which tasks are done */ - for (auto const& model : *all_existing_models) { + for (auto const& model : all_existing_models) { simgrid::kernel::resource::Action* action = model->extract_done_action(); while (action != nullptr && action->get_data() != nullptr) { SD_task_t task = static_cast(action->get_data()); diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index 4a1b82ab8f..56eb832902 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -307,7 +307,7 @@ double SIMIX_get_clock() /** Wake up all processes waiting for a Surf action to finish */ static void SIMIX_wake_processes() { - for (auto const& model : *all_existing_models) { + for (auto const& model : all_existing_models) { simgrid::kernel::resource::Action* action; XBT_DEBUG("Handling the processes whose action failed (if any)"); diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 2c9e268831..8fafa0b4c3 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -50,10 +50,10 @@ void surf_cpu_model_init_Cas01() 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(algo); - all_existing_models->push_back(surf_cpu_model_vm); + all_existing_models.push_back(surf_cpu_model_vm); } namespace simgrid { diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 40c049080b..837212df83 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -304,7 +304,7 @@ void CpuTiModel::create_pm_vm_models() CpuTiModel::CpuTiModel() : CpuModel(Model::UpdateAlgo::FULL) { - all_existing_models->push_back(this); + all_existing_models.push_back(this); } CpuTiModel::~CpuTiModel() diff --git a/src/surf/host_clm03.cpp b/src/surf/host_clm03.cpp index c4a3f20854..f195f6af39 100644 --- a/src/surf/host_clm03.cpp +++ b/src/surf/host_clm03.cpp @@ -28,7 +28,7 @@ namespace simgrid { namespace surf { HostCLM03Model::HostCLM03Model() { - all_existing_models->push_back(this); + all_existing_models.push_back(this); } double HostCLM03Model::next_occuring_event(double now) { diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 7adee01564..2b60d0a793 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -37,7 +37,7 @@ void surf_network_model_init_LegrandVelho() xbt_assert(surf_network_model == nullptr, "Cannot set the network model twice"); surf_network_model = new simgrid::kernel::resource::NetworkCm02Model(); - all_existing_models->push_back(surf_network_model); + all_existing_models.push_back(surf_network_model); simgrid::config::set_default("network/latency-factor", 13.01); simgrid::config::set_default("network/bandwidth-factor", 0.97); @@ -64,7 +64,7 @@ void surf_network_model_init_CM02() simgrid::config::set_default("network/weight-S", 0.0); surf_network_model = new simgrid::kernel::resource::NetworkCm02Model(); - all_existing_models->push_back(surf_network_model); + all_existing_models.push_back(surf_network_model); } /***************************************************************************/ @@ -89,7 +89,7 @@ void surf_network_model_init_Reno() simgrid::config::set_default("network/weight-S", 20537); surf_network_model = new simgrid::kernel::resource::NetworkCm02Model(&simgrid::kernel::lmm::make_new_lagrange_system); - all_existing_models->push_back(surf_network_model); + all_existing_models.push_back(surf_network_model); } @@ -105,7 +105,7 @@ void surf_network_model_init_Reno2() simgrid::config::set_default("network/weight-S", 20537); surf_network_model = new simgrid::kernel::resource::NetworkCm02Model(&simgrid::kernel::lmm::make_new_lagrange_system); - all_existing_models->push_back(surf_network_model); + all_existing_models.push_back(surf_network_model); } void surf_network_model_init_Vegas() @@ -120,7 +120,7 @@ void surf_network_model_init_Vegas() simgrid::config::set_default("network/weight-S", 20537); surf_network_model = new simgrid::kernel::resource::NetworkCm02Model(&simgrid::kernel::lmm::make_new_lagrange_system); - all_existing_models->push_back(surf_network_model); + all_existing_models.push_back(surf_network_model); } namespace simgrid { diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index 6e0214f9f0..e8365de065 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -16,7 +16,7 @@ void surf_network_model_init_Constant() { xbt_assert(surf_network_model == nullptr); surf_network_model = new simgrid::kernel::resource::NetworkConstantModel(); - all_existing_models->push_back(surf_network_model); + all_existing_models.push_back(surf_network_model); } namespace simgrid { diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index d672a8df21..d2437855b4 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -88,7 +88,7 @@ void surf_network_model_init_IB() xbt_assert(surf_network_model == nullptr, "Cannot set the network model twice"); surf_network_model = new simgrid::kernel::resource::NetworkIBModel(); - all_existing_models->push_back(surf_network_model); + all_existing_models.push_back(surf_network_model); simgrid::s4u::Link::on_communication_state_change.connect(IB_action_state_changed_callback); simgrid::s4u::Link::on_communicate.connect(IB_action_init_callback); simgrid::s4u::Host::on_creation.connect(IB_create_host_callback); diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index cfc5864394..e777211104 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -139,7 +139,7 @@ void surf_network_model_init_NS3() xbt_assert(surf_network_model == nullptr, "Cannot set the network model twice"); surf_network_model = new simgrid::kernel::resource::NetworkNS3Model(); - all_existing_models->push_back(surf_network_model); + all_existing_models.push_back(surf_network_model); } static simgrid::config::Flag diff --git a/src/surf/network_smpi.cpp b/src/surf/network_smpi.cpp index dedb8cdbe6..72de7ac9de 100644 --- a/src/surf/network_smpi.cpp +++ b/src/surf/network_smpi.cpp @@ -34,7 +34,7 @@ void surf_network_model_init_SMPI() if (surf_network_model) return; surf_network_model = new simgrid::kernel::resource::NetworkSmpiModel(); - all_existing_models->push_back(surf_network_model); + all_existing_models.push_back(surf_network_model); simgrid::config::set_default("network/weight-S", 8775); } diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index f0deae582b..ebad9d316e 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -22,7 +22,7 @@ void surf_host_model_init_ptask_L07() xbt_assert(not surf_network_model, "Cannot switch to ptasks: network model already defined"); surf_host_model = new simgrid::surf::HostL07Model(); - all_existing_models->push_back(surf_host_model); + all_existing_models.push_back(surf_host_model); } diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 78ac82e2d3..13bb0e3627 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -36,7 +36,7 @@ void check_disk_attachment() void surf_storage_model_init_default() { surf_storage_model = new simgrid::surf::StorageN11Model(); - all_existing_models->push_back(surf_storage_model); + all_existing_models.push_back(surf_storage_model); } namespace simgrid { diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 1e8f2cd079..62bf2e2747 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -37,7 +37,7 @@ void surf_presolve() } XBT_DEBUG ("Set every models in the right state by updating them to 0."); - for (auto const& model : *all_existing_models) + for (auto const& model : all_existing_models) model->update_actions_state(NOW, 0.0); } @@ -68,7 +68,7 @@ double surf_solve(double max_date) time_delta = next_event_virt; } - for (auto const& model : *all_existing_models) { + for (auto const& model : all_existing_models) { if (model != surf_host_model && model != surf_vm_model && model != surf_network_model && model != surf_storage_model) { double next_event_model = model->next_occuring_event(NOW); @@ -139,7 +139,7 @@ double surf_solve(double max_date) NOW = NOW + time_delta; // Inform the models of the date change - for (auto const& model : *all_existing_models) + for (auto const& model : all_existing_models) model->update_actions_state(NOW, time_delta); simgrid::s4u::on_time_advance(time_delta); diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index ce3e759d70..a7135decba 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -27,7 +27,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_kernel, surf, "Logging specific to SURF (ke * Utils * *********/ -std::vector* all_existing_models = nullptr; /* to destroy models correctly */ +std::vector all_existing_models; /* to destroy models correctly */ simgrid::trace_mgr::future_evt_set *future_evt_set = nullptr; std::vector surf_path; @@ -296,8 +296,6 @@ void surf_init(int *argc, char **argv) USER_HOST_LEVEL = simgrid::s4u::Host::extension_create(nullptr); xbt_init(argc, argv); - if (not all_existing_models) - all_existing_models = new std::vector(); if (not future_evt_set) future_evt_set = new simgrid::trace_mgr::future_evt_set(); @@ -317,9 +315,8 @@ void surf_exit() delete stype; } - for (auto const& model : *all_existing_models) + for (auto const& model : all_existing_models) delete model; - delete all_existing_models; delete future_evt_set; future_evt_set = nullptr; diff --git a/teshsuite/surf/surf_usage2/surf_usage2.cpp b/teshsuite/surf/surf_usage2/surf_usage2.cpp index ad7afbc40f..4419b39d7c 100644 --- a/teshsuite/surf/surf_usage2/surf_usage2.cpp +++ b/teshsuite/surf/surf_usage2/surf_usage2.cpp @@ -45,7 +45,7 @@ int main(int argc, char **argv) double now = surf_get_clock(); XBT_INFO("Next Event : %g", now); - for (auto const& model : *all_existing_models) { + for (auto const& model : all_existing_models) { if (model->get_started_action_set()->size() != 0) { XBT_DEBUG("\t Running that model"); running = 1; -- 2.20.1