summaryrefslogtreecommitdiff
path: root/src/cpu/base.cc
diff options
context:
space:
mode:
authorJose Marinho <jose.marinho@arm.com>2017-07-20 14:57:39 +0100
committerAndreas Sandberg <andreas.sandberg@arm.com>2017-11-21 17:09:18 +0000
commit760cc5735f48f3a5a52ebe31df0c039b23c3d611 (patch)
treeda4103b240221359838888467ac4f12544acc2c5 /src/cpu/base.cc
parent00232a868e4816d19c129fb3d6ef5519d7176d5a (diff)
downloadgem5-760cc5735f48f3a5a52ebe31df0c039b23c3d611.tar.xz
cpu, cpu, sim: move Cycle probe update
Move the code responsible for performing the actual probe point notify into BaseCPU. Use BaseCPU activateContext and suspendContext to keep track of sleep cycles. Create a probe point (ppActiveCycles) that does not count cycles where the processor was asleep. Rename ppCycles to ppAllCycles to reflect its nature. Change-Id: I1907ddd07d0ff9f2ef22cc9f61f5f46c630c9d66 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/5762 Maintainer: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Diffstat (limited to 'src/cpu/base.cc')
-rw-r--r--src/cpu/base.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/cpu/base.cc b/src/cpu/base.cc
index af55ee1d6..a41a0c3e3 100644
--- a/src/cpu/base.cc
+++ b/src/cpu/base.cc
@@ -133,6 +133,7 @@ BaseCPU::BaseCPU(Params *p, bool is_checker)
_switchedOut(p->switched_out), _cacheLineSize(p->system->cacheLineSize()),
interrupts(p->interrupts), profileEvent(NULL),
numThreads(p->numThreads), system(p->system),
+ previousCycle(0), previousState(CPU_STATE_SLEEP),
functionTraceStream(nullptr), currentFunctionStart(0),
currentFunctionEnd(0), functionEntryTick(0),
addressMonitor(p->numThreads),
@@ -385,12 +386,16 @@ BaseCPU::pmuProbePoint(const char *name)
void
BaseCPU::regProbePoints()
{
- ppCycles = pmuProbePoint("Cycles");
+ ppAllCycles = pmuProbePoint("Cycles");
+ ppActiveCycles = pmuProbePoint("ActiveCycles");
ppRetiredInsts = pmuProbePoint("RetiredInsts");
ppRetiredLoads = pmuProbePoint("RetiredLoads");
ppRetiredStores = pmuProbePoint("RetiredStores");
ppRetiredBranches = pmuProbePoint("RetiredBranches");
+
+ ppSleeping = new ProbePointArg<bool>(this->getProbeManager(),
+ "Sleeping");
}
void
@@ -520,9 +525,10 @@ BaseCPU::activateContext(ThreadID thread_num)
// Squash enter power gating event while cpu gets activated
if (enterPwrGatingEvent.scheduled())
deschedule(enterPwrGatingEvent);
-
// For any active thread running, update CPU power state to active (ON)
ClockedObject::pwrState(Enums::PwrState::ON);
+
+ updateCycleCounters(CPU_STATE_WAKEUP);
}
void
@@ -535,6 +541,9 @@ BaseCPU::suspendContext(ThreadID thread_num)
}
}
+ // All CPU thread are suspended, update cycle count
+ updateCycleCounters(CPU_STATE_SLEEP);
+
// All CPU threads suspended, enter lower power state for the CPU
ClockedObject::pwrState(Enums::PwrState::CLK_GATED);
@@ -547,6 +556,12 @@ BaseCPU::suspendContext(ThreadID thread_num)
}
void
+BaseCPU::haltContext(ThreadID thread_num)
+{
+ updateCycleCounters(BaseCPU::CPU_STATE_SLEEP);
+}
+
+void
BaseCPU::enterPwrGating(void)
{
ClockedObject::pwrState(Enums::PwrState::OFF);
@@ -579,6 +594,10 @@ BaseCPU::takeOverFrom(BaseCPU *oldCPU)
_taskId = oldCPU->taskId();
// Take over the power state of the switchedOut CPU
ClockedObject::pwrState(oldCPU->pwrState());
+
+ previousState = oldCPU->previousState;
+ previousCycle = oldCPU->previousCycle;
+
_switchedOut = false;
ThreadID size = threadContexts.size();