41 #include "debug/PowerDomain.hh" 45 SimObject(p), _currState(p->default_state),
46 possibleStates(p->possible_states.begin(),
47 p->possible_states.end()),
50 for (
auto &pm: p->leaders) {
53 pm->addFollower(
this);
70 unsigned int currState = (
unsigned int)
_currState;
79 unsigned int currState;
93 "Cannot go to %s in %s \n", Enums::PwrStateStrings[
p],
name());
97 warn_once(
"PowerState: Already in the requested power state, " 110 warn(
"PowerState: More than one power state change request " 111 "encountered within the same simulation tick");
140 Enums::PwrStateStrings[p]);
154 if (*(rev_it) <=
p) {
158 Enums::PwrStateStrings[p],
159 Enums::PwrStateStrings[*(rev_it)]);
170 "Transition to power state %s was not possible, SimObject already" 171 " in the most performance state %s",
172 Enums::PwrStateStrings[
p], Enums::PwrStateStrings[
_currState]);
189 if (
_currState == Enums::PwrState::CLK_GATED) {
208 ret.resize(Enums::PwrState::Num_PwrState);
209 for (
unsigned i = 0;
i < Enums::PwrState::Num_PwrState;
i++)
210 ret[
i] = residencies[
i] / \
220 "Number of power state transitions"),
221 ADD_STAT(numPwrMatchStateTransitions,
222 "Number of power state transitions due match request"),
224 "Distribution of time spent in the clock gated state"),
226 "Cumulative time (in ticks) in various power states")
235 using namespace Stats;
243 unsigned num_bins = std::max(p->clk_gate_bins, 10U);
245 .
init(p->clk_gate_min, p->clk_gate_max,
246 (p->clk_gate_max / num_bins))
251 .
init(Enums::PwrState::Num_PwrState)
254 for (
int i = 0;
i < Enums::PwrState::Num_PwrState;
i++) {
278 PowerStateParams::create()
const FlagsType pdf
Print the percent of the total that this entry represents.
Derived & subname(off_type index, const std::string &name)
Set the subfield name for the given index, and marks this stat to print at the end of simulation...
Enums::PwrState _currState
To keep track of the current power state.
const FlagsType nonan
Don't print if this is NAN.
void preDumpStats() override
Callback before stats are dumped.
Stats::Scalar numTransitions
Result total() const
Return a total of all entries in this vector.
PowerState(const PowerStateParams *p)
Stats::Vector pwrStateResidencyTicks
Tracks the time spent in each of the power states.
void value(VCounter &vec) const
Helper class for objects that have power states.
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
Derived & init(size_type size)
Set this vector to have the given size.
void computeStats()
Record stats values like state residency by computing the time difference from previous update...
PowerState::PowerStateStats stats
#define UNSERIALIZE_SCALAR(scalar)
virtual void preDumpStats()
Callback before stats are dumped.
Tick curTick()
The current simulated tick.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
uint64_t Tick
Tick count type.
void setControlledDomain(PowerDomain *pwr_dom)
std::set< Enums::PwrState > possibleStates
The possible power states this object can be in.
#define warn_if(cond,...)
Conditional warning macro that checks the supplied condition and only prints a warning if the conditi...
PowerStateStats(PowerState &ps)
Enums::PwrState matchPwrState(Enums::PwrState p)
Change the power state of this object to a power state equal to OR more performant than p...
void set(Enums::PwrState p)
Change the power state of this object to the power state p.
Distribution & init(Counter min, Counter max, Counter bkt)
Set the parameters of this distribution.
const Params * params() const
PowerDomain * controlledDomain
The power domain that this power state leads, nullptr if it doesn't lead any.
Stats::Scalar numPwrMatchStateTransitions
Tick prvEvalTick
Last tick the power stats were calculated.
#define SERIALIZE_SCALAR(scalar)
void pwrStateChangeCallback(Enums::PwrState new_pwr_state, PowerState *leader)
Register the change in power state in one of the leader.
The PowerDomain groups PowerState objects together to regulate their power states.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
virtual const std::string name() const
std::ostream CheckpointOut
void serialize(CheckpointOut &cp) const override
Serialize an object.
std::vector< double > getWeights() const
Returns the percentage residency for each power state.
virtual void regStats()
Callback to set stat parameters.
PowerState declaration and implementation.
const FlagsType nozero
Don't print if this is zero.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
void regStats() override
Callback to set stat parameters.
Abstract superclass for simulation objects.
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
Stats::Distribution ticksClkGated