Hello Andreas Sandberg, Anouk Van Laer,
I'd like you to do a code review. Please visit
https://gem5-review.googlesource.com/c/public/gem5/+/28050
to review the following change.
Change subject: sim-power: Specify the states a PowerState object can be in
......................................................................
sim-power: Specify the states a PowerState object can be in
This commit adds the concept of possible power states to the
PowerState SimObject. This is a list of the power states a specific
object can be in. Before transitioning to a power state, a PowerState
object will first check if the requested power states is actually an
allowed state. The user can restricted the power states a
ClockedObject can go to during configuration. In addition, this change
sets the power states, a CPU can be in.
Change-Id: Ida414a87554a14f09767a272b54b5d19bfc8e911
Reviewed-by: Andreas Sandberg <andreas.sandb...@arm.com>
Signed-off-by: Nikos Nikoleris <nikos.nikole...@arm.com>
---
M src/cpu/BaseCPU.py
M src/sim/PowerState.py
M src/sim/power_state.cc
M src/sim/power_state.hh
4 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/cpu/BaseCPU.py b/src/cpu/BaseCPU.py
index 53652bf..feb0eed 100644
--- a/src/cpu/BaseCPU.py
+++ b/src/cpu/BaseCPU.py
@@ -302,3 +302,7 @@
cpus_node.append(node)
yield cpus_node
+
+ def __init__(self, **kwargs):
+ super(BaseCPU, self).__init__(**kwargs)
+ self.power_state.possible_states=['ON', 'CLK_GATED', 'OFF']
diff --git a/src/sim/PowerState.py b/src/sim/PowerState.py
index 59491ec..bfa53e2 100644
--- a/src/sim/PowerState.py
+++ b/src/sim/PowerState.py
@@ -62,6 +62,11 @@
# routine
default_state = Param.PwrState("UNDEFINED", "Default Power State")
+ # Possible power states this object can be in sorted from the most
+ # to the least performant
+ possible_states = VectorParam.PwrState(
+ [], "Power states this object can be in")
+
clk_gate_min = Param.Latency('1ns',"Min value of the distribution")
clk_gate_max = Param.Latency('1s',"Max value of the distribution")
clk_gate_bins = Param.Unsigned('20', "# bins in clk gated
distribution")
diff --git a/src/sim/power_state.cc b/src/sim/power_state.cc
index 7074dd6..a2ed7fe 100644
--- a/src/sim/power_state.cc
+++ b/src/sim/power_state.cc
@@ -40,8 +40,10 @@
#include "base/logging.hh"
PowerState::PowerState(const PowerStateParams *p) :
- SimObject(p), _currState(p->default_state), prvEvalTick(0),
- stats(*this)
+ SimObject(p), _currState(p->default_state),
+ possibleStates(p->possible_states.begin(),
+ p->possible_states.end()),
+ prvEvalTick(0), stats(*this)
{
}
@@ -68,6 +70,11 @@
void
PowerState::set(Enums::PwrState p)
{
+ // Check if this power state is actually allowed by checking whether
it is
+ // present in pwrStateToIndex-dictionary
+ panic_if(possibleStates.find(p) == possibleStates.end(),
+ "Cannot go to %s in %s \n", Enums::PwrStateStrings[p],
name());
+
// Function should ideally be called only when there is a state change
if (_currState == p) {
warn_once("PowerState: Already in the requested power state, "
diff --git a/src/sim/power_state.hh b/src/sim/power_state.hh
index 8cb3b3b..af7527f 100644
--- a/src/sim/power_state.hh
+++ b/src/sim/power_state.hh
@@ -98,11 +98,22 @@
*/
void computeStats();
+ /**
+ * Return the power states this object can be in
+ */
+ std::set<Enums::PwrState> getPossibleStates() const
+ {
+ return possibleStates;
+ }
+
protected:
/** To keep track of the current power state */
Enums::PwrState _currState;
+ /** The possible power states this object can be in */
+ const std::set<Enums::PwrState> possibleStates;
+
/** Last tick the power stats were calculated */
Tick prvEvalTick;
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/28050
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ida414a87554a14f09767a272b54b5d19bfc8e911
Gerrit-Change-Number: 28050
Gerrit-PatchSet: 1
Gerrit-Owner: Nikos Nikoleris <nikos.nikole...@arm.com>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Anouk Van Laer <anouk.vanl...@arm.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s