Skip to content

Commit

Permalink
cpu-o3: branchPred: add ftq end reason stats (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
jensen-yan authored Jan 16, 2025
1 parent 28ab3ea commit 49749b6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/cpu/pred/ftb/decoupled_bpred.cc
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,8 @@ DecoupledBPUWithFTB::DBPFTBStats::DBPFTBStats(statistics::Group* parent, unsigne
ADD_STAT(controlCommitSquashOfUncond, statistics::units::Count::get(), "control squash of uncond branch at commit"),
ADD_STAT(controlCommitSquashOfUncondDirect, statistics::units::Count::get(), "control squash of uncond direct branch at commit"),
ADD_STAT(controlCommitSquashOfUncondIndirect, statistics::units::Count::get(), "control squash of indirect branch at commit"),
ADD_STAT(controlCommitSquashOfUncondReturn, statistics::units::Count::get(), "control squash of return branch at commit")
ADD_STAT(controlCommitSquashOfUncondReturn, statistics::units::Count::get(), "control squash of return branch at commit"),
ADD_STAT(ftqEndReasonDist, statistics::units::Count::get(), "distribution of ftq end reason")
{
predsOfEachStage.init(numStages);
commitPredsFromEachStage.init(numStages+1);
Expand All @@ -582,6 +583,11 @@ DecoupledBPUWithFTB::DBPFTBStats::DBPFTBStats(statistics::Group* parent, unsigne
commitTrapSquashLatencyDist.init(1,16,1);
commitNonControlSquashLatencyDist.init(1,16,1);
updateLatencyDist.init(1,64,2);
ftqEndReasonDist.init(static_cast<int>(FTQEndReason::NUM_REASONS)).flags(statistics::pdf);
ftqEndReasonDist.subname(static_cast<int>(FTQEndReason::NOT_END), "not_end");
ftqEndReasonDist.subname(static_cast<int>(FTQEndReason::TAKEN), "taken");
ftqEndReasonDist.subname(static_cast<int>(FTQEndReason::SIZE_LIMIT), "size_limit");
ftqEndReasonDist.subname(static_cast<int>(FTQEndReason::LOOP_END), "loop_end");
}

DecoupledBPUWithFTB::BpTrace::BpTrace(FetchStream &stream, const DynInstPtr &inst, bool mispred)
Expand Down Expand Up @@ -903,6 +909,7 @@ DecoupledBPUWithFTB::decoupledPredict(const StaticInstPtr &inst,
if (raw_taken) {
if (current_loop_iter >= loop_iter - 1) {
run_out_of_this_entry = true;
dbpFtbStats.ftqEndReasonDist[static_cast<int>(FTQEndReason::LOOP_END)]++;
if (loop_exit) {
taken = false;
lb.tryUnpin();
Expand All @@ -914,6 +921,7 @@ DecoupledBPUWithFTB::decoupledPredict(const StaticInstPtr &inst,
} else {
if (taken) {
run_out_of_this_entry = true;
dbpFtbStats.ftqEndReasonDist[static_cast<int>(FTQEndReason::TAKEN)]++;
}
}

Expand All @@ -931,6 +939,7 @@ DecoupledBPUWithFTB::decoupledPredict(const StaticInstPtr &inst,
inst->advancePC(*target);
if (target->instAddr() >= end) {
run_out_of_this_entry = true;
dbpFtbStats.ftqEndReasonDist[static_cast<int>(FTQEndReason::SIZE_LIMIT)]++;
}
}
DPRINTF(DecoupleBP, "Predict it %staken to %#lx\n", taken ? "" : "not ",
Expand Down
11 changes: 10 additions & 1 deletion src/cpu/pred/ftb/decoupled_bpred.hh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <vector>

#include "arch/generic/pcstate.hh"
#include "base/statistics.hh"
#include "config/the_isa.hh"
// #include "cpu/base.hh"
#include "cpu/o3/cpu_def.hh"
Expand Down Expand Up @@ -532,11 +533,19 @@ class DecoupledBPUWithFTB : public BPredUnit
statistics::Scalar controlCommitSquashOfUncondIndirect;
statistics::Scalar controlCommitSquashOfUncondReturn;


statistics::Vector ftqEndReasonDist;

DBPFTBStats(statistics::Group* parent, unsigned numStages, unsigned fsqSize);
} dbpFtbStats;

enum class FTQEndReason {
NOT_END,
TAKEN,
SIZE_LIMIT,
LOOP_END,
NUM_REASONS
};

public:
void tick();
void ideal_tick();
Expand Down

0 comments on commit 49749b6

Please sign in to comment.