44#include "debug/PowerDomain.hh"
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");
129 stats.numTransitions++;
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]);
182 stats.numPwrMatchStateTransitions++;
197 if (
_currState == enums::PwrState::CLK_GATED) {
198 stats.ticksClkGated.sample(elapsed_time);
210 stats.pwrStateResidencyTicks.value(residencies);
216 ret.resize(enums::PwrState::Num_PwrState);
217 for (
unsigned i = 0;
i < enums::PwrState::Num_PwrState;
i++)
218 ret[
i] = residencies[
i] / \
219 (
stats.pwrStateResidencyTicks.total() + elapsed_time);
228 "Number of power state transitions"),
230 "Number of power state transitions due match request"),
232 "Distribution of time spent in the clock gated state"),
234 "Cumulative time (in ticks) in various power states")
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)
259 .init(enums::PwrState::Num_PwrState)
262 for (
int i = 0;
i < enums::PwrState::Num_PwrState;
i++) {
virtual std::string name() const
The PowerDomain groups PowerState objects together to regulate their 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)
enums::PwrState get() const
void serialize(CheckpointOut &cp) const override
Serialize an object.
#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...
SimObject(const Params &p)
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.
std::vector< Counter > VCounter
vector of counters.
Copyright (c) 2024 Arm Limited 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