From 0617119206ff65bfdad4e484f653638abbc3c747 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 2 Apr 2018 23:06:30 +0200 Subject: [PATCH] snake_case in resource::Resource --- include/simgrid/kernel/resource/Resource.hpp | 21 +++++------ src/kernel/resource/Resource.cpp | 14 ++++---- src/plugins/vm/VirtualMachineImpl.cpp | 6 ++-- src/s4u/s4u_host.cpp | 6 ++-- src/s4u/s4u_link.cpp | 10 ++---- src/simix/smx_host.cpp | 2 +- src/surf/HostImpl.cpp | 2 +- src/surf/StorageImpl.cpp | 14 ++++---- src/surf/StorageImpl.hpp | 4 +-- src/surf/cpu_cas01.cpp | 37 ++++++++++---------- src/surf/cpu_ti.cpp | 22 ++++++------ src/surf/network_cm02.cpp | 37 ++++++++++---------- src/surf/network_interface.cpp | 16 ++++----- src/surf/network_interface.hpp | 4 +-- src/surf/plugins/host_energy.cpp | 2 +- src/surf/plugins/host_load.cpp | 6 ++-- src/surf/ptask_L07.cpp | 34 +++++++++--------- src/surf/storage_n11.cpp | 6 ++-- 18 files changed, 118 insertions(+), 125 deletions(-) diff --git a/include/simgrid/kernel/resource/Resource.hpp b/include/simgrid/kernel/resource/Resource.hpp index ee037cd3b7..d6ac71fd2c 100644 --- a/include/simgrid/kernel/resource/Resource.hpp +++ b/include/simgrid/kernel/resource/Resource.hpp @@ -35,7 +35,7 @@ public: virtual ~Resource(); /** @brief Get the Model of the current Resource */ - Model* model() const; + Model* get_model() const; /** @brief Get the name of the current Resource */ const std::string& get_name() const; @@ -44,28 +44,23 @@ public: bool operator==(const Resource& other) const; - /** - * @brief Apply an event of external load event to that resource - * - * @param event What happened - * @param value [TODO] - */ + /** @brief Apply an event of external load event to that resource */ virtual void apply_event(TraceEvent* event, double value) = 0; /** @brief Check if the current Resource is used (if it currently serves an action) */ virtual bool is_used() = 0; /** @brief returns the current load (in flops per second, byte per second or similar) */ - virtual double getLoad(); + virtual double get_load(); /** @brief Check if the current Resource is active */ - virtual bool isOn() const; + virtual bool is_on() const; /** @brief Check if the current Resource is shut down */ - virtual bool isOff() const; + virtual bool is_off() const; /** @brief Turn on the current Resource */ - virtual void turnOn(); + virtual void turn_on(); /** @brief Turn off the current Resource */ - virtual void turnOff(); + virtual void turn_off(); private: std::string name_; @@ -74,7 +69,7 @@ private: public: /* LMM */ /** @brief Get the lmm constraint associated to this Resource if it is part of a LMM component (or null if none) */ - kernel::lmm::Constraint* constraint() const; + lmm::Constraint* get_constraint() const; private: kernel::lmm::Constraint* const constraint_ = nullptr; diff --git a/src/kernel/resource/Resource.cpp b/src/kernel/resource/Resource.cpp index 6b9ffe17a2..72899f059f 100644 --- a/src/kernel/resource/Resource.cpp +++ b/src/kernel/resource/Resource.cpp @@ -18,31 +18,31 @@ Resource::Resource(Model* model, const std::string& name, lmm::Constraint* const Resource::~Resource() = default; -bool Resource::isOn() const +bool Resource::is_on() const { return is_on_; } -bool Resource::isOff() const +bool Resource::is_off() const { return not is_on_; } -void Resource::turnOn() +void Resource::turn_on() { is_on_ = true; } -void Resource::turnOff() +void Resource::turn_off() { is_on_ = false; } -double Resource::getLoad() +double Resource::get_load() { return constraint_->get_usage(); } -Model* Resource::model() const +Model* Resource::get_model() const { return model_; } @@ -62,7 +62,7 @@ bool Resource::operator==(const Resource& other) const return name_ == other.name_; } -kernel::lmm::Constraint* Resource::constraint() const +kernel::lmm::Constraint* Resource::get_constraint() const { return constraint_; } diff --git a/src/plugins/vm/VirtualMachineImpl.cpp b/src/plugins/vm/VirtualMachineImpl.cpp index c8fd8c3c14..025fc56221 100644 --- a/src/plugins/vm/VirtualMachineImpl.cpp +++ b/src/plugins/vm/VirtualMachineImpl.cpp @@ -97,9 +97,9 @@ double VMModel::next_occuring_event(double now) // this VM got in the sharing on the PM XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, ws_vm->get_cname(), ws_vm->getPm()->get_cname()); - xbt_assert(cpu->model() == surf_cpu_model_vm); - kernel::lmm::System* vcpu_system = cpu->model()->get_maxmin_system(); - vcpu_system->update_constraint_bound(cpu->constraint(), virt_overhead * solved_value); + xbt_assert(cpu->get_model() == surf_cpu_model_vm); + kernel::lmm::System* vcpu_system = cpu->get_model()->get_maxmin_system(); + vcpu_system->update_constraint_bound(cpu->get_constraint(), virt_overhead * solved_value); } /* 2. Calculate resource share at the virtual machine layer. */ diff --git a/src/s4u/s4u_host.cpp b/src/s4u/s4u_host.cpp index 5cb5695a27..14d3a0ea59 100644 --- a/src/s4u/s4u_host.cpp +++ b/src/s4u/s4u_host.cpp @@ -103,7 +103,7 @@ void Host::turnOn() { if (isOff()) { simgrid::simix::kernelImmediate([this] { this->extension()->turnOn(); - this->pimpl_cpu->turnOn(); + this->pimpl_cpu->turn_on(); onStateChange(*this); }); } @@ -120,7 +120,7 @@ void Host::turnOff() { } bool Host::isOn() { - return this->pimpl_cpu->isOn(); + return this->pimpl_cpu->is_on(); } int Host::getPstatesCount() const @@ -270,7 +270,7 @@ void Host::execute(double flops) double Host::getLoad() { - return this->pimpl_cpu->getLoad(); + return this->pimpl_cpu->get_load(); } } // namespace simgrid diff --git a/src/s4u/s4u_link.cpp b/src/s4u/s4u_link.cpp index a7d6c2a085..d9a5089527 100644 --- a/src/s4u/s4u_link.cpp +++ b/src/s4u/s4u_link.cpp @@ -114,20 +114,16 @@ int Link::sharingPolicy() double Link::getUsage() { - return this->pimpl_->constraint()->get_usage(); + return this->pimpl_->get_constraint()->get_usage(); } void Link::turnOn() { - simgrid::simix::kernelImmediate([this]() { - this->pimpl_->turnOn(); - }); + simgrid::simix::kernelImmediate([this]() { this->pimpl_->turn_on(); }); } void Link::turnOff() { - simgrid::simix::kernelImmediate([this]() { - this->pimpl_->turnOff(); - }); + simgrid::simix::kernelImmediate([this]() { this->pimpl_->turn_off(); }); } void* Link::getData() diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index 29a81f4e37..a4ab78c2a9 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -70,7 +70,7 @@ void SIMIX_host_off(sg_host_t h, smx_actor_t issuer) xbt_assert((host != nullptr), "Invalid parameters"); if (h->isOn()) { - h->pimpl_cpu->turnOff(); + h->pimpl_cpu->turn_off(); /* Clean Simulator data */ if (not host->process_list.empty()) { diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index d910bac429..f4c07b3239 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -29,7 +29,7 @@ void HostModel::ignore_empty_vm_in_pm_LMM() /* iterate for all virtual machines */ for (s4u::VirtualMachine* const& ws_vm : vm::VirtualMachineImpl::allVms_) { Cpu* cpu = ws_vm->pimpl_cpu; - int active_tasks = cpu->constraint()->get_variable_amount(); + int active_tasks = cpu->get_constraint()->get_variable_amount(); /* The impact of the VM over its PM is the min between its vCPU amount and the amount of tasks it contains */ int impact = std::min(active_tasks, ws_vm->getImpl()->coreAmount()); diff --git a/src/surf/StorageImpl.cpp b/src/surf/StorageImpl.cpp index 2916346406..999ec2a7a0 100644 --- a/src/surf/StorageImpl.cpp +++ b/src/surf/StorageImpl.cpp @@ -54,7 +54,7 @@ StorageImpl::StorageImpl(kernel::resource::Model* model, std::string name, kerne , size_(size) , attach_(attach) { - StorageImpl::turnOn(); + StorageImpl::turn_on(); XBT_DEBUG("Create resource with Bread '%f' Bwrite '%f' and Size '%llu'", bread, bwrite, size); constraintRead_ = maxminSystem->constraint_new(this, bread); constraintWrite_ = maxminSystem->constraint_new(this, bwrite); @@ -76,17 +76,17 @@ void StorageImpl::apply_event(tmgr_trace_event_t /*event*/, double /*value*/) THROW_UNIMPLEMENTED; } -void StorageImpl::turnOn() +void StorageImpl::turn_on() { - if (isOff()) { - Resource::turnOn(); + if (is_off()) { + Resource::turn_on(); storageStateChangedCallbacks(this, 0, 1); } } -void StorageImpl::turnOff() +void StorageImpl::turn_off() { - if (isOn()) { - Resource::turnOff(); + if (is_on()) { + Resource::turn_off(); storageStateChangedCallbacks(this, 1, 0); } } diff --git a/src/surf/StorageImpl.hpp b/src/surf/StorageImpl.hpp index f0c29a699b..5e2f7e0e81 100644 --- a/src/surf/StorageImpl.hpp +++ b/src/surf/StorageImpl.hpp @@ -98,8 +98,8 @@ public: void apply_event(tmgr_trace_event_t event, double value) override; - void turnOn() override; - void turnOff() override; + void turn_on() override; + void turn_off() override; /** * @brief Read a file diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index a9a81104ff..d03c3c09f1 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -96,7 +96,7 @@ CpuCas01::CpuCas01(CpuCas01Model* model, simgrid::s4u::Host* host, std::vector * CpuCas01::getSpeedPeakList(){ bool CpuCas01::is_used() { - return model()->get_maxmin_system()->constraint_used(constraint()); + return get_model()->get_maxmin_system()->constraint_used(get_constraint()); } /** @brief take into account changes of speed (either load or max) */ @@ -114,12 +114,13 @@ void CpuCas01::onSpeedChange() { kernel::lmm::Variable* var = nullptr; const_lmm_element_t elem = nullptr; - model()->get_maxmin_system()->update_constraint_bound(constraint(), coresAmount_ * speed_.scale * speed_.peak); - while ((var = constraint()->get_variable(&elem))) { + get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(), + coresAmount_ * speed_.scale * speed_.peak); + while ((var = get_constraint()->get_variable(&elem))) { CpuCas01Action* action = static_cast(var->get_id()); - model()->get_maxmin_system()->update_variable_bound(action->get_variable(), - action->requestedCore() * speed_.scale * speed_.peak); + get_model()->get_maxmin_system()->update_variable_bound(action->get_variable(), + action->requestedCore() * speed_.scale * speed_.peak); } Cpu::onSpeedChange(); @@ -140,16 +141,16 @@ void CpuCas01::apply_event(tmgr_trace_event_t event, double value) xbt_assert(coresAmount_ == 1, "FIXME: add state change code also for constraint_core[i]"); if (value > 0) { - if(isOff()) + if (is_off()) host_that_restart.push_back(getHost()); - turnOn(); + turn_on(); } else { - kernel::lmm::Constraint* cnst = constraint(); + kernel::lmm::Constraint* cnst = get_constraint(); kernel::lmm::Variable* var = nullptr; const_lmm_element_t elem = nullptr; double date = surf_get_clock(); - turnOff(); + turn_off(); while ((var = cnst->get_variable(&elem))) { kernel::resource::Action* action = static_cast(var->get_id()); @@ -172,12 +173,12 @@ void CpuCas01::apply_event(tmgr_trace_event_t event, double value) /** @brief Start a new execution on this CPU lasting @param size flops and using one core */ CpuAction* CpuCas01::execution_start(double size) { - return new CpuCas01Action(model(), size, isOff(), speed_.scale * speed_.peak, constraint()); + return new CpuCas01Action(get_model(), size, is_off(), speed_.scale * speed_.peak, get_constraint()); } CpuAction* CpuCas01::execution_start(double size, int requestedCores) { - return new CpuCas01Action(model(), size, isOff(), speed_.scale * speed_.peak, constraint(), requestedCores); + return new CpuCas01Action(get_model(), size, is_off(), speed_.scale * speed_.peak, get_constraint(), requestedCores); } CpuAction *CpuCas01::sleep(double duration) @@ -186,7 +187,7 @@ CpuAction *CpuCas01::sleep(double duration) duration = std::max(duration, sg_surf_precision); XBT_IN("(%s,%g)", get_cname(), duration); - CpuCas01Action* action = new CpuCas01Action(model(), 1.0, isOff(), speed_.scale * speed_.peak, constraint()); + CpuCas01Action* action = new CpuCas01Action(get_model(), 1.0, is_off(), speed_.scale * speed_.peak, get_constraint()); // FIXME: sleep variables should not consume 1.0 in System::expand() action->set_max_duration(duration); @@ -194,16 +195,16 @@ CpuAction *CpuCas01::sleep(double duration) if (duration < 0) { // NO_MAX_DURATION /* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */ simgrid::xbt::intrusive_erase(*action->get_state_set(), *action); - action->state_set_ = &static_cast(model())->cpuRunningActionSetThatDoesNotNeedBeingChecked_; + action->state_set_ = &static_cast(get_model())->cpuRunningActionSetThatDoesNotNeedBeingChecked_; action->get_state_set()->push_back(*action); } - model()->get_maxmin_system()->update_variable_weight(action->get_variable(), 0.0); - if (model()->get_update_algorithm() == kernel::resource::Model::UpdateAlgo::Lazy) { // remove action from the heap - model()->get_action_heap().remove(action); + get_model()->get_maxmin_system()->update_variable_weight(action->get_variable(), 0.0); + if (get_model()->get_update_algorithm() == kernel::resource::Model::UpdateAlgo::Lazy) { // remove action from the heap + get_model()->get_action_heap().remove(action); // this is necessary for a variable with weight 0 since such variables are ignored in lmm and we need to set its // max_duration correctly at the next call to share_resources - model()->get_modified_set()->push_front(*action); + get_model()->get_modified_set()->push_front(*action); } XBT_OUT(); diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 5800817ed9..c1c9ec471f 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -411,11 +411,11 @@ void CpuTi::apply_event(tmgr_trace_event_t event, double value) } else if (event == stateEvent_) { if (value > 0) { - if(isOff()) + if (is_off()) host_that_restart.push_back(getHost()); - turnOn(); + turn_on(); } else { - turnOff(); + turn_off(); double date = surf_get_clock(); /* put all action running on cpu to failed */ @@ -425,7 +425,7 @@ void CpuTi::apply_event(tmgr_trace_event_t event, double value) action.get_state() == kernel::resource::Action::State::not_in_the_system) { action.set_finish_time(date); action.set_state(kernel::resource::Action::State::failed); - model()->get_action_heap().remove(&action); + get_model()->get_action_heap().remove(&action); } } } @@ -485,9 +485,9 @@ void CpuTi::update_actions_finish_time(double now) } /* add in action heap */ if (min_finish > NO_MAX_DURATION) - model()->get_action_heap().update(&action, min_finish, kernel::resource::ActionHeap::Type::unset); + get_model()->get_action_heap().update(&action, min_finish, kernel::resource::ActionHeap::Type::unset); else - model()->get_action_heap().remove(&action); + get_model()->get_action_heap().remove(&action); XBT_DEBUG("Update finish time: Cpu(%s) Action: %p, Start Time: %f Finish Time: %f Max duration %f", get_cname(), &action, action.get_start_time(), action.get_finish_time(), action.get_max_duration()); @@ -520,7 +520,7 @@ void CpuTi::update_remaining_amount(double now) XBT_DEBUG("Flops total: %f, Last update %f", area_total, last_update_); for (CpuTiAction& action : action_set_) { /* action not running, skip it */ - if (action.get_state_set() != model()->get_running_action_set()) + if (action.get_state_set() != get_model()->get_running_action_set()) continue; /* bogus priority, skip it */ @@ -549,7 +549,7 @@ void CpuTi::update_remaining_amount(double now) CpuAction *CpuTi::execution_start(double size) { XBT_IN("(%s,%g)", get_cname(), size); - CpuTiAction* action = new CpuTiAction(static_cast(model()), size, isOff(), this); + CpuTiAction* action = new CpuTiAction(static_cast(get_model()), size, is_off(), this); action_set_.push_back(*action); @@ -564,14 +564,14 @@ CpuAction *CpuTi::sleep(double duration) duration = std::max(duration, sg_surf_precision); XBT_IN("(%s,%g)", get_cname(), duration); - CpuTiAction* action = new CpuTiAction(static_cast(model()), 1.0, isOff(), this); + CpuTiAction* action = new CpuTiAction(static_cast(get_model()), 1.0, is_off(), this); action->set_max_duration(duration); action->suspended_ = kernel::resource::Action::SuspendStates::sleeping; if (duration == NO_MAX_DURATION) { /* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */ simgrid::xbt::intrusive_erase(*action->get_state_set(), *action); - action->state_set_ = &static_cast(model())->runningActionSetThatDoesNotNeedBeingChecked_; + action->state_set_ = &static_cast(get_model())->runningActionSetThatDoesNotNeedBeingChecked_; action->get_state_set()->push_back(*action); } @@ -583,7 +583,7 @@ CpuAction *CpuTi::sleep(double duration) void CpuTi::set_modified(bool modified) { - CpuTiList& modifiedCpu = static_cast(model())->modified_cpus_; + CpuTiList& modifiedCpu = static_cast(get_model())->modified_cpus_; if (modified) { if (not cpu_ti_hook.is_linked()) { modifiedCpu.push_back(*this); diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 64f405bd87..c264794bd2 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -256,13 +256,13 @@ kernel::resource::Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Hos src->get_cname(), dst->get_cname()); for (auto const& link : route) - if (link->isOff()) + if (link->is_off()) failed = 1; if (sg_network_crosstraffic == 1) { dst->routeTo(src, back_route, nullptr); for (auto const& link : back_route) - if (link->isOff()) + if (link->is_off()) failed = 1; } @@ -319,12 +319,12 @@ kernel::resource::Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Hos } for (auto const& link : route) - get_maxmin_system()->expand(link->constraint(), action->get_variable(), 1.0); + get_maxmin_system()->expand(link->get_constraint(), action->get_variable(), 1.0); if (not back_route.empty()) { // sg_network_crosstraffic was activated XBT_DEBUG("Crosstraffic active adding backward flow using 5%%"); for (auto const& link : back_route) - get_maxmin_system()->expand(link->constraint(), action->get_variable(), .05); + get_maxmin_system()->expand(link->get_constraint(), action->get_variable(), .05); // Change concurrency_share here, if you want that cross-traffic is included in the SURF concurrency // (You would also have to change simgrid::kernel::lmm::Element::get_concurrency()) @@ -350,7 +350,7 @@ NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const std::string& nam latency_.peak = latency; if (policy == SURF_LINK_FATPIPE) - constraint()->unshare(); + get_constraint()->unshare(); simgrid::s4u::Link::onCreation(this->piface_); } @@ -368,14 +368,14 @@ void NetworkCm02Link::apply_event(tmgr_trace_event_t triggered, double value) } else if (triggered == stateEvent_) { if (value > 0) - turnOn(); + turn_on(); else { kernel::lmm::Variable* var = nullptr; const_lmm_element_t elem = nullptr; double now = surf_get_clock(); - turnOff(); - while ((var = constraint()->get_variable(&elem))) { + turn_off(); + while ((var = get_constraint()->get_variable(&elem))) { kernel::resource::Action* action = static_cast(var->get_id()); if (action->get_state() == kernel::resource::Action::State::running || @@ -390,15 +390,16 @@ void NetworkCm02Link::apply_event(tmgr_trace_event_t triggered, double value) xbt_die("Unknown event!\n"); } - XBT_DEBUG("There was a resource state event, need to update actions related to the constraint (%p)", constraint()); + XBT_DEBUG("There was a resource state event, need to update actions related to the constraint (%p)", + get_constraint()); } void NetworkCm02Link::setBandwidth(double value) { bandwidth_.peak = value; - model()->get_maxmin_system()->update_constraint_bound(constraint(), - sg_bandwidth_factor * (bandwidth_.peak * bandwidth_.scale)); + get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(), + sg_bandwidth_factor * (bandwidth_.peak * bandwidth_.scale)); TRACE_surf_link_set_bandwidth(surf_get_clock(), get_cname(), sg_bandwidth_factor * bandwidth_.peak * bandwidth_.scale); @@ -409,11 +410,11 @@ void NetworkCm02Link::setBandwidth(double value) const_lmm_element_t elem = nullptr; const_lmm_element_t nextelem = nullptr; int numelem = 0; - while ((var = constraint()->get_variable_safe(&elem, &nextelem, &numelem))) { + while ((var = get_constraint()->get_variable_safe(&elem, &nextelem, &numelem))) { NetworkCm02Action* action = static_cast(var->get_id()); action->weight_ += delta; if (not action->is_suspended()) - model()->get_maxmin_system()->update_variable_weight(action->get_variable(), action->weight_); + get_model()->get_maxmin_system()->update_variable_weight(action->get_variable(), action->weight_); } } } @@ -428,15 +429,15 @@ void NetworkCm02Link::setLatency(double value) latency_.peak = value; - while ((var = constraint()->get_variable_safe(&elem, &nextelem, &numelem))) { + while ((var = get_constraint()->get_variable_safe(&elem, &nextelem, &numelem))) { NetworkCm02Action* action = static_cast(var->get_id()); action->lat_current_ += delta; action->weight_ += delta; if (action->rate_ < 0) - model()->get_maxmin_system()->update_variable_bound(action->get_variable(), - sg_tcp_gamma / (2.0 * action->lat_current_)); + get_model()->get_maxmin_system()->update_variable_bound(action->get_variable(), + sg_tcp_gamma / (2.0 * action->lat_current_)); else { - model()->get_maxmin_system()->update_variable_bound( + get_model()->get_maxmin_system()->update_variable_bound( action->get_variable(), std::min(action->rate_, sg_tcp_gamma / (2.0 * action->lat_current_))); if (action->rate_ < sg_tcp_gamma / (2.0 * action->lat_current_)) { @@ -446,7 +447,7 @@ void NetworkCm02Link::setLatency(double value) } } if (not action->is_suspended()) - model()->get_maxmin_system()->update_variable_weight(action->get_variable(), action->weight_); + get_model()->get_maxmin_system()->update_variable_weight(action->get_variable(), action->weight_); } } diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index d843caa6fc..480a1a5ca3 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -133,7 +133,7 @@ namespace simgrid { bool LinkImpl::is_used() { - return model()->get_maxmin_system()->constraint_used(constraint()); + return get_model()->get_maxmin_system()->constraint_used(get_constraint()); } double LinkImpl::latency() @@ -148,20 +148,20 @@ namespace simgrid { int LinkImpl::sharingPolicy() { - return constraint()->get_sharing_policy(); + return get_constraint()->get_sharing_policy(); } - void LinkImpl::turnOn() + void LinkImpl::turn_on() { - if (isOff()) { - Resource::turnOn(); + if (is_off()) { + Resource::turn_on(); s4u::Link::onStateChange(this->piface_); } } - void LinkImpl::turnOff() + void LinkImpl::turn_off() { - if (isOn()) { - Resource::turnOff(); + if (is_on()) { + Resource::turn_off(); s4u::Link::onStateChange(this->piface_); } } diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index f29e835275..3cf8c35dee 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -143,8 +143,8 @@ public: /** @brief Check if the Link is used */ bool is_used() override; - void turnOn() override; - void turnOff() override; + void turn_on() override; + void turn_off() override; virtual void setStateTrace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). Trace must contain boolean values. */ diff --git a/src/surf/plugins/host_energy.cpp b/src/surf/plugins/host_energy.cpp index d7cbb73d77..44736f3fed 100644 --- a/src/surf/plugins/host_energy.cpp +++ b/src/surf/plugins/host_energy.cpp @@ -237,7 +237,7 @@ double HostEnergy::getCurrentWattsValue() // We consider that the machine is then fully loaded. That's arbitrary but it avoids a NaN cpu_load = 1; else - cpu_load = host->pimpl_cpu->constraint()->get_usage() / current_speed; + cpu_load = host->pimpl_cpu->get_constraint()->get_usage() / current_speed; /** Divide by the number of cores here **/ cpu_load /= host->pimpl_cpu->coreCount(); diff --git a/src/surf/plugins/host_load.cpp b/src/surf/plugins/host_load.cpp index 9fc9f0722a..5f54170b88 100644 --- a/src/surf/plugins/host_load.cpp +++ b/src/surf/plugins/host_load.cpp @@ -60,7 +60,7 @@ HostLoad::HostLoad(simgrid::s4u::Host* ptr) , last_updated(surf_get_clock()) , last_reset(surf_get_clock()) , current_speed(host->getSpeed()) - , current_flops(host->pimpl_cpu->constraint()->get_usage()) + , current_flops(host->pimpl_cpu->get_constraint()->get_usage()) , theor_max_flops(0) , was_prev_idle(current_flops == 0) { @@ -74,7 +74,7 @@ void HostLoad::update() /* Current flop per second computed by the cpu; current_flops = k * pstate_speed_in_flops, k \in {0, 1, ..., cores} * number of active cores */ - current_flops = host->pimpl_cpu->constraint()->get_usage(); + current_flops = host->pimpl_cpu->get_constraint()->get_usage(); /* flops == pstate_speed * cores_being_currently_used */ computed_flops += (now - last_updated) * current_flops; @@ -137,7 +137,7 @@ void HostLoad::reset() idle_time = 0; computed_flops = 0; theor_max_flops = 0; - current_flops = host->pimpl_cpu->constraint()->get_usage(); + current_flops = host->pimpl_cpu->get_constraint()->get_usage(); current_speed = host->getSpeed(); was_prev_idle = (current_flops == 0); } diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 0b04f618f4..0e41e5625a 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -125,7 +125,7 @@ void HostL07Model::update_actions_state(double /*now*/, double delta) while (cnst != nullptr) { i++; void* constraint_id = cnst->get_id(); - if (static_cast(constraint_id)->isOff()) { + if (static_cast(constraint_id)->is_off()) { XBT_DEBUG("Action (%p) Failed!!", &action); action.finish(kernel::resource::Action::State::failed); break; @@ -189,7 +189,7 @@ L07Action::L07Action(kernel::resource::Model* model, int host_nb, sg_host_t* hos model->get_maxmin_system()->update_variable_weight(get_variable(), 0.0); for (int i = 0; i < host_nb; i++) - model->get_maxmin_system()->expand(host_list[i]->pimpl_cpu->constraint(), get_variable(), flops_amount[i]); + model->get_maxmin_system()->expand(host_list[i]->pimpl_cpu->get_constraint(), get_variable(), flops_amount[i]); if(bytes_amount != nullptr) { for (int i = 0; i < host_nb; i++) { @@ -199,7 +199,7 @@ L07Action::L07Action(kernel::resource::Model* model, int host_nb, sg_host_t* hos hostList_->at(i)->routeTo(hostList_->at(j), route, nullptr); for (auto const& link : route) - model->get_maxmin_system()->expand_add(link->constraint(), this->get_variable(), + model->get_maxmin_system()->expand_add(link->get_constraint(), this->get_variable(), bytes_amount[i * host_nb + j]); } } @@ -256,7 +256,7 @@ LinkL07::LinkL07(NetworkL07Model* model, const std::string& name, double bandwid latency_.peak = latency; if (policy == SURF_LINK_FATPIPE) - constraint()->unshare(); + get_constraint()->unshare(); s4u::Link::onCreation(this->piface_); } @@ -269,7 +269,7 @@ kernel::resource::Action* CpuL07::execution_start(double size) host_list[0] = getHost(); flops_amount[0] = size; - return static_cast(model())->hostModel_->execute_parallel(1, host_list, flops_amount, nullptr, -1); + return static_cast(get_model())->hostModel_->execute_parallel(1, host_list, flops_amount, nullptr, -1); } kernel::resource::Action* CpuL07::sleep(double duration) @@ -277,14 +277,14 @@ kernel::resource::Action* CpuL07::sleep(double duration) L07Action *action = static_cast(execution_start(1.0)); action->set_max_duration(duration); action->suspended_ = kernel::resource::Action::SuspendStates::sleeping; - model()->get_maxmin_system()->update_variable_weight(action->get_variable(), 0.0); + get_model()->get_maxmin_system()->update_variable_weight(action->get_variable(), 0.0); return action; } bool CpuL07::is_used() { - return model()->get_maxmin_system()->constraint_used(constraint()); + return get_model()->get_maxmin_system()->constraint_used(get_constraint()); } /** @brief take into account changes of speed (either load or max) */ @@ -292,11 +292,11 @@ void CpuL07::onSpeedChange() { kernel::lmm::Variable* var = nullptr; const_lmm_element_t elem = nullptr; - model()->get_maxmin_system()->update_constraint_bound(constraint(), speed_.peak * speed_.scale); - while ((var = constraint()->get_variable(&elem))) { + get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(), speed_.peak * speed_.scale); + while ((var = get_constraint()->get_variable(&elem))) { kernel::resource::Action* action = static_cast(var->get_id()); - model()->get_maxmin_system()->update_variable_bound(action->get_variable(), speed_.scale * speed_.peak); + get_model()->get_maxmin_system()->update_variable_bound(action->get_variable(), speed_.scale * speed_.peak); } Cpu::onSpeedChange(); @@ -304,7 +304,7 @@ void CpuL07::onSpeedChange() { bool LinkL07::is_used() { - return model()->get_maxmin_system()->constraint_used(constraint()); + return get_model()->get_maxmin_system()->constraint_used(get_constraint()); } void CpuL07::apply_event(tmgr_trace_event_t triggered, double value) @@ -317,9 +317,9 @@ void CpuL07::apply_event(tmgr_trace_event_t triggered, double value) } else if (triggered == stateEvent_) { if (value > 0) - turnOn(); + turn_on(); else - turnOff(); + turn_off(); tmgr_trace_event_unref(&stateEvent_); } else { @@ -340,9 +340,9 @@ void LinkL07::apply_event(tmgr_trace_event_t triggered, double value) } else if (triggered == stateEvent_) { if (value > 0) - turnOn(); + turn_on(); else - turnOff(); + turn_off(); tmgr_trace_event_unref(&stateEvent_); } else { @@ -353,7 +353,7 @@ void LinkL07::apply_event(tmgr_trace_event_t triggered, double value) void LinkL07::setBandwidth(double value) { bandwidth_.peak = value; - model()->get_maxmin_system()->update_constraint_bound(constraint(), bandwidth_.peak * bandwidth_.scale); + get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(), bandwidth_.peak * bandwidth_.scale); } void LinkL07::setLatency(double value) @@ -363,7 +363,7 @@ void LinkL07::setLatency(double value) const_lmm_element_t elem = nullptr; latency_.peak = value; - while ((var = constraint()->get_variable(&elem))) { + while ((var = get_constraint()->get_variable(&elem))) { action = static_cast(var->get_id()); action->updateBound(); } diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 897c3b7ab6..b2059f1b74 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -106,12 +106,12 @@ StorageN11::StorageN11(StorageModel* model, std::string name, kernel::lmm::Syste StorageAction* StorageN11::read(sg_size_t size) { - return new StorageN11Action(model(), size, isOff(), this, READ); + return new StorageN11Action(get_model(), size, is_off(), this, READ); } StorageAction* StorageN11::write(sg_size_t size) { - return new StorageN11Action(model(), size, isOff(), this, WRITE); + return new StorageN11Action(get_model(), size, is_off(), this, WRITE); } /********** @@ -125,7 +125,7 @@ StorageN11Action::StorageN11Action(kernel::resource::Model* model, double cost, XBT_IN("(%s,%g", storage->get_cname(), cost); // Must be less than the max bandwidth for all actions - model->get_maxmin_system()->expand(storage->constraint(), get_variable(), 1.0); + model->get_maxmin_system()->expand(storage->get_constraint(), get_variable(), 1.0); switch(type) { case READ: model->get_maxmin_system()->expand(storage->constraintRead_, get_variable(), 1.0); -- 2.20.1