Skip to content

Commit 6d27fb7

Browse files
committed
bpu: add stats for recomputed vs actual/original prediction diff
Add two per-fetchBlock statistics to track TAGE prediction differences: - recomputedVsActualDiff: recomputed.taken != actual_taken - recomputedVsOriginalDiff: recomputed.taken != original pred.taken
1 parent 4ec9fc8 commit 6d27fb7

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/cpu/pred/btb/btb_tage.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,15 +707,25 @@ BTBTAGE::update(const FetchStream &stream) {
707707
}
708708

709709
// Process each BTB entry
710+
bool hasRecomputedVsActualDiff = false;
711+
bool hasRecomputedVsOriginalDiff = false;
710712
for (auto &btb_entry : entries_to_update) {
711713
bool actual_taken = stream.exeTaken && stream.exeBranchInfo == btb_entry;
712714
TagePrediction recomputed;
713715
if (updateOnRead) { // if update on read is enabled, re-read providers using snapshot
714716
// Re-read providers using snapshot (do not rely on prediction-time main/alt)
715717
recomputed = generateSinglePrediction(btb_entry, startAddr, predMeta);
718+
// Track differences for statistics
719+
auto it = predMeta->preds.find(btb_entry.pc);
720+
if (it != predMeta->preds.end() && recomputed.taken != it->second.taken) {
721+
hasRecomputedVsOriginalDiff = true;
722+
}
716723
} else { // otherwise, use the prediction from the prediction-time main/alt
717724
recomputed = predMeta->preds[btb_entry.pc];
718725
}
726+
if (recomputed.taken != actual_taken) {
727+
hasRecomputedVsActualDiff = true;
728+
}
719729

720730
// Update predictor state and check if need to allocate new entry
721731
bool need_allocate = updatePredictorStateAndCheckAllocation(btb_entry, actual_taken, recomputed, stream);
@@ -760,6 +770,13 @@ BTBTAGE::update(const FetchStream &stream) {
760770
}
761771
#endif
762772
}
773+
// Update recomputed difference statistics (per fetchBlock)
774+
if (hasRecomputedVsActualDiff) {
775+
tageStats.recomputedVsActualDiff++;
776+
}
777+
if (hasRecomputedVsOriginalDiff) {
778+
tageStats.recomputedVsOriginalDiff++;
779+
}
763780
if (getDelay() <2){
764781
checkUtageUpdateMisspred(stream);
765782
}
@@ -1026,6 +1043,8 @@ BTBTAGE::TageStats::TageStats(statistics::Group* parent, int numPredictors, int
10261043
ADD_STAT(updateAllocSuccess, statistics::units::Count::get(), "alloc success when update"),
10271044
ADD_STAT(updateMispred, statistics::units::Count::get(), "mispred when update"),
10281045
ADD_STAT(updateResetU, statistics::units::Count::get(), "reset u when update"),
1046+
ADD_STAT(recomputedVsActualDiff, statistics::units::Count::get(), "fetchBlocks where recomputed.taken != actual_taken"),
1047+
ADD_STAT(recomputedVsOriginalDiff, statistics::units::Count::get(), "fetchBlocks where recomputed.taken != original pred.taken"),
10291048
ADD_STAT(updateBankConflict, statistics::units::Count::get(), "number of bank conflicts detected"),
10301049
ADD_STAT(updateDeferredDueToConflict, statistics::units::Count::get(), "number of updates deferred due to bank conflict (retried later)"),
10311050
ADD_STAT(updateBankConflictPerBank, statistics::units::Count::get(), "bank conflicts per bank"),

src/cpu/pred/btb/btb_tage.hh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ class BTBTAGE : public TimedBaseBTBPredictor
350350
Scalar updateMispred;
351351
Scalar updateResetU;
352352

353+
// Recomputed prediction difference statistics (per fetchBlock)
354+
Scalar recomputedVsActualDiff; // recomputed.taken != actual_taken
355+
Scalar recomputedVsOriginalDiff; // recomputed.taken != original pred.taken
356+
353357
// Bank conflict statistics
354358
Scalar updateBankConflict; // Number of bank conflicts detected
355359
Scalar updateDeferredDueToConflict; // Number of updates deferred due to bank conflict (retried later)

0 commit comments

Comments
 (0)