From eefc25aa1c98cbb7458cbf5d38007470e3bef7d0 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 20 May 2018 15:21:44 +0200 Subject: [PATCH] snake_case some parts of kernel::resource::Cpu --- include/simgrid/s4u/Host.hpp | 1 + src/s4u/s4u_Host.cpp | 14 +++++++------- src/surf/cpu_cas01.cpp | 16 ++++++++-------- src/surf/cpu_interface.cpp | 31 ++++++++++++++++--------------- src/surf/cpu_interface.hpp | 16 ++++++++-------- src/surf/cpu_ti.cpp | 6 +++--- src/surf/plugins/host_energy.cpp | 4 ++-- src/surf/plugins/host_load.cpp | 2 +- src/surf/ptask_L07.cpp | 6 +++--- src/surf/sg_platf.cpp | 2 +- 10 files changed, 50 insertions(+), 48 deletions(-) diff --git a/include/simgrid/s4u/Host.hpp b/include/simgrid/s4u/Host.hpp index 15972ced07..ab6cb8b886 100644 --- a/include/simgrid/s4u/Host.hpp +++ b/include/simgrid/s4u/Host.hpp @@ -108,6 +108,7 @@ public: int getPstatesCount() const; void setPstate(int pstate_index); int getPstate(); + std::vector get_attached_storages(); XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_attached_storages() instead.") void getAttachedStorages( std::vector* storages); diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index 1fbbf945ff..cdbc5a9f9c 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -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(); } /** diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index b069dc9930..4d6329f18a 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -93,11 +93,11 @@ CpuCas01::CpuCas01(CpuCas01Model* model, simgrid::s4u::Host* host, std::vector * 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); + cores_count_ * speed_.scale * speed_.peak); while ((var = get_constraint()->get_variable(&elem))) { CpuCas01Action* action = static_cast(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(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(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"); diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 7cd104de73..727c60240b 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -73,7 +73,7 @@ Cpu::Cpu(kernel::resource::Model* model, simgrid::s4u::Host* host, std::vector* 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()); @@ -84,41 +84,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(speedPerPstate_.size()), + xbt_assert(pstate_index <= static_cast(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(speedPerPstate_.size())); + get_cname(), pstate_index, static_cast(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(speedPerPstate_.size())), "Invalid parameters (pstate index out of bounds)"); + xbt_assert((pstate_index <= static_cast(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) @@ -136,16 +137,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) { diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index e92c13320f..10f6232abb 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -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,16 +119,16 @@ 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; + int cores_count_ = 1; simgrid::s4u::Host* host_; - std::vector speedPerPstate_; /*< List of supported CPU capacities (pstate related) */ + std::vector speed_per_pstate_; /*< List of supported CPU capacities (pstate related) */ int pstate_ = 0; /*< Current pstate (index in the speedPeakList)*/ 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). */ @@ -136,7 +136,7 @@ public: 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}; }; diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index d15f1d2d58..befaa7498e 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -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"); diff --git a/src/surf/plugins/host_energy.cpp b/src/surf/plugins/host_energy.cpp index 82fe90d338..f34657686b 100644 --- a/src/surf/plugins/host_energy.cpp +++ b/src/surf/plugins/host_energy.cpp @@ -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 diff --git a/src/surf/plugins/host_load.cpp b/src/surf/plugins/host_load.cpp index 94e8966a31..d915b593b3 100644 --- a/src/surf/plugins/host_load.cpp +++ b/src/surf/plugins/host_load.cpp @@ -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(host)) // Ignore virtual machines return; diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index d1485bfb1a..590dae1fef 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -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(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"); diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index e7374e59c4..4ecc5c44b8 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -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); } -- 2.20.1