X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c04075c49b6bc68df4f37240b4ac53e7a108abaa..b8ceec9dcbf950163eb1328573830d360ace02ee:/src/plugins/host_energy.cpp diff --git a/src/plugins/host_energy.cpp b/src/plugins/host_energy.cpp index 3b2b4839ef..6d9483d501 100644 --- a/src/plugins/host_energy.cpp +++ b/src/plugins/host_energy.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2010-2022. 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. */ @@ -110,13 +110,12 @@ before you can get accurate energy predictions. @endrst */ -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_energy, surf, "Logging specific to the SURF energy plugin"); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(host_energy, kernel, "Logging specific to the host energy plugin"); // 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: @@ -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