Skip to content

bpu: add stats for recomputed vs actual/original prediction diff#685

Merged
jensen-yan merged 1 commit intoxs-devfrom
tage-stats1-align
Jan 12, 2026
Merged

bpu: add stats for recomputed vs actual/original prediction diff#685
jensen-yan merged 1 commit intoxs-devfrom
tage-stats1-align

Conversation

@jensen-yan
Copy link
Copy Markdown
Collaborator

@jensen-yan jensen-yan commented Dec 26, 2025

Add two per-fetchBlock statistics to track TAGE prediction differences:

  • recomputedVsActualDiff: recomputed.taken != actual_taken
  • recomputedVsOriginalDiff: recomputed.taken != original pred.taken

Summary by CodeRabbit

  • Improvements
    • Added enhanced metrics for monitoring branch prediction recomputation accuracy against actual outcomes and baseline predictions.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Dec 26, 2025

📝 Walkthrough

Walkthrough

This pull request adds per-fetch recomputation difference tracking to the BTB TAGE predictor. It introduces two new statistics counters to measure deviations between recomputed predictions and actual outcomes, and between recomputed and original predictions when update-on-read is applied. The implementation computes these differences during the BTB update path and increments counters accordingly.

Changes

Cohort / File(s) Summary
BTB TAGE Statistics Declaration
src/cpu/pred/btb/btb_tage.hh
Adds two new public Scalar fields to BTBTAGE::TageStats: recomputedVsActualDiff and recomputedVsOriginalDiff for tracking prediction variance metrics.
BTB TAGE Recomputation Tracking
src/cpu/pred/btb/btb_tage.cc
Implements per-entry difference computation and statistics updates during BTB update path; computes deltas between recomputed predictions vs. actual outcomes and vs. original predictions, sets tracking flags, and increments corresponding statistics counters.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

align-kmhv3

Suggested reviewers

  • Yakkhini
  • CJ362ff

Poem

🐰 With whiskers twitched, I hop with glee,
Tracking predictions with accuracy!
Recomputed paths both new and old,
Statistics whisper secrets untold,
TAGE's wisdom blooms like spring's first fold! 📊

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding statistics to track differences between recomputed predictions and actual/original predictions in the branch prediction unit.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tage-stats1-align

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4ec9fc8 and 6d27fb7.

📒 Files selected for processing (2)
  • src/cpu/pred/btb/btb_tage.cc
  • src/cpu/pred/btb/btb_tage.hh
🧰 Additional context used
🧬 Code graph analysis (1)
src/cpu/pred/btb/btb_tage.cc (2)
src/cpu/pred/btb/btb_tage.hh (1)
  • btb_entry (420-422)
src/cpu/pred/btb/btb_mgsc.cc (2)
  • generateSinglePrediction (243-341)
  • generateSinglePrediction (244-244)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Quick Build, Unit Tests & Smoke Test
  • GitHub Check: perf_test / XS-GEM5 - Run performance test (spec06-0.3c)
🔇 Additional comments (6)
src/cpu/pred/btb/btb_tage.hh (1)

353-355: LGTM! Clear statistics field additions.

The two new statistics fields are well-named and properly documented. The comment correctly indicates these are per-fetchBlock counters (tracking fetchBlocks with at least one difference, not counting individual branch differences).

src/cpu/pred/btb/btb_tage.cc (5)

710-711: LGTM! Proper flag initialization for per-fetchBlock tracking.

The boolean flags are correctly initialized before processing entries and will be set if any entry in the fetchBlock shows a difference.


718-722: LGTM! Correct tracking of recomputed vs original differences.

The logic properly:

  1. Only executes when updateOnRead is enabled (correct, since recomputed would equal original when disabled)
  2. Safely checks for entry existence before comparison
  3. Compares the recomputed prediction with the original prediction from metadata

726-728: LGTM! Correct tracking of recomputed vs actual differences.

The logic properly tracks when the recomputed prediction differs from the actual outcome, regardless of the updateOnRead setting.


773-779: LGTM! Correct per-fetchBlock statistics update.

The counters are correctly incremented once per fetchBlock when any entry shows a difference, matching the intended per-fetchBlock granularity described in the PR objectives.


1046-1047: LGTM! Proper statistics initialization.

The statistics are correctly initialized with clear descriptions that accurately convey the per-fetchBlock granularity of these counters.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Add two per-fetchBlock statistics to track TAGE prediction differences:
- recomputedVsActualDiff: recomputed.taken != actual_taken
- recomputedVsOriginalDiff: recomputed.taken != original pred.taken
@github-actions
Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.1772 -
This PR 2.1772 ➡️ 0.0000 (0.00%)

✅ Difftest smoke test passed!

@XiangShanRobot
Copy link
Copy Markdown

[Generated by GEM5 Performance Robot]
commit: 6d27fb7
workflow: gem5 Align BTB Performance Test(0.3c)

Align BTB Performance

Overall Score

PR Master Diff(%)
Score 17.53 17.53 -0.01 🔴

@jensen-yan jensen-yan merged commit 2198991 into xs-dev Jan 12, 2026
3 checks passed
@jensen-yan jensen-yan deleted the tage-stats1-align branch January 12, 2026 02:35
@coderabbitai coderabbitai bot mentioned this pull request Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants