From: Martin Quinson Date: Sat, 7 Jul 2018 22:40:57 +0000 (+0200) Subject: cosmetics around CpuTiModel X-Git-Tag: v3_21~537 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a46dc2e1f51658a842b4df3e689bd7f6c49986fe cosmetics around CpuTiModel --- diff --git a/src/include/surf/surf.hpp b/src/include/surf/surf.hpp index db629ccbf2..f04854aa19 100644 --- a/src/include/surf/surf.hpp +++ b/src/include/surf/surf.hpp @@ -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:... diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index c3bdc57cdd..2c9e268831 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -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 *********/ 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; } diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 519bf989b2..08960f094c 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -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_ */ diff --git a/src/surf/cpu_ti.hpp b/src/surf/cpu_ti.hpp index 519e744220..9c6f0a85a0 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -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 -#include +//#include #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 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* speed_per_pstate, int core) override; double next_occuring_event(double now) override; @@ -150,3 +152,5 @@ public: } } + +#endif /* SURF_MODEL_CPUTI_H_ */