Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 20 May 2018 20:24:55 +0000 (22:24 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 20 May 2018 20:24:55 +0000 (22:24 +0200)
include/simgrid/s4u/Host.hpp
src/plugins/vm/s4u_VirtualMachine.cpp
src/s4u/s4u_Host.cpp
src/surf/cpu_cas01.cpp
src/surf/cpu_interface.cpp
src/surf/cpu_interface.hpp
src/surf/cpu_ti.cpp
src/surf/plugins/host_energy.cpp
src/surf/plugins/host_load.cpp
src/surf/ptask_L07.cpp
src/surf/sg_platf.cpp

index 15972ce..ab6cb8b 100644 (file)
@@ -108,6 +108,7 @@ public:
   int getPstatesCount() const;
   void setPstate(int pstate_index);
   int getPstate();
+
   std::vector<const char*> get_attached_storages();
   XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_attached_storages() instead.") void getAttachedStorages(
       std::vector<const char*>* storages);
index d603636..0703e8d 100644 (file)
@@ -35,11 +35,11 @@ VirtualMachine::VirtualMachine(const char* name, s4u::Host* pm, int coreAmount,
   pimpl_netpoint = pm->pimpl_netpoint;
 
   // Create a VCPU for this VM
-  std::vector<double>* speeds = new std::vector<double>();
+  std::vector<double> speeds;
   for (int i = 0; i < pm->getPstatesCount(); i++)
-    speeds->push_back(pm->getPstateSpeed(i));
+    speeds.push_back(pm->getPstateSpeed(i));
 
-  surf_cpu_model_vm->createCpu(this, speeds, pm->getCoreCount());
+  surf_cpu_model_vm->createCpu(this, &speeds, pm->getCoreCount());
   if (pm->getPstate() != 0)
     setPstate(pm->getPstate());
 
index 1fbbf94..cdbc5a9 100644 (file)
@@ -133,7 +133,7 @@ bool Host::is_on()
 
 int Host::getPstatesCount() const
 {
-  return this->pimpl_cpu->getNbPStates();
+  return this->pimpl_cpu->get_pstates_count();
 }
 
 /**
@@ -226,31 +226,31 @@ double Host::getPstateSpeed(int pstate_index)
   return simgrid::simix::simcall([this, pstate_index] { return this->pimpl_cpu->getPstateSpeed(pstate_index); });
 }
 
-/** @brief Get the peak processor speed (under full load (=1.0), in flops/s), at the current pstate */
+/** @brief Get the peak processor speed in flops/s, (under full load (=1.0), at the current pstate) */
 double Host::getSpeed()
 {
-  return pimpl_cpu->getSpeed(1.0);
+  return this->pimpl_cpu->getSpeed(1.0);
 }
 double Host::get_available_speed()
 {
-  return pimpl_cpu->get_available_speed();
+  return this->pimpl_cpu->get_available_speed();
 }
 
 /** @brief Returns the number of core of the processor. */
 int Host::getCoreCount()
 {
-  return pimpl_cpu->coreCount();
+  return this->pimpl_cpu->get_cores_count();
 }
 
 /** @brief Set the pstate at which the host should run */
 void Host::setPstate(int pstate_index)
 {
-  simgrid::simix::simcall([this, pstate_index] { this->pimpl_cpu->setPState(pstate_index); });
+  simgrid::simix::simcall([this, pstate_index] { this->pimpl_cpu->set_pstate(pstate_index); });
 }
 /** @brief Retrieve the pstate at which the host is currently running */
 int Host::getPstate()
 {
-  return this->pimpl_cpu->getPState();
+  return this->pimpl_cpu->get_pstate();
 }
 
 /**
index b069dc9..0b61967 100644 (file)
@@ -93,11 +93,11 @@ CpuCas01::CpuCas01(CpuCas01Model* model, simgrid::s4u::Host* host, std::vector<d
 CpuCas01::~CpuCas01()
 {
   if (get_model() == surf_cpu_model_pm)
-    speedPerPstate_.clear();
+    speed_per_pstate_.clear();
 }
 
 std::vector<double> * CpuCas01::getSpeedPeakList(){
-  return &speedPerPstate_;
+  return &speed_per_pstate_;
 }
 
 bool CpuCas01::is_used()
@@ -111,7 +111,7 @@ void CpuCas01::onSpeedChange() {
   const kernel::lmm::Element* elem = nullptr;
 
   get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(),
-                                                            coresAmount_ * speed_.scale * speed_.peak);
+                                                            get_cores_count() * speed_.scale * speed_.peak);
   while ((var = get_constraint()->get_variable(&elem))) {
     CpuCas01Action* action = static_cast<CpuCas01Action*>(var->get_id());
 
@@ -126,19 +126,19 @@ void CpuCas01::apply_event(tmgr_trace_event_t event, double value)
 {
   if (event == speed_.event) {
     /* TODO (Hypervisor): do the same thing for constraint_core[i] */
-    xbt_assert(coresAmount_ == 1, "FIXME: add speed scaling code also for constraint_core[i]");
+    xbt_assert(get_cores_count() == 1, "FIXME: add speed scaling code also for constraint_core[i]");
 
     speed_.scale = value;
     onSpeedChange();
 
     tmgr_trace_event_unref(&speed_.event);
-  } else if (event == stateEvent_) {
+  } else if (event == state_event_) {
     /* TODO (Hypervisor): do the same thing for constraint_core[i] */
-    xbt_assert(coresAmount_ == 1, "FIXME: add state change code also for constraint_core[i]");
+    xbt_assert(get_cores_count() == 1, "FIXME: add state change code also for constraint_core[i]");
 
     if (value > 0) {
       if (is_off())
-        host_that_restart.push_back(getHost());
+        host_that_restart.push_back(get_host());
       turn_on();
     } else {
       kernel::lmm::Constraint* cnst = get_constraint();
@@ -159,7 +159,7 @@ void CpuCas01::apply_event(tmgr_trace_event_t event, double value)
         }
       }
     }
