[gem5-dev] Change in public/gem5[master]: cpu, cpu, sim: move Cycle probe update
Andreas Sandberg has submitted this change and it was merged. ( https://gem5-review.googlesource.com/5762 ) Change subject: cpu, cpu, sim: move Cycle probe update .. 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 SandbergReviewed-on: https://gem5-review.googlesource.com/5762 Maintainer: Andreas Sandberg Reviewed-by: Jason Lowe-Power --- M src/cpu/base.cc M src/cpu/base.hh M src/cpu/kvm/base.cc M src/cpu/minor/pipeline.hh M src/cpu/o3/cpu.cc M src/cpu/simple/atomic.cc M src/cpu/simple/base.cc M src/cpu/simple/timing.cc 8 files changed, 88 insertions(+), 19 deletions(-) Approvals: Jason Lowe-Power: Looks good to me, but someone else must approve Andreas Sandberg: Looks good to me, approved; Looks good to me, approved diff --git a/src/cpu/base.cc b/src/cpu/base.cc index af55ee1..a41a0c3 100644 --- a/src/cpu/base.cc +++ b/src/cpu/base.cc @@ -133,6 +133,7 @@ _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 @@ 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(this->getProbeManager(), + "Sleeping"); } void @@ -520,9 +525,10 @@ // 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 @@ } } +// 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 @@ } void +BaseCPU::haltContext(ThreadID thread_num) +{ +updateCycleCounters(BaseCPU::CPU_STATE_SLEEP); +} + +void BaseCPU::enterPwrGating(void) { ClockedObject::pwrState(Enums::PwrState::OFF); @@ -579,6 +594,10 @@ _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(); diff --git a/src/cpu/base.hh b/src/cpu/base.hh index 13c56a9..52598fd 100644 --- a/src/cpu/base.hh +++ b/src/cpu/base.hh @@ -63,6 +63,7 @@ #include "sim/full_system.hh" #include "sim/insttracer.hh" #include "sim/probe/pmu.hh" +#include "sim/probe/probe.hh" #include "sim/system.hh" #include "debug/Mwait.hh" @@ -277,7 +278,7 @@ virtual void suspendContext(ThreadID thread_num); /// Notify the CPU that the indicated context is now halted. -virtual void haltContext(ThreadID thread_num) {} +virtual void haltContext(ThreadID thread_num); /// Given a Thread Context pointer return the thread num int findContext(ThreadContext *tc); @@ -489,6 +490,7 @@ */ virtual void probeInstCommit(const StaticInstPtr ); + protected: /** * Helper method to instantiate probe points belonging to this * object. @@ -498,9 +500,6 @@ */ ProbePoints::PMUUPtr pmuProbePoint(const char *name); -/** CPU cycle counter */ -ProbePoints::PMUUPtr ppCycles; - /** * Instruction commit probe point. * @@ -519,9 +518,58 @@ /** Retired branches (any type) */ ProbePoints::PMUUPtr ppRetiredBranches; +/** CPU cycle counter even if any thread Context is suspended*/ +ProbePoints::PMUUPtr ppAllCycles; + +/** CPU cycle counter, only counts if any thread contexts is active **/ +ProbePoints::PMUUPtr ppActiveCycles; + +/** + * ProbePoint that signals transitions of
[gem5-dev] Change in public/gem5[master]: cpu, cpu, sim: move Cycle probe update
Andreas Sandberg has uploaded this change for review. ( https://gem5-review.googlesource.com/5762 Change subject: cpu, cpu, sim: move Cycle probe update .. 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--- M src/cpu/base.cc M src/cpu/base.hh M src/cpu/kvm/base.cc M src/cpu/minor/pipeline.hh M src/cpu/o3/cpu.cc M src/cpu/simple/atomic.cc M src/cpu/simple/base.cc M src/cpu/simple/timing.cc 8 files changed, 88 insertions(+), 19 deletions(-) diff --git a/src/cpu/base.cc b/src/cpu/base.cc index af55ee1..a41a0c3 100644 --- a/src/cpu/base.cc +++ b/src/cpu/base.cc @@ -133,6 +133,7 @@ _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 @@ 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(this->getProbeManager(), + "Sleeping"); } void @@ -520,9 +525,10 @@ // 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 @@ } } +// 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 @@ } void +BaseCPU::haltContext(ThreadID thread_num) +{ +updateCycleCounters(BaseCPU::CPU_STATE_SLEEP); +} + +void BaseCPU::enterPwrGating(void) { ClockedObject::pwrState(Enums::PwrState::OFF); @@ -579,6 +594,10 @@ _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(); diff --git a/src/cpu/base.hh b/src/cpu/base.hh index 13c56a9..52598fd 100644 --- a/src/cpu/base.hh +++ b/src/cpu/base.hh @@ -63,6 +63,7 @@ #include "sim/full_system.hh" #include "sim/insttracer.hh" #include "sim/probe/pmu.hh" +#include "sim/probe/probe.hh" #include "sim/system.hh" #include "debug/Mwait.hh" @@ -277,7 +278,7 @@ virtual void suspendContext(ThreadID thread_num); /// Notify the CPU that the indicated context is now halted. -virtual void haltContext(ThreadID thread_num) {} +virtual void haltContext(ThreadID thread_num); /// Given a Thread Context pointer return the thread num int findContext(ThreadContext *tc); @@ -489,6 +490,7 @@ */ virtual void probeInstCommit(const StaticInstPtr ); + protected: /** * Helper method to instantiate probe points belonging to this * object. @@ -498,9 +500,6 @@ */ ProbePoints::PMUUPtr pmuProbePoint(const char *name); -/** CPU cycle counter */ -ProbePoints::PMUUPtr ppCycles; - /** * Instruction commit probe point. * @@ -519,9 +518,58 @@ /** Retired branches (any type) */ ProbePoints::PMUUPtr ppRetiredBranches; +/** CPU cycle counter even if any thread Context is suspended*/ +ProbePoints::PMUUPtr ppAllCycles; + +/** CPU cycle counter, only counts if any thread contexts is active **/ +ProbePoints::PMUUPtr ppActiveCycles; + +/** + * ProbePoint that signals transitions of threadContexts sets. + * The ProbePoint reports information through it bool parameter. + * - If the parameter is true then the last enabled threadContext of the + * CPU object was disabled. + * - If the parameter is false then a threadContext was enabled, all the + * remaining threadContexts are