gem5  v21.1.0.2
power_state.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2017, 2020 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
43 #ifndef __SIM_POWER_STATE_HH__
44 #define __SIM_POWER_STATE_HH__
45 
46 #include <set>
47 #include <vector>
48 
49 #include "base/callback.hh"
50 #include "base/statistics.hh"
51 #include "enums/PwrState.hh"
52 #include "params/PowerState.hh"
53 #include "sim/sim_object.hh"
54 
55 namespace gem5
56 {
57 
58 class PowerDomain;
59 
64 class PowerState : public SimObject
65 {
66  public:
67  PowerState(const PowerStateParams &p);
68 
71 
72  virtual void addFollower(PowerState* pwr_obj) {};
73  void setControlledDomain(PowerDomain* pwr_dom);
74 
75  void serialize(CheckpointOut &cp) const override;
76  void unserialize(CheckpointIn &cp) override;
77 
81  void set(enums::PwrState p);
82 
83 
84  inline enums::PwrState get() const
85  {
86  return _currState;
87  }
88 
89  inline std::string getName() const
90  {
91  return enums::PwrStateStrings[_currState];
92  }
93 
96 
103  void computeStats();
104 
109  enums::PwrState matchPwrState(enums::PwrState p);
110 
114  std::set<enums::PwrState> getPossibleStates() const
115  {
116  return possibleStates;
117  }
118 
119  protected:
120 
122  enums::PwrState _currState;
123 
125  std::set<enums::PwrState> possibleStates;
126 
129 
135 
137  {
139 
140  void regStats() override;
141  void preDumpStats() override;
142 
144 
150  } stats;
151 };
152 
153 } // namespace gem5
154 
155 #endif //__SIM_POWER_STATE_HH__
gem5::statistics::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1927
gem5::PowerDomain
The PowerDomain groups PowerState objects together to regulate their power states.
Definition: power_domain.hh:59
gem5::PowerState::addFollower
virtual void addFollower(PowerState *pwr_obj)
Definition: power_state.hh:72
gem5::PowerState::getName
std::string getName() const
Definition: power_state.hh:89
gem5::PowerState::possibleStates
std::set< enums::PwrState > possibleStates
The possible power states this object can be in.
Definition: power_state.hh:125
gem5::statistics::Distribution
A simple distribution stat.
Definition: statistics.hh:2081
gem5::PowerState::PowerStateStats::PowerStateStats
PowerStateStats(PowerState &ps)
Definition: power_state.cc:224
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::PowerState::controlledDomain
PowerDomain * controlledDomain
The power domain that this power state leads, nullptr if it doesn't lead any.
Definition: power_state.hh:134
gem5::PowerState::get
enums::PwrState get() const
Definition: power_state.hh:84
gem5::statistics::Vector
A vector of scalar stats.
Definition: statistics.hh:2003
std::vector< double >
gem5::PowerState::setControlledDomain
void setControlledDomain(PowerDomain *pwr_dom)
Definition: power_state.cc:66
gem5::PowerState::PowerStateStats::numTransitions
statistics::Scalar numTransitions
Definition: power_state.hh:145
gem5::PowerState::computeStats
void computeStats()
Record stats values like state residency by computing the time difference from previous update.
Definition: power_state.cc:187
gem5::PowerState::PowerStateStats::numPwrMatchStateTransitions
statistics::Scalar numPwrMatchStateTransitions
Definition: power_state.hh:146
gem5::PowerState::PowerState
PowerState(const PowerStateParams &p)
Definition: power_state.cc:52
gem5::PowerState::stats
gem5::PowerState::PowerStateStats stats
gem5::PowerState::PARAMS
PARAMS(PowerState)
Parameters of PowerState object.
gem5::PowerState::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: power_state.cc:85
sim_object.hh
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
statistics.hh
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::PowerState
Helper class for objects that have power states.
Definition: power_state.hh:64
gem5::PowerState::matchPwrState
enums::PwrState matchPwrState(enums::PwrState p)
Change the power state of this object to a power state equal to OR more performant than p.
Definition: power_state.cc:139
gem5::PowerState::PowerStateStats
Definition: power_state.hh:136
gem5::PowerState::PowerStateStats::powerState
PowerState & powerState
Definition: power_state.hh:143
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::PowerState::PowerStateStats::preDumpStats
void preDumpStats() override
Callback before stats are dumped.
Definition: power_state.cc:270
gem5::PowerState::PowerStateStats::ticksClkGated
statistics::Distribution ticksClkGated
Definition: power_state.hh:147
gem5::PowerState::PowerStateStats::regStats
void regStats() override
Callback to set stat parameters.
Definition: power_state.cc:239
gem5::ArmISA::ps
Bitfield< 18, 16 > ps
Definition: misc_types.hh:513
gem5::PowerState::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: power_state.cc:76
gem5::statistics::Group
Statistics container.
Definition: group.hh:93
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::PowerState::getWeights
std::vector< double > getWeights() const
Returns the percentage residency for each power state.
Definition: power_state.cc:205
gem5::PowerState::prvEvalTick
Tick prvEvalTick
Last tick the power stats were calculated.
Definition: power_state.hh:128
gem5::PowerState::getPossibleStates
std::set< enums::PwrState > getPossibleStates() const
Return the power states this object can be in.
Definition: power_state.hh:114
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::PowerState::set
void set(enums::PwrState p)
Change the power state of this object to the power state p.
Definition: power_state.cc:96
gem5::PowerState::PowerStateStats::pwrStateResidencyTicks
statistics::Vector pwrStateResidencyTicks
Tracks the time spent in each of the power states.
Definition: power_state.hh:149
callback.hh
gem5::PowerState::_currState
enums::PwrState _currState
To keep track of the current power state.
Definition: power_state.hh:122

Generated on Tue Sep 21 2021 12:25:48 for gem5 by doxygen 1.8.17