gem5  v21.1.0.2
dvfs_handler.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2014 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 
46 #ifndef __SIM_DVFS_HANDLER_HH__
47 #define __SIM_DVFS_HANDLER_HH__
48 
49 #include <cassert>
50 #include <map>
51 #include <vector>
52 
53 #include "base/logging.hh"
54 #include "base/types.hh"
55 #include "debug/DVFS.hh"
56 #include "params/DVFSHandler.hh"
57 #include "sim/clock_domain.hh"
58 #include "sim/eventq.hh"
59 #include "sim/sim_object.hh"
60 
61 namespace gem5
62 {
63 
74 class DVFSHandler : public SimObject
75 {
76  public:
77  typedef DVFSHandlerParams Params;
78  DVFSHandler(const Params &p);
79 
82 
87  uint32_t numDomains() const { return domainIDList.size(); }
88 
93  DomainID domainID(uint32_t index) const;
94 
100  bool validDomainID(DomainID domain_id) const;
101 
106  Tick transLatency() const { return _transLatency; }
107 
116  bool perfLevel(DomainID domain_id, PerfLevel perf_level);
117 
125  PerfLevel perfLevel(DomainID domain_id) const {
126  assert(isEnabled());
127  return findDomain(domain_id)->perfLevel();
128  }
129 
138  Tick clkPeriodAtPerfLevel(DomainID domain_id, PerfLevel perf_level) const
139  {
140  SrcClockDomain *d = findDomain(domain_id);
141  assert(d);
142  PerfLevel n = d->numPerfLevels();
143  if (perf_level < n)
144  return d->clkPeriodAtPerfLevel(perf_level);
145 
146  warn("DVFSHandler %s reads illegal frequency level %u from "\
147  "SrcClockDomain %s. Returning 0\n", name(), perf_level, d->name());
148  return Tick(0);
149  }
150 
159  double voltageAtPerfLevel(DomainID domain_id, PerfLevel perf_level) const;
160 
169  {
170  return findDomain(domain_id)->numPerfLevels();
171  }
172 
178  bool isEnabled() const { return enableHandler; }
179 
180  void serialize(CheckpointOut &cp) const override;
181  void unserialize(CheckpointIn &cp) override;
182 
183  private:
184  typedef std::map<DomainID, SrcClockDomain*> Domains;
186 
191 
196 
203  SrcClockDomain *findDomain(DomainID domain_id) const {
204  auto it = domains.find(domain_id);
205  panic_if(it == domains.end(),
206  "DVFS: Could not find a domain for ID %d.\n",domain_id );
207  return domains.find(domain_id)->second;
208  }
209 
215 
216 
222 
223 
224 
229  struct UpdateEvent : public Event
230  {
232  perfLevelToSet(0) {}
233 
238 
243 
248 
255  void updatePerfLevel();
256 
257  void process() { updatePerfLevel(); }
258  };
259 
260  typedef std::map<DomainID, UpdateEvent> UpdatePerfLevelEvents;
266 };
267 
268 } // namespace gem5
269 
270 #endif // __SIM_DVFS_HANDLER_HH__
gem5::DVFSHandler::domains
Domains domains
Definition: dvfs_handler.hh:185
gem5::DVFSHandler::voltageAtPerfLevel
double voltageAtPerfLevel(DomainID domain_id, PerfLevel perf_level) const
Read the voltage of the specified domain at the specified performance level.
Definition: dvfs_handler.cc:173
warn
#define warn(...)
Definition: logging.hh:245
gem5::DVFSHandler::UpdateEvent::process
void process()
Definition: dvfs_handler.hh:257
gem5::DVFSHandler::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: dvfs_handler.cc:197
gem5::SrcClockDomain::numPerfLevels
PerfLevel numPerfLevels() const
Get the number of available performance levels for this clock domain.
Definition: clock_domain.hh:221
gem5::MipsISA::index
Bitfield< 30, 0 > index
Definition: pra_constants.hh:47
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::DVFSHandler::UpdatePerfLevelEvents
std::map< DomainID, UpdateEvent > UpdatePerfLevelEvents
Definition: dvfs_handler.hh:260
gem5::DVFSHandler::PerfLevel
SrcClockDomain::PerfLevel PerfLevel
Definition: dvfs_handler.hh:81
std::vector< DomainID >
gem5::DVFSHandler::DVFSHandler
DVFSHandler(const Params &p)
Definition: dvfs_handler.cc:58
gem5::DVFSHandler::UpdateEvent::UpdateEvent
UpdateEvent()
Definition: dvfs_handler.hh:231
gem5::EventBase::DVFS_Update_Pri
static const Priority DVFS_Update_Pri
DVFS update event leads to stats dump therefore given a lower priority to ensure all relevant states ...
Definition: eventq.hh:187
gem5::DVFSHandler::perfLevel
PerfLevel perfLevel(DomainID domain_id) const
Get the current performance level of a domain.
Definition: dvfs_handler.hh:125
gem5::SrcClockDomain::perfLevel
void perfLevel(PerfLevel perf_level)
Sets the current performance level of the domain.
Definition: clock_domain.cc:139
gem5::DVFSHandler::numPerfLevels
PerfLevel numPerfLevels(PerfLevel domain_id) const
Get the total number of available performance levels.
Definition: dvfs_handler.hh:168
gem5::DVFSHandler::sysClkDomain
SrcClockDomain * sysClkDomain
Clock domain of the system the handler is instantiated.
Definition: dvfs_handler.hh:195
gem5::DVFSHandler::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: dvfs_handler.cc:224
gem5::DVFSHandler::findDomain
SrcClockDomain * findDomain(DomainID domain_id) const
Search for a domain based on the domain ID.
Definition: dvfs_handler.hh:203
gem5::DVFSHandler::validDomainID
bool validDomainID(DomainID domain_id) const
Check whether a domain ID is known to the handler or not.
Definition: dvfs_handler.cc:105
gem5::Named::name
virtual std::string name() const
Definition: named.hh:47
sim_object.hh
gem5::Event
Definition: eventq.hh:251
gem5::DVFSHandler::UpdateEvent::domainIDToSet
DomainID domainIDToSet
ID of the domain that will be changed by the in-flight event.
Definition: dvfs_handler.hh:242
gem5::ArmISA::d
Bitfield< 9 > d
Definition: misc_types.hh:63
gem5::DVFSHandler::domainIDList
std::vector< DomainID > domainIDList
List of IDs avaiable in the domain list.
Definition: dvfs_handler.hh:190
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::SrcClockDomain::DomainID
int32_t DomainID
Definition: clock_domain.hh:183
gem5::DVFSHandler::transLatency
Tick transLatency() const
Get transition latency to switch between performance levels.
Definition: dvfs_handler.hh:106
gem5::SrcClockDomain
The source clock domains provides the notion of a clock domain that is connected to a tunable clock s...
Definition: clock_domain.hh:166
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::DVFSHandler::Domains
std::map< DomainID, SrcClockDomain * > Domains
Definition: dvfs_handler.hh:184
gem5::DVFSHandler::UpdateEvent::perfLevelToSet
PerfLevel perfLevelToSet
Target performance level of the in-flight event.
Definition: dvfs_handler.hh:247
gem5::DVFSHandler::enableHandler
bool enableHandler
Disabling the DVFS handler ensures that all the DVFS migration requests are ignored.
Definition: dvfs_handler.hh:214
gem5::DVFSHandler::_transLatency
const Tick _transLatency
This corresponds to the maximum transition latency associated with the hardware transitioning from a ...
Definition: dvfs_handler.hh:221
gem5::DVFSHandler::DomainID
SrcClockDomain::DomainID DomainID
Definition: dvfs_handler.hh:80
clock_domain.hh
gem5::DVFSHandler
DVFS Handler class, maintains a list of all the domains it can handle.
Definition: dvfs_handler.hh:74
panic_if
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:203
gem5::ArmISA::n
Bitfield< 31 > n
Definition: misc_types.hh:455
types.hh
gem5::DVFSHandler::domainID
DomainID domainID(uint32_t index) const
Get the n-th domain ID, from the domains managed by this handler.
Definition: dvfs_handler.cc:94
gem5::SrcClockDomain::PerfLevel
uint32_t PerfLevel
Definition: clock_domain.hh:191
gem5::DVFSHandler::UpdateEvent::dvfsHandler
static DVFSHandler * dvfsHandler
Static pointer to the single DVFS hander for all the update events.
Definition: dvfs_handler.hh:237
logging.hh
gem5::DVFSHandler::isEnabled
bool isEnabled() const
Check enable status of the DVFS handler, when the handler is disabled, no request should be sent to t...
Definition: dvfs_handler.hh:178
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::DVFSHandler::updatePerfLevelEvents
UpdatePerfLevelEvents updatePerfLevelEvents
Map from domain IDs -> perf level update events, records in-flight change requests per domain ID.
Definition: dvfs_handler.hh:265
gem5::DVFSHandler::clkPeriodAtPerfLevel
Tick clkPeriodAtPerfLevel(DomainID domain_id, PerfLevel perf_level) const
Read the clock period of the specified domain at the specified performance level.
Definition: dvfs_handler.hh:138
gem5::DVFSHandler::numDomains
uint32_t numDomains() const
Get the number of domains assigned to this DVFS handler.
Definition: dvfs_handler.hh:87
gem5::DVFSHandler::UpdateEvent::updatePerfLevel
void updatePerfLevel()
Updates the performance level by modifying the clock and the voltage of the associated clocked object...
Definition: dvfs_handler.cc:158
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::DVFSHandler::perfLevel
bool perfLevel(DomainID domain_id, PerfLevel perf_level)
Set a new performance level for the specified domain.
Definition: dvfs_handler.cc:118
gem5::DVFSHandler::UpdateEvent
Update performance level event, encapsulates all the required information for a future call to change...
Definition: dvfs_handler.hh:229
gem5::DVFSHandler::Params
DVFSHandlerParams Params
Definition: dvfs_handler.hh:77
eventq.hh

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