Skip to content

cpu: Align BTBTAGE update reread and bank conflicts#764

Open
jensen-yan wants to merge 2 commits intoxs-devfrom
tage-bankconf-align
Open

cpu: Align BTBTAGE update reread and bank conflicts#764
jensen-yan wants to merge 2 commits intoxs-devfrom
tage-bankconf-align

Conversation

@jensen-yan
Copy link
Collaborator

@jensen-yan jensen-yan commented Feb 27, 2026

Change-Id: I39cbd80ec9fcf1bcaa443814e62cee39b5ed163a

Summary by CodeRabbit

  • Bug Fixes

    • Smarter per-entry decision for when table re-reads are needed during prediction updates, reducing unnecessary recomputation.
    • Bank conflicts are only reported when an update actually requires a re-read, improving conflict accuracy.
  • Tests

    • Added test coverage for bank-conflict behavior when re-reads are/aren’t required.
  • Chores

    • Updated simulator guidance message to recommend the RTL-like update reread policy.

Change-Id: I39cbd80ec9fcf1bcaa443814e62cee39b5ed163a
@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

📝 Walkthrough

Walkthrough

Adds per-entry reread decision logic to BTBTAGE: new helpers determine when updates must reread provider predictions, update flow now selectively recomputes or reuses metadata predictions, and bank-conflict checks are performed only when rereads are required. A test verifies bank-conflict is skipped when reread isn't needed.

Changes

Cohort / File(s) Summary
BTB TAGE core
src/cpu/pred/btb/btb_tage.cc
Adds per-entry helper logic (needRereadForUpdateEntry, needRereadForUpdate), integrates reread decisions into canResolveUpdate and update flow, selectively recomputes predictions via generateSinglePrediction or reuses metadata, and adjusts bank-conflict checks and logging.
BTB TAGE headers
src/cpu/pred/btb/btb_tage.hh
Declares new private helpers for reread logic and an extended handleNewEntryAllocation signature; updates comments to reflect reread/update-on-read policy.
Tests
src/cpu/pred/btb/test/btb_tage.test.cc
Adds BankConflictOnlyWhenRereadNeeded test to ensure bank-conflict counters aren't incremented when update-on-read is enabled and reread isn't required.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

perf, align-kmhv3

Suggested reviewers

  • Yakkhini
  • CJ362ff

Poem

🐇 I nibble at meta, hop between reads,

If reuse will do, I skip extra deeds.
Banks stay calm, counters sleep tight,
A clever update keeps the fetches light.
Hoppity-hop—BTBTAGE, good night ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: aligning BTBTAGE update reread logic with bank conflict detection, which is the core focus of the implementation changes across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tage-bankconf-align

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.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 94b74481c9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +796 to 799
} else {
// Provider was already recorded in metadata and can be used directly.
recomputed = meta_pred;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Re-read provider state before using stored prediction info

When updateOnRead is enabled, this new fast path skips generateSinglePrediction for provider-used, non-mispred entries and reuses prediction-time metadata directly; however, predictor tables are mutable between prediction and resolve (older targets can update/allocate first), so the recorded {table,index,way} can become stale. updatePredictorStateAndCheckAllocation then updates the entry at that stale location without a tag re-check, which can train the wrong branch entry and silently corrupt BTBTAGE state/results.

Useful? React with 👍 / 👎.

@github-actions
Copy link

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.1727 -
This PR 2.2133 📈 +0.0406 (+1.87%)

✅ Difftest smoke test passed!

Change-Id: If5b351f32a70f1397532c9eb61692efb7a2bfc2a
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/cpu/pred/btb/btb_tage.cc`:
- Around line 448-455: The comment above the early return is misleading:
updateOnRead == false does not unconditionally prevent rereads because earlier
checks (missing metadata/prediction) can still force a reread; update the
comment near the block that checks updateOnRead and returns false to state that
updateOnRead disables rereads in normal cases but missing metadata/prediction
still trigger a forced reread, and keep the final sentence describing the
alignment experiment that the function returns it->second.useAlt to allow
rereads only for the alt/base path case.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 36734c73-a3c5-4673-b4e3-63c20193d31a

📥 Commits

Reviewing files that changed from the base of the PR and between 94b7448 and e6e70f3.

📒 Files selected for processing (2)
  • src/cpu/pred/btb/btb_tage.cc
  • src/cpu/pred/btb/btb_tage.hh

Comment on lines +448 to +455
// Legacy mode: if update-on-read is disabled, never reread.
if (!updateOnRead) {
return false;
}

// Alignment experiment:
// only when alt/base path is used do we reread and potentially incur bank conflicts.
return it->second.useAlt;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Comment is slightly misleading vs actual control flow.

Line 448 says “never reread” when updateOnRead is disabled, but Lines 426-442 still force reread when metadata/prediction is missing. Please align the comment with actual behavior.

Suggested wording tweak
-    // Legacy mode: if update-on-read is disabled, never reread.
+    // Legacy mode: if update-on-read is disabled, skip reread when meta prediction exists.
+    // Missing metadata still forces reread to recover provider information.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Legacy mode: if update-on-read is disabled, never reread.
if (!updateOnRead) {
return false;
}
// Alignment experiment:
// only when alt/base path is used do we reread and potentially incur bank conflicts.
return it->second.useAlt;
// Legacy mode: if update-on-read is disabled, skip reread when meta prediction exists.
// Missing metadata still forces reread to recover provider information.
if (!updateOnRead) {
return false;
}
// Alignment experiment:
// only when alt/base path is used do we reread and potentially incur bank conflicts.
return it->second.useAlt;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cpu/pred/btb/btb_tage.cc` around lines 448 - 455, The comment above the
early return is misleading: updateOnRead == false does not unconditionally
prevent rereads because earlier checks (missing metadata/prediction) can still
force a reread; update the comment near the block that checks updateOnRead and
returns false to state that updateOnRead disables rereads in normal cases but
missing metadata/prediction still trigger a forced reread, and keep the final
sentence describing the alignment experiment that the function returns
it->second.useAlt to allow rereads only for the alt/base path case.

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.1796 -
This PR 2.2189 📈 +0.0393 (+1.81%)

✅ Difftest smoke test passed!

@XiangShanRobot
Copy link

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

Align BTB Performance

Overall Score

PR Master Diff(%)
Score 17.68 17.56 +0.68 🟢

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

Align BTB Performance

Overall Score

PR Previous Commit Diff(%)
Score 17.68 17.68 -0.02 🔴

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.

2 participants