X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c04075c49b6bc68df4f37240b4ac53e7a108abaa..c6683b41cf9ecda70c1d4d75d1effc61903a894f:/src/plugins/vm/dirty_page_tracking.cpp diff --git a/src/plugins/vm/dirty_page_tracking.cpp b/src/plugins/vm/dirty_page_tracking.cpp index f4ba064da6..7fdee49640 100644 --- a/src/plugins/vm/dirty_page_tracking.cpp +++ b/src/plugins/vm/dirty_page_tracking.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2017-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2017-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. */ @@ -10,9 +10,7 @@ #include "src/kernel/activity/ExecImpl.hpp" #include "src/kernel/resource/VirtualMachineImpl.hpp" -namespace simgrid { -namespace plugin { -namespace vm { +namespace simgrid::plugin::vm { class DirtyPageTrackingExt { bool dp_tracking_ = false; std::map dp_objs_; @@ -49,17 +47,17 @@ simgrid::xbt::Extensionget_remaining(); + for (auto const& [exec, _] : dp_objs_) + dp_objs_[exec] = exec->get_remaining(); } double DirtyPageTrackingExt::computed_flops_lookup() { double total = 0; - for (auto const& elm : dp_objs_) { - total += elm.second - elm.first->get_remaining(); - dp_objs_[elm.first] = elm.first->get_remaining(); + for (auto const& [exec, flops] : dp_objs_) { + total += flops - exec->get_remaining(); + dp_objs_[exec] = exec->get_remaining(); } total += dp_updated_by_deleted_tasks_; @@ -67,9 +65,7 @@ double DirtyPageTrackingExt::computed_flops_lookup() return total; } -} // namespace vm -} // namespace plugin -} // namespace simgrid +} // namespace simgrid::plugin::vm using simgrid::plugin::vm::DirtyPageTrackingExt; @@ -80,7 +76,7 @@ static void on_virtual_machine_creation(const simgrid::s4u::VirtualMachine& vm) static void on_exec_creation(simgrid::s4u::Exec const& e) { - auto exec = static_cast(e.get_impl()); + auto* exec = static_cast(e.get_impl()); const simgrid::s4u::VirtualMachine* vm = dynamic_cast(exec->get_host()); if (vm == nullptr) return; @@ -92,9 +88,9 @@ static void on_exec_creation(simgrid::s4u::Exec const& e) } } -static void on_exec_completion(const simgrid::s4u::Activity& e) +static void on_exec_completion(const simgrid::s4u::Exec& e) { - const auto exec = dynamic_cast(e.get_impl()); + const auto* exec = dynamic_cast(e.get_impl()); if (exec == nullptr) return; const simgrid::s4u::VirtualMachine* vm = dynamic_cast(exec->get_host()); @@ -117,7 +113,7 @@ void sg_vm_dirty_page_tracking_init() simgrid::kernel::resource::VirtualMachineImpl::extension_create(); simgrid::s4u::VirtualMachine::on_creation_cb(&on_virtual_machine_creation); simgrid::s4u::Exec::on_start_cb(&on_exec_creation); - simgrid::s4u::Activity::on_completion_cb(&on_exec_completion); + simgrid::s4u::Exec::on_completion_cb(&on_exec_completion); } }