40 #include <unordered_map> 43 #include "debug/PowerDomain.hh" 48 pwrStateUpdateEvent(*this),
56 leader->setControlledDomain(
this);
79 for (
const auto &obj : objs) {
80 const auto & states = obj->getPossibleStates();
81 auto it = states.find(Enums::PwrState::ON);
83 "%s in %s does not have the required power states to be " 84 "part of a PowerDomain i.e. the ON state!", obj->name(),
100 fatal_if(leader == follower,
"%s is both a leader and follower" 101 " in %s\n!", leader->name(),
name());
107 Enums::PwrState pws = leader->get();
108 fatal_if(pws == Enums::PwrState::UNDEFINED,
109 "%s is in the UNDEFINED power state, not acceptable as " 110 "leader!", leader->name());
123 for (
const auto &obj : objs) {
124 const auto &obj_states = obj->getPossibleStates();
125 if (obj_states.find(p_state) == obj_states.end()) {
141 Enums::PwrStateStrings[p_state]);
151 Enums::PwrState most_perf_state = Enums::PwrState::Num_PwrState;
152 std::string most_perf_leader;
154 Enums::PwrState pw = leader->get();
155 if (pw < most_perf_state) {
156 most_perf_state = pw;
157 most_perf_leader = leader->name();
160 assert(most_perf_state != Enums::PwrState::Num_PwrState);
162 most_perf_leader, most_perf_state);
166 if (!f_states.empty()) {
167 for (Enums::PwrState f_pw : f_states ) {
170 if ((f_pw != Enums::PwrState::UNDEFINED) &&
171 (f_pw < most_perf_state)) {
172 most_perf_state = f_pw;
176 "is %u\n", most_perf_state);
178 return most_perf_state;
188 Enums::PwrState actual_pws =
190 matched_states.push_back(actual_pws);
198 Enums::PwrState new_power_state =
206 set(new_power_state);
237 "be updated in %u ticks\n", old_target_state,
247 "Number of calls by leaders to change power domain state"),
248 ADD_STAT(numLeaderCallsChangingState,
249 "Number of calls by leader to change power domain state " 250 "actually resulting in a power state change")
268 PowerDomainParams::create()
Enums::PwrState _currState
To keep track of the current power state.
PowerDomain(const PowerDomainParams *p)
std::vector< PowerState * > leaders
List of all leaders in the PowerDomain.
EventWrapper< PowerDomain, &PowerDomain::setFollowerPowerStates > pwrStateUpdateEvent
Event to update the power states of the followers.
std::vector< PowerState * > followers
List of all followers in the PowerDomain.
PowerDomain::PowerDomainStats stats
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.
void addFollower(PowerState *pwr_obj) override
Function called by a follower to register itself as a dependant of this power domain.
Tick curTick()
The current simulated tick.
const Tick updateLatency
Latency with which power state changes of the leaders will ripple through to the followers.
std::set< Enums::PwrState > possibleStates
The possible power states this object can be in.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
void schedule(Event &event, Tick when)
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
Stats::Scalar numLeaderCallsChangingState
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, the power state of the PowerDomain is set and some assertions about the PowerState objects in the Domain are checked.
Enums::PwrState leaderTargetState
Power state requested by the leader.
bool isPossiblePwrState(Enums::PwrState p_state)
Check if a given p_state is available across all leaders and followers in this domain.
Stats::Scalar numLeaderCalls
void regStats() override
Callback to set stat parameters.
virtual void regStats()
Callback to set stat parameters.
std::set< Enums::PwrState > getPossibleStates() const
Return the power states this object can be in.
const FlagsType nozero
Don't print if this is zero.
void setFollowerPowerStates()
Update the followers of the newly updated power state.
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...
PowerDomainStats(PowerDomain &pd)