-    tmgr_trace_event_unref(&stateEvent_);
+    tmgr_trace_event_unref(&state_event_);
 
   } else {
     xbt_die("Unknown event!\n");
index 6445903..a8b793d 100644 (file)
@@ -60,7 +60,7 @@ Cpu::Cpu(kernel::resource::Model* model, simgrid::s4u::Host* host, std::vector<d
 
 Cpu::Cpu(kernel::resource::Model* model, simgrid::s4u::Host* host, kernel::lmm::Constraint* constraint,
          std::vector<double>* speedPerPstate, int core)
-    : Resource(model, host->get_cname(), constraint), coresAmount_(core), host_(host)
+    : Resource(model, host->get_cname(), constraint), cores_count_(core), host_(host)
 {
   xbt_assert(core > 0, "Host %s must have at least one core, not 0.", host->get_cname());
 
@@ -71,41 +71,42 @@ Cpu::Cpu(kernel::resource::Model* model, simgrid::s4u::Host* host, kernel::lmm::
 
   // Copy the power peak array:
   for (double const& value : *speedPerPstate) {
-    speedPerPstate_.push_back(value);
+    speed_per_pstate_.push_back(value);
   }
 }
 
 Cpu::~Cpu() = default;
 
-int Cpu::getNbPStates()
+int Cpu::get_pstates_count()
 {
-  return speedPerPstate_.size();
+  return speed_per_pstate_.size();
 }
 
-void Cpu::setPState(int pstate_index)
+void Cpu::set_pstate(int pstate_index)
 {
-  xbt_assert(pstate_index <= static_cast<int>(speedPerPstate_.size()),
+  xbt_assert(pstate_index <= static_cast<int>(speed_per_pstate_.size()),
              "Invalid parameters for CPU %s (pstate %d > length of pstates %d). Please fix your platform file, or your "
              "call to change the pstate.",
-             get_cname(), pstate_index, static_cast<int>(speedPerPstate_.size()));
+             get_cname(), pstate_index, static_cast<int>(speed_per_pstate_.size()));
 
-  double new_peak_speed = speedPerPstate_[pstate_index];
+  double new_peak_speed = speed_per_pstate_[pstate_index];
   pstate_ = pstate_index;
   speed_.peak = new_peak_speed;
 
   onSpeedChange();
 }
 
-int Cpu::getPState()
+int Cpu::get_pstate()
 {
   return pstate_;
 }
 
 double Cpu::getPstateSpeed(int pstate_index)
 {
-  xbt_assert((pstate_index <= static_cast<int>(speedPerPstate_.size())), "Invalid parameters (pstate index out of bounds)");
+  xbt_assert((pstate_index <= static_cast<int>(speed_per_pstate_.size())),
+             "Invalid parameters (pstate index out of bounds)");
 
-  return speedPerPstate_[pstate_index];
+  return speed_per_pstate_[pstate_index];
 }
 
 double Cpu::getSpeed(double load)
@@ -123,16 +124,16 @@ void Cpu::onSpeedChange() {
   s4u::Host::on_speed_change(*host_);
 }
 
-int Cpu::coreCount()
+int Cpu::get_cores_count()
 {
-  return coresAmount_;
+  return cores_count_;
 }
 
 void Cpu::setStateTrace(tmgr_trace_t trace)
 {
-  xbt_assert(stateEvent_ == nullptr, "Cannot set a second state trace to Host %s", host_->get_cname());
+  xbt_assert(state_event_ == nullptr, "Cannot set a second state trace to Host %s", host_->get_cname());
 
-  stateEvent_ = future_evt_set->add_trace(trace, this);
+  state_event_ = future_evt_set->add_trace(trace, this);
 }
 void Cpu::set_speed_trace(tmgr_trace_t trace)
 {
index e92c133..26f76ac 100644 (file)
@@ -103,7 +103,7 @@ public:
   virtual simgrid::kernel::resource::Action* sleep(double duration) = 0;
 
   /** @brief Get the amount of cores */
-  virtual int coreCount();
+  virtual int get_cores_count();
 
   /** @brief Get the speed, accounting for the trace load and provided process load instead of the real current one */
   virtual double getSpeed(double load);
@@ -119,24 +119,27 @@ public:
   /** @brief Get the current Cpu computational speed */
   virtual double getPstateSpeed(int pstate_index);
 
-  virtual int getNbPStates();
-  virtual void setPState(int pstate_index);
-  virtual int  getPState();
+  virtual int get_pstates_count();
+  virtual void set_pstate(int pstate_index);
+  virtual int get_pstate();
 
-  simgrid::s4u::Host* getHost() { return host_; }
+  simgrid::s4u::Host* get_host() { return host_; }
 
-  int coresAmount_ = 1;
+private:
+  int cores_count_ = 1;
   simgrid::s4u::Host* host_;
 
-  std::vector<double> speedPerPstate_; /*< List of supported CPU capacities (pstate related) */
   int pstate_ = 0;                     /*< Current pstate (index in the speedPeakList)*/
+protected:
+  std::vector<double> speed_per_pstate_; /*< List of supported CPU capacities (pstate related) */
 
+public:
   virtual void setStateTrace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). Trace must contain boolean values (0 or 1). */
   virtual void
   set_speed_trace(tmgr_trace_t trace); /*< setup the trace file with availability events (peak speed changes due to
                                           external load). Trace must contain relative values (ratio between 0 and 1) */
 
-  tmgr_trace_event_t stateEvent_ = nullptr;
+  tmgr_trace_event_t state_event_ = nullptr;
   Metric speed_                  = {1.0, 0, nullptr};
 };
 
index d15f1d2..befaa74 100644 (file)
@@ -402,10 +402,10 @@ void CpuTi::apply_event(tmgr_trace_event_t event, double value)
 
     tmgr_trace_event_unref(&speed_.event);
 
-  } else if (event == stateEvent_) {
+  } else if (event == state_event_) {
     if (value > 0) {
       if (is_off())
-        host_that_restart.push_back(getHost());
+        host_that_restart.push_back(get_host());
       turn_on();
     } else {
       turn_off();
@@ -422,7 +422,7 @@ void CpuTi::apply_event(tmgr_trace_event_t event, double value)
         }
       }
     }
