cpu: Add branch predictor PMU probe points
This changeset adds probe points that can be used to implement PMU counters for branch predictor stats. The following probes are supported: * BPRedUnit::ppBranches / Branches * BPRedUnit::ppMisses / Misses
This commit is contained in:
parent
3697990c27
commit
76b0ff9ecd
|
@ -56,6 +56,7 @@
|
||||||
#include "cpu/inst_seq.hh"
|
#include "cpu/inst_seq.hh"
|
||||||
#include "cpu/static_inst.hh"
|
#include "cpu/static_inst.hh"
|
||||||
#include "params/BranchPredictor.hh"
|
#include "params/BranchPredictor.hh"
|
||||||
|
#include "sim/probe/pmu.hh"
|
||||||
#include "sim/sim_object.hh"
|
#include "sim/sim_object.hh"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,6 +77,8 @@ class BPredUnit : public SimObject
|
||||||
*/
|
*/
|
||||||
void regStats();
|
void regStats();
|
||||||
|
|
||||||
|
void regProbePoints() M5_ATTR_OVERRIDE;
|
||||||
|
|
||||||
/** Perform sanity checks after a drain. */
|
/** Perform sanity checks after a drain. */
|
||||||
void drainSanityCheck() const;
|
void drainSanityCheck() const;
|
||||||
|
|
||||||
|
@ -290,6 +293,34 @@ class BPredUnit : public SimObject
|
||||||
Stats::Scalar usedRAS;
|
Stats::Scalar usedRAS;
|
||||||
/** Stat for number of times the RAS is incorrect. */
|
/** Stat for number of times the RAS is incorrect. */
|
||||||
Stats::Scalar RASIncorrect;
|
Stats::Scalar RASIncorrect;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* @{
|
||||||
|
* @name PMU Probe points.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Branches seen by the branch predictor
|
||||||
|
*
|
||||||
|
* @note This counter includes speculative branches.
|
||||||
|
*/
|
||||||
|
ProbePoints::PMUUPtr ppBranches;
|
||||||
|
|
||||||
|
/** Miss-predicted branches */
|
||||||
|
ProbePoints::PMUUPtr ppMisses;
|
||||||
|
|
||||||
|
/** @} */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __CPU_PRED_BPRED_UNIT_HH__
|
#endif // __CPU_PRED_BPRED_UNIT_HH__
|
||||||
|
|
|
@ -119,6 +119,22 @@ BPredUnit::regStats()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProbePoints::PMUUPtr
|
||||||
|
BPredUnit::pmuProbePoint(const char *name)
|
||||||
|
{
|
||||||
|
ProbePoints::PMUUPtr ptr;
|
||||||
|
ptr.reset(new ProbePoints::PMU(getProbeManager(), name));
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BPredUnit::regProbePoints()
|
||||||
|
{
|
||||||
|
ppBranches = pmuProbePoint("Branches");
|
||||||
|
ppMisses = pmuProbePoint("Misses");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BPredUnit::drainSanityCheck() const
|
BPredUnit::drainSanityCheck() const
|
||||||
{
|
{
|
||||||
|
@ -141,6 +157,7 @@ BPredUnit::predict(const StaticInstPtr &inst, const InstSeqNum &seqNum,
|
||||||
TheISA::PCState target = pc;
|
TheISA::PCState target = pc;
|
||||||
|
|
||||||
++lookups;
|
++lookups;
|
||||||
|
ppBranches->notify(1);
|
||||||
|
|
||||||
void *bp_history = NULL;
|
void *bp_history = NULL;
|
||||||
|
|
||||||
|
@ -259,6 +276,8 @@ BPredUnit::predictInOrder(const StaticInstPtr &inst, const InstSeqNum &seqNum,
|
||||||
TheISA::PCState target;
|
TheISA::PCState target;
|
||||||
|
|
||||||
++lookups;
|
++lookups;
|
||||||
|
ppBranches->notify(1);
|
||||||
|
|
||||||
DPRINTF(Branch, "[tid:%i] [sn:%i] %s ... PC %s doing branch "
|
DPRINTF(Branch, "[tid:%i] [sn:%i] %s ... PC %s doing branch "
|
||||||
"prediction\n", tid, seqNum,
|
"prediction\n", tid, seqNum,
|
||||||
inst->disassemble(instPC.instAddr()), instPC);
|
inst->disassemble(instPC.instAddr()), instPC);
|
||||||
|
@ -438,6 +457,7 @@ BPredUnit::squash(const InstSeqNum &squashed_sn,
|
||||||
History &pred_hist = predHist[tid];
|
History &pred_hist = predHist[tid];
|
||||||
|
|
||||||
++condIncorrect;
|
++condIncorrect;
|
||||||
|
ppMisses->notify(1);
|
||||||
|
|
||||||
DPRINTF(Branch, "[tid:%i]: Squashing from sequence number %i, "
|
DPRINTF(Branch, "[tid:%i]: Squashing from sequence number %i, "
|
||||||
"setting target to %s.\n", tid, squashed_sn, corrTarget);
|
"setting target to %s.\n", tid, squashed_sn, corrTarget);
|
||||||
|
|
Loading…
Reference in a new issue