X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/27c8bce290f11b67b83f5363885c971764af9bdd..33ab927a5c7716530d8cadec7f1200976713453c:/src/kernel/resource/CpuImpl.cpp diff --git a/src/kernel/resource/CpuImpl.cpp b/src/kernel/resource/CpuImpl.cpp index 38f68695d3..d597356ef8 100644 --- a/src/kernel/resource/CpuImpl.cpp +++ b/src/kernel/resource/CpuImpl.cpp @@ -1,12 +1,13 @@ -/* Copyright (c) 2013-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2013-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. */ #include "src/kernel/resource/CpuImpl.hpp" +#include "src/kernel/EngineImpl.hpp" +#include "src/kernel/resource/models/cpu_ti.hpp" #include "src/kernel/resource/profile/Profile.hpp" -#include "src/surf/cpu_ti.hpp" -#include "src/surf/surf_interface.hpp" +#include "src/simgrid/math_utils.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_cpu, ker_resource, "CPU resource, fueling execution activites"); @@ -18,7 +19,7 @@ namespace simgrid::kernel::resource { void CpuModel::update_actions_state_lazy(double now, double /*delta*/) { - while (not get_action_heap().empty() && double_equals(get_action_heap().top_date(), now, sg_surf_precision)) { + while (not get_action_heap().empty() && double_equals(get_action_heap().top_date(), now, sg_precision_timing)) { auto* action = static_cast(get_action_heap().pop()); XBT_DEBUG("Something happened to action %p", action); @@ -66,9 +67,9 @@ CpuImpl* CpuImpl::set_pstate(unsigned long pstate_index) { xbt_assert( pstate_index < speed_per_pstate_.size(), - "Invalid parameters for CPU %s (pstate %lu >= length of pstates %d). Please fix your platform file, or your " + "Invalid parameters for CPU %s (pstate %lu >= length of pstates %zu). Please fix your platform file, or your " "call to change the pstate.", - get_cname(), pstate_index, static_cast(speed_per_pstate_.size())); + get_cname(), pstate_index, speed_per_pstate_.size()); double new_peak_speed = speed_per_pstate_[pstate_index]; pstate_ = pstate_index; @@ -89,8 +90,8 @@ CpuImpl* CpuImpl::set_pstate_speed(const std::vector& speed_per_state) double CpuImpl::get_pstate_peak_speed(unsigned long pstate_index) const { - xbt_assert((pstate_index <= speed_per_pstate_.size()), "Invalid parameters (pstate index out of bounds)"); - + xbt_assert(pstate_index < speed_per_pstate_.size(), "Invalid parameters (pstate index %lu out of bounds %zu)", + pstate_index, speed_per_pstate_.size()); return speed_per_pstate_[pstate_index]; } @@ -151,6 +152,23 @@ void CpuImpl::seal() Resource::seal(); } +void CpuImpl::turn_off() +{ + if (is_on()) { + Resource::turn_off(); + + const kernel::lmm::Element* elem = nullptr; + double now = EngineImpl::get_clock(); + while (const auto* var = get_constraint()->get_variable(&elem)) { + Action* action = var->get_id(); + if (action->get_state() == Action::State::INITED || action->get_state() == Action::State::STARTED) { + action->set_finish_time(now); + action->set_state(Action::State::FAILED); + } + } + } +} + /********** * Action * **********/