Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics around CpuTiModel
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 7 Jul 2018 22:40:57 +0000 (00:40 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 7 Jul 2018 22:40:57 +0000 (00:40 +0200)
src/include/surf/surf.hpp
src/surf/cpu_cas01.cpp
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp

index db629cc..f04854a 100644 (file)
@@ -89,13 +89,6 @@ XBT_PUBLIC_DATA simgrid::surf::CpuModel* surf_cpu_model_vm;
  */
 XBT_PUBLIC void surf_cpu_model_init_Cas01();
 
-/** \ingroup SURF_models
- *  \brief Initializes the CPU model with trace integration [Deprecated]
- *
- *  You shouldn't have to call it by yourself.
- */
-XBT_PUBLIC void surf_cpu_model_init_ti();
-
 /** \ingroup SURF_models
  *  \brief The list of all available optimization modes (both for cpu and networks).
  *  These optimization modes can be set using --cfg=cpu/optim:... and --cfg=network/optim:...
index c3bdc57..2c9e268 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;
   }
 
index 519bf98..08960f0 100644 (file)
@@ -8,8 +8,7 @@
 #include "src/surf/trace_mgr.hpp"
 #include "surf/surf.hpp"
 
-#ifndef SURF_MODEL_CPUTI_H_
-#define SURF_MODEL_CPUTI_H_
+#define EPSILON 0.000000001
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_ti, surf_cpu, "Logging specific to the SURF CPU TRACE INTEGRATION module");
 
@@ -292,21 +291,22 @@ int CpuTiTrace::binary_search(double* array, double a, int low, int high)
 /*********
  * Model *
  *********/
+namespace simgrid {
+namespace surf {
 
-void surf_cpu_model_init_ti()
+void CpuTiModel::create_pm_vm_models()
 {
-  xbt_assert(not surf_cpu_model_pm, "CPU model already initialized. This should not happen.");
-  xbt_assert(not surf_cpu_model_vm, "CPU model already initialized. This should not happen.");
+  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.");
 
   surf_cpu_model_pm = new simgrid::surf::CpuTiModel();
-  all_existing_models->push_back(surf_cpu_model_pm);
-
   surf_cpu_model_vm = new simgrid::surf::CpuTiModel();
-  all_existing_models->push_back(surf_cpu_model_vm);
 }
 
-namespace simgrid {
-namespace surf {
+CpuTiModel::CpuTiModel() : CpuModel(Model::UpdateAlgo::FULL)
+{
+  all_existing_models->push_back(this);
+}
 
 CpuTiModel::~CpuTiModel()
 {
@@ -673,5 +673,3 @@ double CpuTiAction::get_remains()
 
 }
 }
-
-#endif /* SURF_MODEL_CPUTI_H_ */
index 519e744..9c6f0a8 100644 (file)
@@ -3,16 +3,16 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#ifndef SURF_MODEL_CPUTI_H_
+#define SURF_MODEL_CPUTI_H_
+
 #include <boost/intrusive/list.hpp>
 
-#include <xbt/base.h>
+//#include <xbt/base.h>
 
 #include "src/surf/cpu_interface.hpp"
 #include "src/surf/trace_mgr.hpp"
 
-/* Epsilon */
-#define EPSILON 0.000000001
-
 namespace simgrid {
 namespace surf {
 
@@ -139,7 +139,9 @@ typedef boost::intrusive::list<CpuTi, CpuTiListOptions> CpuTiList;
  *********/
 class CpuTiModel : public CpuModel {
 public:
-  CpuTiModel() : CpuModel(Model::UpdateAlgo::FULL){};
+  static void create_pm_vm_models(); // Make both models be TI models
+
+  CpuTiModel();
   ~CpuTiModel() override;
   Cpu* create_cpu(simgrid::s4u::Host* host, std::vector<double>* speed_per_pstate, int core) override;
   double next_occuring_event(double now) override;
@@ -150,3 +152,5 @@ public:
 
 }
 }
+
+#endif /* SURF_MODEL_CPUTI_H_ */