Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
have each model register into all_existing_models by itself
[simgrid.git] / src / surf / cpu_cas01.cpp
index c3bdc57..a39c9b3 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "cpu_cas01.hpp"
 #include "simgrid/sg_config.hpp"
+#include "src/surf/cpu_ti.hpp"
 #include "src/surf/surf_interface.hpp"
 #include "surf/surf.hpp"
 
@@ -34,11 +35,11 @@ static simgrid::config::Flag<std::string>
  *********/
 void surf_cpu_model_init_Cas01()
 {
-  xbt_assert(not surf_cpu_model_pm);
-  xbt_assert(not surf_cpu_model_vm);
+  xbt_assert(surf_cpu_model_pm == nullptr, "CPU model already initialized. This should not happen.");
+  xbt_assert(surf_cpu_model_vm == nullptr, "CPU model already initialized. This should not happen.");
 
   if (cpu_optim_opt == "TI") {
-    surf_cpu_model_init_ti();
+    simgrid::surf::CpuTiModel::create_pm_vm_models();
     return;
   }
 
@@ -49,10 +50,7 @@ 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);
-
   surf_cpu_model_vm = new simgrid::surf::CpuCas01Model(algo);
-  all_existing_models->push_back(surf_cpu_model_vm);
 }
 
 namespace simgrid {
@@ -60,6 +58,8 @@ namespace surf {
 
 CpuCas01Model::CpuCas01Model(kernel::resource::Model::UpdateAlgo algo) : simgrid::surf::CpuModel(algo)
 {
+  all_existing_models.push_back(this);
+
   bool select = simgrid::config::get_value<bool>("cpu/maxmin-selective-update");
 
   if (algo == Model::UpdateAlgo::LAZY) {