gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: Vasileios Spiliopoulos
38  * Akash Bagdia
39  * Stephan Diestelhorst
40  */
41 
50 #ifndef __SIM_DVFS_HANDLER_HH__
51 #define __SIM_DVFS_HANDLER_HH__
52 
53 #include <vector>
54 
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 
71 class DVFSHandler : public SimObject
72 {
73  public:
74  typedef DVFSHandlerParams Params;
75  DVFSHandler(const Params *p);
76 
79 
84  uint32_t numDomains() const { return domainIDList.size(); }
85 
90  DomainID domainID(uint32_t index) const;
91 
97  bool validDomainID(DomainID domain_id) const;
98 
103  Tick transLatency() const { return _transLatency; }
104 
113  bool perfLevel(DomainID domain_id, PerfLevel perf_level);
114 
122  PerfLevel perfLevel(DomainID domain_id) const {
123  assert(isEnabled());
124  return findDomain(domain_id)->perfLevel();
125  }
126 
135  Tick clkPeriodAtPerfLevel(DomainID domain_id, PerfLevel perf_level) const
136  {
137  SrcClockDomain *d = findDomain(domain_id);
138  assert(d);
139  PerfLevel n = d->numPerfLevels();
140  if (perf_level < n)
141  return d->clkPeriodAtPerfLevel(perf_level);
142 
143  warn("DVFSHandler %s reads illegal frequency level %u from "\
144  "SrcClockDomain %s. Returning 0\n", name(), perf_level, d->name());
145  return Tick(0);
146  }
147 
156  double voltageAtPerfLevel(DomainID domain_id, PerfLevel perf_level) const;
157 
165  PerfLevel numPerfLevels(PerfLevel domain_id) const
166  {
167  return findDomain(domain_id)->numPerfLevels();
168  }
169 
175  bool isEnabled() const { return enableHandler; }
176 
177  void serialize(CheckpointOut &cp) const override;
178  void unserialize(CheckpointIn &cp) override;
179 
180  private:
181  typedef std::map<DomainID, SrcClockDomain*> Domains;
182  Domains domains;
183 
188 
193 
200  SrcClockDomain *findDomain(DomainID domain_id) const {
201  auto it = domains.find(domain_id);
202  panic_if(it == domains.end(),
203  "DVFS: Could not find a domain for ID %d.\n",domain_id );
204  return domains.find(domain_id)->second;
205  }
206 
212 
213 
219 
220 
221 
226  struct UpdateEvent : public Event {
228  perfLevelToSet(0) {}
229 
234 
238  DomainID domainIDToSet;
239 
243  PerfLevel perfLevelToSet;
244 
251  void updatePerfLevel();
252 
253  void process() { updatePerfLevel(); }
254  };
255 
256  typedef std::map<DomainID, UpdateEvent> UpdatePerfLevelEvents;
261  UpdatePerfLevelEvents updatePerfLevelEvents;
262 };
263 
264 #endif // __SIM_DVFS_HANDLER_HH__
std::map< DomainID, UpdateEvent > UpdatePerfLevelEvents
bool perfLevel(DomainID domain_id, PerfLevel perf_level)
Set a new performance level for the specified domain.
PerfLevel numPerfLevels(PerfLevel domain_id) const
Get the total number of available performance levels.
Bitfield< 30, 0 > index
double voltageAtPerfLevel(DomainID domain_id, PerfLevel perf_level) const
Read the voltage of the specified domain at the specified performance level.
SrcClockDomain * findDomain(DomainID domain_id) const
Search for a domain based on the domain ID.
PerfLevel perfLevelToSet
Target performance level of the in-flight event.
PerfLevel perfLevel(DomainID domain_id) const
Get the current performance level of a domain.
bool isEnabled() const
Check enable status of the DVFS handler, when the handler is disabled, no request should be sent to t...
bool enableHandler
Disabling the DVFS handler ensures that all the DVFS migration requests are ignored.
bool validDomainID(DomainID domain_id) const
Check whether a domain ID is known to the handler or not.
SrcClockDomain * sysClkDomain
Clock domain of the system the handler is instantiated.
Definition: cprintf.cc:42
Domains domains
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Bitfield< 31 > n
DomainID domainID(uint32_t index) const
Get the n-th domain ID, from the domains managed by this handler.
Definition: dvfs_handler.cc:97
uint32_t PerfLevel
Tick clkPeriodAtPerfLevel(DomainID domain_id, PerfLevel perf_level) const
Read the clock period of the specified domain at the specified performance level. ...
void updatePerfLevel()
Updates the performance level by modifying the clock and the voltage of the associated clocked object...
UpdatePerfLevelEvents updatePerfLevelEvents
Map from domain IDs -> perf level update events, records in-flight change requests per domain ID...
uint32_t numDomains() const
Get the number of domains assigned to this DVFS handler.
Definition: dvfs_handler.hh:84
uint64_t Tick
Tick count type.
Definition: types.hh:63
Bitfield< 9 > d
void serialize(CheckpointOut &cp) const override
Serialize an object.
Tick clkPeriodAtPerfLevel() const
ClockDomain declarations.
void perfLevel(PerfLevel perf_level)
Sets the current performance level of the domain.
Tick transLatency() const
Get transition latency to switch between performance levels.
virtual const std::string name() const
Definition: sim_object.hh:120
DomainID domainIDToSet
ID of the domain that will be changed by the in-flight event.
PerfLevel numPerfLevels() const
Get the number of available performance levels for this clock domain.
The source clock domains provides the notion of a clock domain that is connected to a tunable clock s...
DVFS Handler class, maintains a list of all the domains it can handle.
Definition: dvfs_handler.hh:71
static SimObject * find(const char *name)
Find the SimObject with the given name and return a pointer to it.
Definition: sim_object.cc:174
std::vector< DomainID > domainIDList
List of IDs avaiable in the domain list.
DVFSHandler(const Params *p)
Definition: dvfs_handler.cc:61
std::ostream CheckpointOut
Definition: serialize.hh:68
Definition: eventq.hh:189
SrcClockDomain::DomainID DomainID
Definition: dvfs_handler.hh:77
SrcClockDomain::PerfLevel PerfLevel
Definition: dvfs_handler.hh:78
DVFSHandlerParams Params
Definition: dvfs_handler.hh:74
std::map< DomainID, SrcClockDomain * > Domains
#define warn(...)
Definition: logging.hh:212
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:153
static DVFSHandler * dvfsHandler
Static pointer to the single DVFS hander for all the update events.
const Tick _transLatency
This corresponds to the maximum transition latency associated with the hardware transitioning from a ...
Bitfield< 0 > p
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:185
Abstract superclass for simulation objects.
Definition: sim_object.hh:96
Update performance level event, encapsulates all the required information for a future call to change...

Generated on Fri Feb 28 2020 16:27:02 for gem5 by doxygen 1.8.13