gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
power_model.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016, 2018, 2021 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
38#ifndef __SIM_POWER_POWER_MODEL_HH__
39#define __SIM_POWER_POWER_MODEL_HH__
40
41#include "base/statistics.hh"
42#include "base/temperature.hh"
43#include "enums/PMType.hh"
44#include "params/PowerModel.hh"
45#include "params/PowerModelState.hh"
46#include "sim/probe/probe.hh"
47#include "sim/sim_object.hh"
48
49namespace gem5
50{
51
52class SimObject;
53class ClockedObject;
54
60{
61 public:
62
63 typedef PowerModelStateParams Params;
64 PowerModelState(const Params &p);
65
71 virtual double getDynamicPower() const = 0;
72
78 virtual double getStaticPower() const = 0;
79
85 virtual void setTemperature(Temperature temp) { _temp = temp; }
86
88 clocked_object = clkobj;
89 }
90
91 protected:
92
95
98
100};
101
108class PowerModel : public SimObject
109{
110 public:
111
112 typedef PowerModelParams Params;
113 PowerModel(const Params &p);
114
120 double getDynamicPower() const;
121
127 double getStaticPower() const;
128
129 void setClockedObject(ClockedObject *clkobj);
130
131 virtual void regProbePoints();
132
133 void thermalUpdateCallback(const Temperature &temp);
134
135 protected:
137 class ThermalProbeListener : public ProbeListenerArgBase<Temperature>
138 {
139 public:
141 : ProbeListenerArgBase(std::move(name)), pm(_pm)
142 {}
143
144 void notify(const Temperature &temp)
145 {
146 pm.thermalUpdateCallback(temp);
147 }
148
149 protected:
151 };
152
155
158
161
164
166 enums::PMType power_model_type;
167
169};
170
171} // namespace gem5
172
173#endif
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
PowerModelStateParams Params
statistics::Value dynamicPower
PowerModelState(const Params &p)
virtual double getDynamicPower() const =0
Get the dynamic power consumption.
void setClockedObject(ClockedObject *clkobj)
Temperature _temp
Current temperature.
ClockedObject * clocked_object
The clocked object we belong to.
virtual void setTemperature(Temperature temp)
Temperature update.
virtual double getStaticPower() const =0
Get the static power consumption.
statistics::Value staticPower
void notify(const Temperature &temp)
ThermalProbeListener(PowerModel &_pm, std::string name)
virtual void regProbePoints()
Register probe points for this object.
enums::PMType power_model_type
The type of power model - collects all power, static or dynamic only.
statistics::Value staticPower
double getStaticPower() const
Get the static power consumption.
void setClockedObject(ClockedObject *clkobj)
ClockedObject * clocked_object
The clocked object we belong to.
PowerModel(const Params &p)
ProbeListenerPtr< ThermalProbeListener > thermalListener
Listener to catch temperature changes in the SubSystem.
PowerModelParams Params
SubSystem * subsystem
The subsystem this power model belongs to.
void thermalUpdateCallback(const Temperature &temp)
std::vector< PowerModelState * > states_pm
Actual power models (one per power state)
double getDynamicPower() const
Get the dynamic power consumption.
statistics::Value dynamicPower
const std::string name
Definition probe.hh:114
Abstract superclass for simulation objects.
The SubSystem simobject does nothing, it is just a container for other simobjects used by the configu...
Definition sub_system.hh:61
The class stores temperatures in Kelvin and provides helper methods to convert to/from Celsius.
STL vector class.
Definition stl.hh:37
SimObject(const Params &p)
Definition sim_object.cc:58
Bitfield< 0 > p
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
std::unique_ptr< Listener, ProbeListenerCleanup > ProbeListenerPtr
This typedef should be used instead of a raw std::unique_ptr<> since we have to disconnect the listen...
Definition probe.hh:155
Overload hash function for BasicBlockRange type.
Definition binary32.hh:81
Declaration of Statistics objects.

Generated on Mon May 26 2025 09:19:13 for gem5 by doxygen 1.13.2