-/* 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/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");
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<CpuAction*>(get_action_heap().pop());
XBT_DEBUG("Something happened to action %p", action);
{
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<int>(speed_per_pstate_.size()));
+ get_cname(), pstate_index, speed_per_pstate_.size());
double new_peak_speed = speed_per_pstate_[pstate_index];
pstate_ = pstate_index;
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];
}
void CpuImpl::on_speed_change()
{
s4u::Host::on_speed_change(*piface_);
+ piface_->on_this_speed_change(*piface_);
}
CpuImpl* CpuImpl::set_core_count(int core_count)
Resource::seal();
}
+void CpuImpl::turn_off()
+{
+ if (is_on()) {
+ Resource::turn_off();
+ cancel_actions();
+ }
+}
+
/**********
* Action *
**********/
set_last_value(get_rate());
}
-xbt::signal<void(CpuAction const&, Action::State)> CpuAction::on_state_change;
-
-void CpuAction::suspend()
-{
- Action::State previous = get_state();
- on_state_change(*this, previous);
- Action::suspend();
-}
-
-void CpuAction::resume()
-{
- Action::State previous = get_state();
- on_state_change(*this, previous);
- Action::resume();
-}
-
void CpuAction::set_state(Action::State state)
{
Action::State previous = get_state();
Action::set_state(state);
- on_state_change(*this, previous);
+ s4u::Host::on_exec_state_change(*this, previous);
}
/** @brief returns a list of all CPUs that this action is using */