-    tmgr_trace_event_unref(&stateEvent_);
+    tmgr_trace_event_unref(&state_event_);
 
   } else {
     xbt_die("Unknown event!\n");
index 82fe90d..f346576 100644 (file)
@@ -235,7 +235,7 @@ double HostEnergy::getCurrentWattsValue()
     cpu_load = host->pimpl_cpu->get_constraint()->get_usage() / current_speed;
 
   /** Divide by the number of cores here **/
-  cpu_load /= host->pimpl_cpu->coreCount();
+  cpu_load /= host->pimpl_cpu->get_cores_count();
 
   if (cpu_load > 1) // A machine with a load > 1 consumes as much as a fully loaded machine, not more
     cpu_load = 1;
@@ -384,7 +384,7 @@ static void onCreation(simgrid::s4u::Host& host)
 static void onActionStateChange(simgrid::surf::CpuAction* action, simgrid::kernel::resource::Action::State previous)
 {
   for (simgrid::surf::Cpu* const& cpu : action->cpus()) {
-    simgrid::s4u::Host* host = cpu->getHost();
+    simgrid::s4u::Host* host = cpu->get_host();
     if (host != nullptr) {
 
       // If it's a VM, take the corresponding PM
index 94e8966..d915b59 100644 (file)
@@ -151,7 +151,7 @@ static void onHostChange(simgrid::s4u::Host& host)
 static void onActionStateChange(simgrid::surf::CpuAction* action, simgrid::kernel::resource::Action::State /*previous*/)
 {
   for (simgrid::surf::Cpu* const& cpu : action->cpus()) {
-    simgrid::s4u::Host* host = cpu->getHost();
+    simgrid::s4u::Host* host = cpu->get_host();
 
     if (dynamic_cast<simgrid::s4u::VirtualMachine*>(host)) // Ignore virtual machines
       return;
index d1485bf..590dae1 100644 (file)
@@ -263,7 +263,7 @@ kernel::resource::Action* CpuL07::execution_start(double size)
   sg_host_t* host_list = new sg_host_t[1]();
   double* flops_amount = new double[1]();
 
-  host_list[0] = getHost();
+  host_list[0]    = get_host();
   flops_amount[0] = size;
 
   return static_cast<CpuL07Model*>(get_model())->hostModel_->execute_parallel(1, host_list, flops_amount, nullptr, -1);
@@ -312,12 +312,12 @@ void CpuL07::apply_event(tmgr_trace_event_t triggered, double value)
     onSpeedChange();
     tmgr_trace_event_unref(&speed_.event);
 
-  } else if (triggered == stateEvent_) {
+  } else if (triggered == state_event_) {
     if (value > 0)
       turn_on();
     else
       turn_off();
-    tmgr_trace_event_unref(&stateEvent_);
+    tmgr_trace_event_unref(&state_event_);
 
   } else {
     xbt_die("Unknown event!\n");
index e7374e5..4ecc5c4 100644 (file)
@@ -84,7 +84,7 @@ void sg_platf_new_host(simgrid::kernel::routing::HostCreationArgs* args)
   if (args->speed_trace)
     host->pimpl_cpu->set_speed_trace(args->speed_trace);
   if (args->pstate != 0)
-    host->pimpl_cpu->setPState(args->pstate);
+    host->pimpl_cpu->set_pstate(args->pstate);
   if (args->coord && strcmp(args->coord, ""))
     new simgrid::kernel::routing::vivaldi::Coords(host->pimpl_netpoint, args->coord);
 }