X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/040d8fa855d2b6ac9884f68108a09b935570be21..3e8cbdbebfce89fb0abf0cb8710c8505e111d097:/src/plugins/host_energy.cpp diff --git a/src/plugins/host_energy.cpp b/src/plugins/host_energy.cpp index 4fbb275e71..32af0e36b4 100644 --- a/src/plugins/host_energy.cpp +++ b/src/plugins/host_energy.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2010-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. */ @@ -94,8 +94,8 @@ This encodes the following values: To change the pstate of a given CPU, use the following functions: -:cpp:func:`MSG_host_get_nb_pstates()`, :cpp:func:`simgrid::s4u::Host::set_pstate()`, -:cpp:func:`MSG_host_get_power_peak_at()`. +:cpp:func:`sg_host_get_nb_pstates()`, :cpp:func:`simgrid::s4u::Host::set_pstate()`, +:cpp:func:`sg_host_get_pstate_speed()`. .. raw:: html @@ -115,8 +115,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(host_energy, kernel, "Logging specific to the ho // Forwards declaration needed to make this function a friend (because friends have external linkage by default) static void on_simulation_end(); -namespace simgrid { -namespace plugin { +namespace simgrid::plugin { class PowerRange { public: @@ -217,10 +216,10 @@ HostEnergy::HostEnergy(simgrid::s4u::Host* ptr) : host_(ptr) const char* off_power_str = host_->get_property("wattage_off"); if (off_power_str != nullptr) { try { - this->watts_off_ = std::stod(std::string(off_power_str)); + this->watts_off_ = std::stod(off_power_str); } catch (const std::invalid_argument&) { - throw std::invalid_argument(std::string("Invalid value for property wattage_off of host ") + host_->get_cname() + - ": " + off_power_str); + throw std::invalid_argument("Invalid value for property wattage_off of host " + host_->get_name() + ": " + + off_power_str); } } /* watts_off is 0 by default */ @@ -333,7 +332,7 @@ double HostEnergy::get_current_watts_value(double cpu_load) const double HostEnergy::get_consumed_energy() { if (last_updated_ < simgrid::s4u::Engine::get_clock()) // We need to simcall this as it modifies the environment - simgrid::kernel::actor::simcall(std::bind(&HostEnergy::update, this)); + simgrid::kernel::actor::simcall_answered(std::bind(&HostEnergy::update, this)); return total_energy_; } @@ -391,8 +390,7 @@ void HostEnergy::init_watts_range_list() has_pstate_power_values_ = true; } -} // namespace plugin -} // namespace simgrid +} // namespace simgrid::plugin using simgrid::plugin::HostEnergy; @@ -414,8 +412,7 @@ static void on_action_state_change(simgrid::kernel::resource::CpuAction const& a simgrid::s4u::Host* host = cpu->get_iface(); if (host != nullptr) { // If it's a VM, take the corresponding PM - const simgrid::s4u::VirtualMachine* vm = dynamic_cast(host); - if (vm) // If it's a VM, take the corresponding PM + if (const auto* vm = dynamic_cast(host)) host = vm->get_pm(); // Get the host_energy extension for the relevant host @@ -492,8 +489,7 @@ void sg_host_energy_plugin_init() simgrid::s4u::Exec::on_start_cb([](simgrid::s4u::Exec const& activity) { if (activity.get_host_number() == 1) { // We only run on one host simgrid::s4u::Host* host = activity.get_host(); - const simgrid::s4u::VirtualMachine* vm = dynamic_cast(host); - if (vm != nullptr) + if (const auto* vm = dynamic_cast(host)) host = vm->get_pm(); xbt_assert(host != nullptr); host->extension()->update(); @@ -509,7 +505,7 @@ void sg_host_energy_plugin_init() */ void sg_host_energy_update_all() { - simgrid::kernel::actor::simcall([]() { + simgrid::kernel::actor::simcall_answered([]() { std::vector list = simgrid::s4u::Engine::get_instance()->get_all_hosts(); for (auto const& host : list) if (dynamic_cast(host) == nullptr) { // Ignore virtual machines