_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),
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
// 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
}
}
+ // 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);
}
}
+void
+BaseCPU::haltContext(ThreadID thread_num)
+{
+ updateCycleCounters(BaseCPU::CPU_STATE_SLEEP);
+}
+
void
BaseCPU::enterPwrGating(void)
{
_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();
#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"
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);
*/
virtual void probeInstCommit(const StaticInstPtr &inst);
+ protected:
/**
* Helper method to instantiate probe points belonging to this
* object.
*/
ProbePoints::PMUUPtr pmuProbePoint(const char *name);
- /** CPU cycle counter */
- ProbePoints::PMUUPtr ppCycles;
-
/**
* Instruction commit probe point.
*
/** 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 disabled.
+ */
+ ProbePointArg<bool> *ppSleeping;
/** @} */
+ enum CPUState {
+ CPU_STATE_ON,
+ CPU_STATE_SLEEP,
+ CPU_STATE_WAKEUP
+ };
+
+ Cycles previousCycle;
+ CPUState previousState;
+ /** base method keeping track of cycle progression **/
+ inline void updateCycleCounters(CPUState state)
+ {
+ uint32_t delta = curCycle() - previousCycle;
+
+ if (previousState == CPU_STATE_ON) {
+ ppActiveCycles->notify(delta);
+ }
+
+ switch (state)
+ {
+ case CPU_STATE_WAKEUP:
+ ppSleeping->notify(false);
+ break;
+ case CPU_STATE_SLEEP:
+ ppSleeping->notify(true);
+ break;
+ default:
+ break;
+ }
+
+ ppAllCycles->notify(delta);
+
+ previousCycle = curCycle();
+ previousState = state;
+ }
// Function tracing
private:
/*
- * Copyright (c) 2012, 2015 ARM Limited
+ * Copyright (c) 2012, 2015, 2017 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
{
// for now, these are equivalent
suspendContext(thread_num);
+ updateCycleCounters(BaseCPU::CPU_STATE_SLEEP);
}
ThreadContext *
/*
- * Copyright (c) 2013-2014 ARM Limited
+ * Copyright (c) 2013-2014, 2017 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
* stages and pipeline advance) */
void evaluate() override;
- void countCycles(Cycles delta) override
- {
- cpu.ppCycles->notify(delta);
- }
-
void minorTrace() const;
/** Functions below here are BaseCPU operations passed on to pipeline
assert(drainState() != DrainState::Drained);
++numCycles;
- ppCycles->notify(1);
+ updateCycleCounters(BaseCPU::CPU_STATE_ON);
// activity = false;
deactivateThread(tid);
removeThread(tid);
+
+ updateCycleCounters(BaseCPU::CPU_STATE_SLEEP);
}
template <class Impl>
--cycles;
idleCycles += cycles;
numCycles += cycles;
- ppCycles->notify(cycles);
}
schedule(tickEvent, clockEdge());
Cycles delta = ticksToCycles(threadInfo[thread_num]->thread->lastActivate -
threadInfo[thread_num]->thread->lastSuspend);
numCycles += delta;
- ppCycles->notify(delta);
if (!tickEvent.scheduled()) {
//Make sure ticks are still on multiples of cycles
for (int i = 0; i < width || locked; ++i) {
numCycles++;
- ppCycles->notify(1);
+ updateCycleCounters(BaseCPU::CPU_STATE_ON);
if (!curStaticInst || !curStaticInst->isDelayedCommit()) {
checkForInterrupts();
/*
- * Copyright (c) 2010-2012,2015 ARM Limited
+ * Copyright (c) 2010-2012, 2015, 2017 ARM Limited
* Copyright (c) 2013 Advanced Micro Devices, Inc.
* All rights reserved
*
{
// for now, these are equivalent
suspendContext(thread_num);
+ updateCycleCounters(BaseCPU::CPU_STATE_SLEEP);
}
assert(thread->microPC() == 0);
updateCycleCounts();
+ updateCycleCounters(BaseCPU::CPU_STATE_ON);
}
// fault may be NoFault in cases where a fault is suppressed,
// for instance prefetches.
updateCycleCounts();
+ updateCycleCounters(BaseCPU::CPU_STATE_ON);
if (traceData) {
// Since there was a fault, we shouldn't trace this instruction.
completeIfetch(NULL);
updateCycleCounts();
+ updateCycleCounters(BaseCPU::CPU_STATE_ON);
}
}
}
updateCycleCounts();
+ updateCycleCounters(BaseCPU::CPU_STATE_ON);
}
_status = BaseSimpleCPU::Running;
updateCycleCounts();
+ updateCycleCounters(BaseCPU::CPU_STATE_ON);
if (pkt)
pkt->req->setAccessLatency();
pkt->req->setAccessLatency();
updateCycleCounts();
+ updateCycleCounters(BaseCPU::CPU_STATE_ON);
if (pkt->senderState) {
SplitFragmentSenderState * send_state =
const Cycles delta(curCycle() - previousCycle);
numCycles += delta;
- ppCycles->notify(delta);
previousCycle = curCycle();
}