Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Objectifies the CPU model
[simgrid.git] / src / surf / cpu_cas01.cpp
index 42fd5c1..83aa5f9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2023. The SimGrid Team. All rights reserved.          */
 
 /* 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. */
@@ -34,11 +34,13 @@ static simgrid::config::Flag<std::string>
                                "Cannot change the optimization algorithm after the initialization");
                   });
 
+static simgrid::config::Flag<std::string> cfg_cpu_solver("cpu/solver", "Set linear equations solver used by CPU model",
+                                                         "maxmin", &simgrid::kernel::lmm::System::validate_solver);
+
 /*********
  * Model *
  *********/
-void surf_cpu_model_init_Cas01()
-{
+SIMGRID_REGISTER_CPU_MODEL(Cas01, "Simplistic CPU model (time=size/speed)", []() {
   if (cpu_optim_opt == "TI") {
     simgrid::kernel::resource::CpuTiModel::create_pm_models();
     return;
@@ -48,11 +50,9 @@ void surf_cpu_model_init_Cas01()
   auto* engine      = simgrid::kernel::EngineImpl::get_instance();
   engine->add_model(cpu_model_pm);
   engine->get_netzone_root()->set_cpu_pm_model(cpu_model_pm);
-}
+});
 
-namespace simgrid {
-namespace kernel {
-namespace resource {
+namespace simgrid::kernel::resource {
 
 CpuCas01Model::CpuCas01Model(const std::string& name) : CpuModel(name)
 {
@@ -67,7 +67,7 @@ CpuCas01Model::CpuCas01Model(const std::string& name) : CpuModel(name)
     select = true;
   }
 
-  set_maxmin_system(new lmm::System(select));
+  set_maxmin_system(lmm::System::build(cfg_cpu_solver.get(), select));
 }
 
 CpuImpl* CpuCas01Model::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate)
@@ -202,6 +202,4 @@ CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double sp
   model->get_maxmin_system()->expand(constraint, get_variable(), 1.0);
 }
 
-} // namespace resource
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::resource