}
}
+ProbePoints::PMUUPtr
+BaseCPU::pmuProbePoint(const char *name)
+{
+ ProbePoints::PMUUPtr ptr;
+ ptr.reset(new ProbePoints::PMU(getProbeManager(), name));
+
+ return ptr;
+}
+
+void
+BaseCPU::regProbePoints()
+{
+ ppCycles = pmuProbePoint("Cycles");
+
+ ppRetiredInsts = pmuProbePoint("RetiredInsts");
+ ppRetiredLoads = pmuProbePoint("RetiredLoads");
+ ppRetiredStores = pmuProbePoint("RetiredStores");
+ ppRetiredBranches = pmuProbePoint("RetiredBranches");
+}
+
+void
+BaseCPU::probeInstCommit(const StaticInstPtr &inst)
+{
+ if (!inst->isMicroop() || inst->isLastMicroop())
+ ppRetiredInsts->notify(1);
+
+
+ if (inst->isLoad())
+ ppRetiredLoads->notify(1);
+
+ if (inst->isStore())
+ ppRetiredLoads->notify(1);
+
+ if (inst->isControl())
+ ppRetiredBranches->notify(1);
+}
void
BaseCPU::regStats()
#include "sim/eventq.hh"
#include "sim/full_system.hh"
#include "sim/insttracer.hh"
+#include "sim/probe/pmu.hh"
#include "sim/system.hh"
struct BaseCPUParams;
virtual void startup();
virtual void regStats();
+ void regProbePoints() M5_ATTR_OVERRIDE;
+
void registerThreadContexts();
/**
*/
void scheduleLoadStop(ThreadID tid, Counter loads, const char *cause);
+ public:
+ /**
+ * @{
+ * @name PMU Probe points.
+ */
+
+ /**
+ * Helper method to trigger PMU probes for a committed
+ * instruction.
+ *
+ * @param inst Instruction that just committed
+ */
+ virtual void probeInstCommit(const StaticInstPtr &inst);
+
+ /**
+ * Helper method to instantiate probe points belonging to this
+ * object.
+ *
+ * @param name Name of the probe point.
+ * @return A unique_ptr to the new probe point.
+ */
+ ProbePoints::PMUUPtr pmuProbePoint(const char *name);
+
+ /** CPU cycle counter */
+ ProbePoints::PMUUPtr ppCycles;
+
+ /**
+ * Instruction commit probe point.
+ *
+ * This probe point is triggered whenever one or more instructions
+ * are committed. It is normally triggered once for every
+ * instruction. However, CPU models committing bundles of
+ * instructions may call notify once for the entire bundle.
+ */
+ ProbePoints::PMUUPtr ppRetiredInsts;
+
+ /** Retired load instructions */
+ ProbePoints::PMUUPtr ppRetiredLoads;
+ /** Retired store instructions */
+ ProbePoints::PMUUPtr ppRetiredStores;
+
+ /** Retired branches (any type) */
+ ProbePoints::PMUUPtr ppRetiredBranches;
+
+ /** @} */
+
+
+
// Function tracing
private:
bool functionTracingEnabled;
/* Set the CP SeqNum to the numOps commit number */
if (inst->traceData)
inst->traceData->setCPSeq(thread->numOp);
+
+ cpu.probeInstCommit(inst->staticInst);
}
bool
* stages and pipeline advance) */
void evaluate();
+ void countCycles(Cycles delta) M5_ATTR_OVERRIDE
+ {
+ cpu.ppCycles->notify(delta);
+ }
+
void minorTrace() const;
/** Functions below here are BaseCPU operations passed on to pipeline
void
FullO3CPU<Impl>::regProbePoints()
{
+ BaseCPU::regProbePoints();
+
ppInstAccessComplete = new ProbePointArg<PacketPtr>(getProbeManager(), "InstAccessComplete");
ppDataAccessComplete = new ProbePointArg<std::pair<DynInstPtr, PacketPtr> >(getProbeManager(), "DataAccessComplete");
+
fetch.regProbePoints();
iew.regProbePoints();
commit.regProbePoints();
assert(getDrainState() != Drainable::Drained);
++numCycles;
+ ppCycles->notify(1);
// activity = false;
// Check for instruction-count-based events.
comInstEventQueue[tid]->serviceEvents(thread[tid]->numInst);
system->instEventQueue.serviceEvents(system->totalNumInsts);
+
+ probeInstCommit(inst->staticInst);
}
template <class Impl>
Cycles cycles(curCycle() - lastRunningCycle);
// @todo: This is an oddity that is only here to match the stats
- if (cycles != 0)
+ if (cycles > 1) {
--cycles;
- idleCycles += cycles;
- numCycles += cycles;
+ idleCycles += cycles;
+ numCycles += cycles;
+ ppCycles->notify(cycles);
+ }
schedule(tickEvent, clockEdge());
}
assert(!tickEvent.scheduled());
notIdleFraction = 1;
- numCycles += ticksToCycles(thread->lastActivate - thread->lastSuspend);
+ Cycles delta = ticksToCycles(thread->lastActivate - thread->lastSuspend);
+ numCycles += delta;
+ ppCycles->notify(delta);
//Make sure ticks are still on multiples of cycles
schedule(tickEvent, clockEdge(Cycles(0)));
for (int i = 0; i < width || locked; ++i) {
numCycles++;
+ ppCycles->notify(1);
if (!curStaticInst || !curStaticInst->isDelayedCommit())
checkForInterrupts();
void
AtomicSimpleCPU::regProbePoints()
{
+ BaseCPU::regProbePoints();
+
ppCommit = new ProbePointArg<pair<SimpleThread*, const StaticInstPtr>>
(getProbeManager(), "Commit");
}
delete traceData;
traceData = NULL;
}
+
+ // Call CPU instruction commit probes
+ probeInstCommit(curStaticInst);
}
void
assert(!stayAtPC);
assert(microPC() == 0);
- numCycles += curCycle() - previousCycle;
+ updateCycleCounts();
}
{
// fault may be NoFault in cases where a fault is suppressed,
// for instance prefetches.
- numCycles += curCycle() - previousCycle;
- previousCycle = curCycle();
+ updateCycleCounts();
if (traceData) {
// Since there was a fault, we shouldn't trace this instruction.
_status = IcacheWaitResponse;
completeIfetch(NULL);
- numCycles += curCycle() - previousCycle;
- previousCycle = curCycle();
+ updateCycleCounts();
}
}
advanceInst(fault);
}
- numCycles += curCycle() - previousCycle;
- previousCycle = curCycle();
+ updateCycleCounts();
}
_status = BaseSimpleCPU::Running;
- numCycles += curCycle() - previousCycle;
- previousCycle = curCycle();
+ updateCycleCounts();
if (pkt)
pkt->req->setAccessLatency();
pkt->req->getFlags().isSet(Request::NO_ACCESS));
pkt->req->setAccessLatency();
- numCycles += curCycle() - previousCycle;
- previousCycle = curCycle();
+
+ updateCycleCounts();
if (pkt->senderState) {
SplitFragmentSenderState * send_state =
advanceInst(fault);
}
+void
+TimingSimpleCPU::updateCycleCounts()
+{
+ const Cycles delta(curCycle() - previousCycle);
+
+ numCycles += delta;
+ ppCycles->notify(delta);
+
+ previousCycle = curCycle();
+}
+
void
TimingSimpleCPU::DcachePort::recvTimingSnoopReq(PacketPtr pkt)
{
};
+ void updateCycleCounts();
+
IcachePort icachePort;
DcachePort dcachePort;
PacketPtr ifetch_pkt;
PacketPtr dcache_pkt;
- Tick previousCycle;
+ Cycles previousCycle;
protected:
{
++owner.tickCycles;
++owner.numCycles;
+ owner.countCycles(Cycles(1));
owner.evaluate();
if (owner.running) {
owner.object.schedule(this,
object.schedule(event, object.clockEdge(Cycles(1)));
running = true;
numCycles += cyclesSinceLastStopped();
+ countCycles(cyclesSinceLastStopped());
}
}
/** Action to call on the clock tick */
virtual void evaluate() = 0;
+
+ /**
+ * Callback to handle cycle statistics and probes.
+ *
+ * This callback is called at the beginning of a new cycle active
+ * cycle and when restarting the ticked object. The delta
+ * parameter indicates the number of cycles elapsed since the
+ * previous call is normally '1' unless the object has been
+ * stopped and restarted.
+ *
+ * @param delta Number of cycles since the previous call.
+ */
+ virtual void countCycles(Cycles delta) {}
};
/** TickedObject attaches Ticked to ClockedObject and can be used as