40#include <unordered_map>
43#include "debug/PowerDomain.hh"
51 pwrStateUpdateEvent(*this),
59 leader->setControlledDomain(
this);
82 for (
const auto &obj : objs) {
83 const auto & states = obj->getPossibleStates();
84 auto it = states.find(enums::PwrState::ON);
86 "%s in %s does not have the required power states to be "
87 "part of a PowerDomain i.e. the ON state!", obj->name(),
103 fatal_if(leader == follower,
"%s is both a leader and follower"
104 " in %s\n!", leader->name(),
name());
110 enums::PwrState pws = leader->get();
111 fatal_if(pws == enums::PwrState::UNDEFINED,
112 "%s is in the UNDEFINED power state, not acceptable as "
113 "leader!", leader->name());
126 for (
const auto &obj : objs) {
127 const auto &obj_states = obj->getPossibleStates();
128 if (obj_states.find(p_state) == obj_states.end()) {
140 for (
auto p_state:
leaders[0]->getPossibleStates()) {
144 enums::PwrStateStrings[p_state]);
154 enums::PwrState most_perf_state = enums::PwrState::Num_PwrState;
155 std::string most_perf_leader;
157 enums::PwrState pw = leader->get();
158 if (pw < most_perf_state) {
159 most_perf_state = pw;
160 most_perf_leader = leader->name();
163 assert(most_perf_state != enums::PwrState::Num_PwrState);
165 most_perf_leader, most_perf_state);
169 if (!f_states.empty()) {
170 for (enums::PwrState f_pw : f_states ) {
173 if ((f_pw != enums::PwrState::UNDEFINED) &&
174 (f_pw < most_perf_state)) {
175 most_perf_state = f_pw;
179 "is %u\n", most_perf_state);
181 return most_perf_state;
191 enums::PwrState actual_pws =
193 matched_states.push_back(actual_pws);
201 enums::PwrState new_power_state =
209 set(new_power_state);
240 "be updated in %u ticks\n", old_target_state,
248 : statistics::
Group(&pd),
249 ADD_STAT(numLeaderCalls, statistics::units::Count::get(),
250 "Number of calls by leaders to change power domain state"),
251 ADD_STAT(numLeaderCallsChangingState, statistics::units::Count::get(),
252 "Number of calls by leader to change power domain state actually "
253 "resulting in a power state change")
265 numLeaderCallsChangingState
virtual std::string name() const
The PowerDomain groups PowerState objects together to regulate their power states.
PowerDomain(const PowerDomainParams &p)
std::vector< PowerState * > followers
List of all followers in the PowerDomain.
enums::PwrState calculatePowerDomainState(const std::vector< enums::PwrState > &f_states={})
Calculate the power state of the power domain, based upon the power states of the leaders.
void calculatePossiblePwrStates()
Calculate the possible power states of the domain based upon the intersection of the power states of ...
void startup() override
During startup, the list of possible power states the PowerDomain can be in is populated,...
void addFollower(PowerState *pwr_obj) override
Function called by a follower to register itself as a dependant of this power domain.
void pwrStateChangeCallback(enums::PwrState new_pwr_state, PowerState *leader)
Register the change in power state in one of the leader.
enums::PwrState leaderTargetState
Power state requested by the leader.
const Tick updateLatency
Latency with which power state changes of the leaders will ripple through to the followers.
gem5::PowerDomain::PowerDomainStats stats
void setFollowerPowerStates()
Update the followers of the newly updated power state.
std::vector< PowerState * > leaders
List of all leaders in the PowerDomain.
bool isPossiblePwrState(enums::PwrState p_state)
Check if a given p_state is available across all leaders and followers in this domain.
MemberEventWrapper<&PowerDomain::setFollowerPowerStates > pwrStateUpdateEvent
Event to update the power states of the followers.
Helper class for objects that have power states.
enums::PwrState _currState
To keep track of the current power state.
std::set< enums::PwrState > possibleStates
The possible power states this object can be in.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
void schedule(Event &event, Tick when)
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
virtual void regStats()
Callback to set stat parameters.
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.
void regStats() override
Callback to set stat parameters.
statistics::Scalar numLeaderCalls
PowerDomainStats(PowerDomain &pd)
statistics::Scalar numLeaderCallsChangingState