Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
prefer automatic mem handling (std::vector<>* becomes std::vector<>)
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 8 Jul 2018 23:32:22 +0000 (01:32 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 9 Jul 2018 04:46:40 +0000 (06:46 +0200)
17 files changed:
include/simgrid/kernel/resource/Model.hpp
src/plugins/vm/VirtualMachineImpl.cpp
src/simdag/sd_global.cpp
src/simix/smx_global.cpp
src/surf/cpu_cas01.cpp
src/surf/cpu_ti.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
src/surf/storage_n11.cpp
src/surf/surf_c_bindings.cpp
src/surf/surf_interface.cpp
teshsuite/surf/surf_usage2/surf_usage2.cpp

index ce391af..5985e4b 100644 (file)
@@ -114,6 +114,6 @@ private:
 /** \ingroup SURF_models
  *  \brief List of initialized models
  */
-XBT_PUBLIC_DATA std::vector<simgrid::kernel::resource::Model*>* all_existing_models;
+XBT_PUBLIC_DATA std::vector<simgrid::kernel::resource::Model*> all_existing_models;
 
 #endif
index ceae075..088f09a 100644 (file)
@@ -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);
   }
 }
 
index 193b5f4..09236e0 100644 (file)
@@ -56,7 +56,7 @@ std::set<SD_task_t>* 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<SD_task_t>(action->get_data());
index 4a1b82a..56eb832 100644 (file)
@@ -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)");
index 2c9e268..8fafa0b 100644 (file)
@@ -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 {
index 40c0490..837212d 100644 (file)
@@ -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()
index c4a3f20..f195f6a 100644 (file)
@@ -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)
 {
index 7adee01..2b60d0a 100644 (file)
@@ -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<double>("network/latency-factor", 13.01);
   simgrid::config::set_default<double>("network/bandwidth-factor", 0.97);
@@ -64,7 +64,7 @@ void surf_network_model_init_CM02()
   simgrid::config::set_default<double>("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<double>("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<double>("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<double>("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 {
index 6e0214f..e8365de 100644 (file)
@@ -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 {
index d672a8d..d243785 100644 (file)
@@ -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);
index cfc5864..e777211 100644 (file)
@@ -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<std::string>
index dedb8cd..72de7ac 100644 (file)
@@ -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<double>("network/weight-S", 8775);
 }
index f0deae5..ebad9d3 100644 (file)
@@ -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);
 }
 
 
index 78ac82e..13bb0e3 100644 (file)
@@ -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 {
index 1e8f2cd..62bf2e2 100644 (file)
@@ -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);
index ce3e759..a7135de 100644 (file)
@@ -27,7 +27,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_kernel, surf, "Logging specific to SURF (ke
  * Utils *
  *********/
 
-std::vector<simgrid::kernel::resource::Model*>* all_existing_models = nullptr; /* to destroy models correctly */
+std::vector<simgrid::kernel::resource::Model*> all_existing_models; /* to destroy models correctly */
 
 simgrid::trace_mgr::future_evt_set *future_evt_set = nullptr;
 std::vector<std::string> 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<simgrid::kernel::resource::Model*>();
   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;
index ad7afbc..4419b39 100644 (file)
@@ -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;