Skip to content

Commit 2198991

Browse files
authored
bpu: add stats for recomputed vs actual/original prediction diff [skip ci](#685)
Add two per-fetchBlock statistics to track TAGE prediction differences: - recomputedVsActualDiff: recomputed.taken != actual_taken - recomputedVsOriginalDiff: recomputed.taken != original pred.taken
1 parent a37e734 commit 2198991

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
@@ -697,15 +697,25 @@ BTBTAGE::update(const FetchStream &stream) {
697697
}
698698

699699
// Process each BTB entry
700+
bool hasRecomputedVsActualDiff = false;
701+
bool hasRecomputedVsOriginalDiff = false;
700702
for (auto &btb_entry : entries_to_update) {
701703
bool actual_taken = stream.exeTaken && stream.exeBranchInfo == btb_entry;
702704
TagePrediction recomputed;
703705
if (updateOnRead) { // if update on read is enabled, re-read providers using snapshot
704706
// Re-read providers using snapshot (do not rely on prediction-time main/alt)
705707
recomputed = generateSinglePrediction(btb_entry, startAddr, predMeta);
708+
// Track differences for statistics
709+
auto it = predMeta->preds.find(btb_entry.pc);
710+
if (it != predMeta->preds.end() && recomputed.taken != it->second.taken) {
711+
hasRecomputedVsOriginalDiff = true;
712+
}
706713
} else { // otherwise, use the prediction from the prediction-time main/alt
707714
recomputed = predMeta->preds[btb_entry.pc];
708715
}
716+
if (recomputed.taken != actual_taken) {
717+
hasRecomputedVsActualDiff = true;
718+
}
709719

710720
// Update predictor state and check if need to allocate new entry
711721
bool need_allocate = updatePredictorStateAndCheckAllocation(btb_entry, actual_taken, recomputed, stream);
@@ -750,6 +760,13 @@ BTBTAGE::update(const FetchStream &stream) {
750760
}
751761
#endif
752762
}
763+
// Update recomputed difference statistics (per fetchBlock)
764+
if (hasRecomputedVsActualDiff) {
765+
tageStats.recomputedVsActualDiff++;
766+
}
767+
if (hasRecomputedVsOriginalDiff) {
768+
tageStats.recomputedVsOriginalDiff++;
769+
}
753770
if (getDelay() <2){
754771
checkUtageUpdateMisspred(stream);
755772
}
@@ -1011,6 +1028,8 @@ BTBTAGE::TageStats::TageStats(statistics::Group* parent, int numPredictors, int
10111028
ADD_STAT(updateAllocSuccess, statistics::units::Count::get(), "alloc success when update"),
10121029
ADD_STAT(updateMispred, statistics::units::Count::get(), "mispred when update"),
10131030
ADD_STAT(updateResetU, statistics::units::Count::get(), "reset u when update"),
1031+
ADD_STAT(recomputedVsActualDiff, statistics::units::Count::get(), "fetchBlocks where recomputed.taken != actual_taken"),
1032+
ADD_STAT(recomputedVsOriginalDiff, statistics::units::Count::get(), "fetchBlocks where recomputed.taken != original pred.taken"),
10141033
ADD_STAT(updateBankConflict, statistics::units::Count::get(), "number of bank conflicts detected"),
10151034
ADD_STAT(updateDeferredDueToConflict, statistics::units::Count::get(), "number of updates deferred due to bank conflict (retried later)"),
10161035
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
@@ -343,6 +343,10 @@ class BTBTAGE : public TimedBaseBTBPredictor
343343
Scalar updateMispred;
344344
Scalar updateResetU;
345345

346+
// Recomputed prediction difference statistics (per fetchBlock)
347+
Scalar recomputedVsActualDiff; // recomputed.taken != actual_taken
348+
Scalar recomputedVsOriginalDiff; // recomputed.taken != original pred.taken
349+
346350
// Bank conflict statistics
347351
Scalar updateBankConflict; // Number of bank conflicts detected
348352
Scalar updateDeferredDueToConflict; // Number of updates deferred due to bank conflict (retried later)

0 commit comments

Comments
 (0)