From: Martin Quinson Date: Fri, 30 Mar 2018 23:13:57 +0000 (+0200) Subject: CpuCas01: set updateAlgo as initializer X-Git-Tag: v3.20~568 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/22a45a8d97ef0f1211ee05f9c16d7d90b37cf33b CpuCas01: set updateAlgo as initializer My goal here is to make updateAlgo a constant in each Model object. --- diff --git a/include/simgrid/kernel/resource/Model.hpp b/include/simgrid/kernel/resource/Model.hpp index 77039234ed..b803d87a14 100644 --- a/include/simgrid/kernel/resource/Model.hpp +++ b/include/simgrid/kernel/resource/Model.hpp @@ -29,6 +29,8 @@ public: }; Model(); + Model(Model::UpdateAlgo algo); + virtual ~Model(); /** @brief Get the set of [actions](@ref Action) in *ready* state */ @@ -52,10 +54,7 @@ public: /** @brief Set the maxmin system of the current Model */ void set_maxmin_system(lmm::System* system) { maxmin_system_ = system; } - /** - * @brief Get the update mechanism of the current Model - * @see e_UM_t - */ + /** @brief Get the update mechanism of the current Model */ UpdateAlgo getUpdateMechanism() const { return update_mechanism_; } void setUpdateMechanism(UpdateAlgo mechanism) { update_mechanism_ = mechanism; } diff --git a/src/kernel/resource/Model.cpp b/src/kernel/resource/Model.cpp index 5e73044f95..e463d997be 100644 --- a/src/kernel/resource/Model.cpp +++ b/src/kernel/resource/Model.cpp @@ -13,6 +13,7 @@ namespace kernel { namespace resource { Model::Model() = default; +Model::Model(Model::UpdateAlgo algo) : update_mechanism_(algo) {} Model::~Model() { diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 019d540dc9..d9f5f14c59 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -42,32 +42,35 @@ void surf_cpu_model_init_Cas01() return; } - surf_cpu_model_pm = new simgrid::surf::CpuCas01Model(cpu_optim_opt == "Lazy"); + simgrid::kernel::resource::Model::UpdateAlgo algo; + if (cpu_optim_opt == "Lazy") + algo = simgrid::kernel::resource::Model::UpdateAlgo::Lazy; + else + 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(cpu_optim_opt == "Lazy"); + surf_cpu_model_vm = new simgrid::surf::CpuCas01Model(algo); all_existing_models->push_back(surf_cpu_model_vm); } namespace simgrid { namespace surf { -CpuCas01Model::CpuCas01Model(bool optim_lazy) : simgrid::surf::CpuModel() +CpuCas01Model::CpuCas01Model(kernel::resource::Model::UpdateAlgo algo) : simgrid::surf::CpuModel(algo) { bool select = xbt_cfg_get_boolean("cpu/maxmin-selective-update"); - if (optim_lazy) { + if (algo == Model::UpdateAlgo::Lazy) { xbt_assert(select || xbt_cfg_is_default_value("cpu/maxmin-selective-update"), "You cannot disable cpu selective update when using the lazy update mechanism"); - setUpdateMechanism(Model::UpdateAlgo::Lazy); select = true; - } else { - setUpdateMechanism(Model::UpdateAlgo::Full); } set_maxmin_system(new simgrid::kernel::lmm::System(select)); - if (optim_lazy) + if (algo == Model::UpdateAlgo::Lazy) get_maxmin_system()->modified_set_ = new kernel::resource::Action::ModifiedSet(); } diff --git a/src/surf/cpu_cas01.hpp b/src/surf/cpu_cas01.hpp index 7683a0804f..ba1f13d7bc 100644 --- a/src/surf/cpu_cas01.hpp +++ b/src/surf/cpu_cas01.hpp @@ -24,7 +24,7 @@ class XBT_PRIVATE CpuCas01Action; class CpuCas01Model : public simgrid::surf::CpuModel { public: - CpuCas01Model(bool optim_lazy); + CpuCas01Model(kernel::resource::Model::UpdateAlgo algo); ~CpuCas01Model() override; Cpu *createCpu(simgrid::s4u::Host *host, std::vector *speedPerPstate, int core) override; diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 375c1d7ac8..72a99af01e 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -26,6 +26,9 @@ namespace surf { */ class XBT_PUBLIC CpuModel : public kernel::resource::Model { public: + CpuModel(kernel::resource::Model::UpdateAlgo algo) : Model(algo) {} + CpuModel() : Model() {} + /** * @brief Create a Cpu * diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 4fc9b6c7f7..c04b25af94 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -373,8 +373,7 @@ void CpuTiModel::update_actions_state(double now, double /*delta*/) CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, std::vector *speedPerPstate, int core) : Cpu(model, host, speedPerPstate, core) { - xbt_assert(core==1,"Multi-core not handled by this model yet"); - coresAmount_ = core; + xbt_assert(core == 1, "Multi-core not handled by this model yet"); speed_.peak = speedPerPstate->front(); XBT_DEBUG("CPU create: peak=%f", speed_.peak);