44#include "debug/PowerDomain.hh"
54 possibleStates(
p.possible_states.begin(),
55 p.possible_states.end()),
58 for (
auto &pm:
p.leaders) {
61 pm->addFollower(
this);
78 unsigned int currState = (
unsigned int)
_currState;
87 unsigned int currState;
101 "Cannot go to %s in %s \n", enums::PwrStateStrings[
p],
name());
105 warn_once(
"PowerState: Already in the requested power state, "
118 warn(
"PowerState: More than one power state change request "
119 "encountered within the same simulation tick");
148 enums::PwrStateStrings[
p]);
162 if (*(rev_it) <=
p) {
166 enums::PwrStateStrings[
p],
167 enums::PwrStateStrings[*(rev_it)]);
178 "Transition to power state %s was not possible, SimObject already"
179 " in the most performance state %s",
180 enums::PwrStateStrings[
p], enums::PwrStateStrings[
_currState]);
197 if (
_currState == enums::PwrState::CLK_GATED) {
216 ret.resize(enums::PwrState::Num_PwrState);
217 for (
unsigned i = 0;
i < enums::PwrState::Num_PwrState;
i++)
218 ret[
i] = residencies[
i] / \
225 : statistics::
Group(&co),
227 ADD_STAT(numTransitions, statistics::units::Count::get(),
228 "Number of power state transitions"),
229 ADD_STAT(numPwrMatchStateTransitions, statistics::units::Count::get(),
230 "Number of power state transitions due match request"),
232 "Distribution of time spent in the clock gated state"),
233 ADD_STAT(pwrStateResidencyTicks, statistics::units::
Tick::get(),
234 "Cumulative time (in ticks) in various power states")
243 using namespace statistics;
245 const PowerStateParams &
p = powerState.params();
247 numTransitions.flags(
nozero);
248 numPwrMatchStateTransitions.flags(
nozero);
251 unsigned num_bins = std::max(
p.clk_gate_bins, 10U);
253 .init(
p.clk_gate_min,
p.clk_gate_max,
254 (
p.clk_gate_max -
p.clk_gate_min + 1.0) / num_bins)
258 pwrStateResidencyTicks
259 .init(enums::PwrState::Num_PwrState)
262 for (
int i = 0;
i < enums::PwrState::Num_PwrState;
i++) {
263 pwrStateResidencyTicks.subname(
i, enums::PwrStateStrings[
i]);
282 powerState.computeStats();
virtual std::string name() const
The PowerDomain groups PowerState objects together to regulate their power states.
void pwrStateChangeCallback(enums::PwrState new_pwr_state, PowerState *leader)
Register the change in power state in one of the leader.
Helper class for objects that have power states.
void set(enums::PwrState p)
Change the power state of this object to the power state p.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
enums::PwrState _currState
To keep track of the current power state.
void computeStats()
Record stats values like state residency by computing the time difference from previous update.
gem5::PowerState::PowerStateStats stats
PowerState(const PowerStateParams &p)
std::vector< double > getWeights() const
Returns the percentage residency for each power state.
std::set< enums::PwrState > possibleStates
The possible power states this object can be in.
PowerDomain * controlledDomain
The power domain that this power state leads, nullptr if it doesn't lead any.
enums::PwrState matchPwrState(enums::PwrState p)
Change the power state of this object to a power state equal to OR more performant than p.
Tick prvEvalTick
Last tick the power stats were calculated.
void setControlledDomain(PowerDomain *pwr_dom)
void serialize(CheckpointOut &cp) const override
Serialize an object.
Abstract superclass for simulation objects.
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
void value(VCounter &vec) const
Result total() const
Return a total of all entries in this vector.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
virtual void regStats()
Callback to set stat parameters.
virtual void preDumpStats()
Callback before stats are dumped.
#define warn_if(cond,...)
Conditional warning macro that checks the supplied condition and only prints a warning if the conditi...
const FlagsType pdf
Print the percent of the total that this entry represents.
const FlagsType nonan
Don't print if this is NAN.
const FlagsType nozero
Don't print if this is zero.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Tick curTick()
The universal simulation clock.
std::ostream CheckpointOut
uint64_t Tick
Tick count type.
PowerState declaration and implementation.
#define UNSERIALIZE_SCALAR(scalar)
#define SERIALIZE_SCALAR(scalar)
statistics::Distribution ticksClkGated
statistics::Vector pwrStateResidencyTicks
Tracks the time spent in each of the power states.
PowerStateStats(PowerState &ps)
void regStats() override
Callback to set stat parameters.
void preDumpStats() override
Callback before stats are dumped.
statistics::Scalar numPwrMatchStateTransitions
statistics::Scalar numTransitions