gem5  v20.0.0.3
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 
48 #include "base/callback.hh"
49 #include "base/statistics.hh"
50 #include "enums/PwrState.hh"
51 #include "params/PowerState.hh"
52 #include "sim/core.hh"
53 #include "sim/sim_object.hh"
54 
55 class PowerDomain;
56 
61 class PowerState : public SimObject
62 {
63  public:
64  PowerState(const PowerStateParams *p);
65 
67  typedef PowerStateParams Params;
68  const Params* params() const
69  {
70  return reinterpret_cast<const Params*>(_params);
71  }
72 
73  virtual void addFollower(PowerState* pwr_obj) {};
74  void setControlledDomain(PowerDomain* pwr_dom);
75 
76  void serialize(CheckpointOut &cp) const override;
77  void unserialize(CheckpointIn &cp) override;
78 
82  void set(Enums::PwrState p);
83 
84 
85  inline Enums::PwrState get() const
86  {
87  return _currState;
88  }
89 
90  inline std::string getName() const
91  {
92  return Enums::PwrStateStrings[_currState];
93  }
94 
97 
104  void computeStats();
105 
110  Enums::PwrState matchPwrState(Enums::PwrState p);
111 
115  std::set<Enums::PwrState> getPossibleStates() const
116  {
117  return possibleStates;
118  }
119 
120  protected:
121 
123  Enums::PwrState _currState;
124 
126  std::set<Enums::PwrState> possibleStates;
127 
130 
136 
138  {
140 
141  void regStats() override;
142  void preDumpStats() override;
143 
145 
151  } stats;
152 };
153 
155 {
157  public:
158  PowerStateDumpCallback(PowerState *co_t) : co(co_t) {}
159  virtual void process() { co->computeStats(); };
160 };
161 
162 #endif //__SIM_POWER_STATE_HH__
Generic callback class.
Definition: callback.hh:39
Enums::PwrState _currState
To keep track of the current power state.
Definition: power_state.hh:123
PowerStateParams Params
Parameters of PowerState object.
Definition: power_state.hh:67
PowerStateDumpCallback(PowerState *co_t)
Definition: power_state.hh:158
void preDumpStats() override
Callback before stats are dumped.
Definition: power_state.cc:262
std::string getName() const
Definition: power_state.hh:90
PowerState(const PowerStateParams *p)
Definition: power_state.cc:44
Stats::Vector pwrStateResidencyTicks
Tracks the time spent in each of the power states.
Definition: power_state.hh:150
A vector of scalar stats.
Definition: statistics.hh:2547
Definition: cprintf.cc:40
Helper class for objects that have power states.
Definition: power_state.hh:61
Declaration of Statistics objects.
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2505
void computeStats()
Record stats values like state residency by computing the time difference from previous update...
Definition: power_state.cc:179
virtual void addFollower(PowerState *pwr_obj)
Definition: power_state.hh:73
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: power_state.cc:77
uint64_t Tick
Tick count type.
Definition: types.hh:61
void setControlledDomain(PowerDomain *pwr_dom)
Definition: power_state.cc:58
A simple distribution stat.
Definition: statistics.hh:2589
std::set< Enums::PwrState > possibleStates
The possible power states this object can be in.
Definition: power_state.hh:126
PowerStateStats(PowerState &ps)
Definition: power_state.cc:216
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:131
const Params * params() const
Definition: power_state.hh:68
PowerDomain * controlledDomain
The power domain that this power state leads, nullptr if it doesn&#39;t lead any.
Definition: power_state.hh:135
Stats::Scalar numPwrMatchStateTransitions
Definition: power_state.hh:147
Statistics container.
Definition: group.hh:83
Tick prvEvalTick
Last tick the power stats were calculated.
Definition: power_state.hh:129
The PowerDomain groups PowerState objects together to regulate their power states.
Definition: power_domain.hh:56
std::ostream CheckpointOut
Definition: serialize.hh:63
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: power_state.cc:68
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:111
std::vector< double > getWeights() const
Returns the percentage residency for each power state.
Definition: power_state.cc:197
std::set< Enums::PwrState > getPossibleStates() const
Return the power states this object can be in.
Definition: power_state.hh:115
Bitfield< 18, 16 > ps
Bitfield< 0 > p
std::vector< Info * > stats
Definition: group.hh:212
void regStats() override
Callback to set stat parameters.
Definition: power_state.cc:231
virtual void process()
virtual process function that is invoked when the callback queue is executed.
Definition: power_state.hh:159
Abstract superclass for simulation objects.
Definition: sim_object.hh:93
Stats::Distribution ticksClkGated
Definition: power_state.hh:148

Generated on Fri Jul 3 2020 15:53:04 for gem5 by doxygen 1.8.13