]> AND Public Git Repository - simgrid.git/blobdiff - src/surf/cpu_cas01.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Sonar variety
[simgrid.git] / src / surf / cpu_cas01.cpp
index 8570cffd0758ab1b8b690d8b5b2cc080f971c87b..2223a803691f788025aed48e88ed3330c5e93701 100644 (file)
@@ -3,12 +3,13 @@
 /* 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. */
 
-#include "cpu_cas01.hpp"
 #include "simgrid/kernel/routing/NetZoneImpl.hpp"
 #include "simgrid/s4u/Engine.hpp"
+
 #include "simgrid/sg_config.hpp"
 #include "src/kernel/EngineImpl.hpp"
 #include "src/kernel/resource/profile/Event.hpp"
+#include "src/surf/cpu_cas01.hpp"
 #include "src/surf/cpu_ti.hpp"
 #include "src/surf/surf_interface.hpp"
 #include "surf/surf.hpp"
@@ -44,9 +45,8 @@ void surf_cpu_model_init_Cas01()
     return;
   }
 
-  auto cpu_model_pm = std::make_shared<simgrid::kernel::resource::CpuCas01Model>();
-  simgrid::kernel::EngineImpl::get_instance()->add_model(simgrid::kernel::resource::Model::Type::CPU_PM, cpu_model_pm,
-                                                         true);
+  auto cpu_model_pm = std::make_shared<simgrid::kernel::resource::CpuCas01Model>("Cpu_Cas01");
+  simgrid::kernel::EngineImpl::get_instance()->add_model(cpu_model_pm);
   simgrid::s4u::Engine::get_instance()->get_netzone_root()->get_impl()->set_cpu_pm_model(cpu_model_pm);
 }
 
@@ -54,7 +54,7 @@ namespace simgrid {
 namespace kernel {
 namespace resource {
 
-CpuCas01Model::CpuCas01Model()
+CpuCas01Model::CpuCas01Model(const std::string& name) : CpuModel(name)
 {
   if (config::get_value<std::string>("cpu/optim") == "Lazy")
     set_update_algorithm(Model::UpdateAlgo::LAZY);
@@ -70,7 +70,7 @@ CpuCas01Model::CpuCas01Model()
   set_maxmin_system(new lmm::System(select));
 }
 
-Cpu* CpuCas01Model::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate)
+CpuImpl* CpuCas01Model::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate)
 {
   return (new CpuCas01(host, speed_per_pstate))->set_model(this);
 }
@@ -86,19 +86,18 @@ bool CpuCas01::is_used() const
 /** @brief take into account changes of speed (either load or max) */
 void CpuCas01::on_speed_change()
 {
-  const lmm::Variable* var;
   const lmm::Element* elem = nullptr;
 
   get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(),
                                                             get_core_count() * speed_.scale * speed_.peak);
-  while ((var = get_constraint()->get_variable(&elem))) {
-    const CpuCas01Action* action = static_cast<CpuCas01Action*>(var->get_id());
+  while (const auto* var = get_constraint()->get_variable(&elem)) {
+    const auto* action = static_cast<CpuCas01Action*>(var->get_id());
 
     get_model()->get_maxmin_system()->update_variable_bound(action->get_variable(),
                                                             action->requested_core() * speed_.scale * speed_.peak);
   }
 
-  Cpu::on_speed_change();
+  CpuImpl::on_speed_change();
 }
 
 void CpuCas01::apply_event(profile::Event* event, double value)
@@ -121,14 +120,12 @@ void CpuCas01::apply_event(profile::Event* event, double value)
         get_iface()->turn_on();
       }
     } else {
-      const lmm::Constraint* cnst = get_constraint();
-      const lmm::Variable* var;
       const lmm::Element* elem = nullptr;
       double date              = surf_get_clock();
 
       get_iface()->turn_off();
 
-      while ((var = cnst->get_variable(&elem))) {
+      while (const auto* var = get_constraint()->get_variable(&elem)) {
         Action* action = var->get_id();
 
         if (action->get_state() == Action::State::INITED || action->get_state() == Action::State::STARTED ||