Skip to content

bpu: test tage not use alt table#690

Open
jensen-yan wants to merge 1 commit into
xs-devfrom
noAlt-align
Open

bpu: test tage not use alt table#690
jensen-yan wants to merge 1 commit into
xs-devfrom
noAlt-align

Conversation

@jensen-yan

@jensen-yan jensen-yan commented Jan 5, 2026

Copy link
Copy Markdown
Collaborator

Change-Id: I4d1d26b637f35f566120a3fda6119699be7c32cf

Summary by CodeRabbit

  • Refactor
    • Simplified branch prediction logic by streamlining the alternate prediction path, reducing overall mechanism complexity
    • Cleaned up debug output and diagnostic tracing for improved clarity

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

Change-Id: I4d1d26b637f35f566120a3fda6119699be7c32cf
@coderabbitai

coderabbitai Bot commented Jan 5, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The PR disables the alternate TAGE prediction provider within the BTB TAGE predictor. The alternate prediction path is removed from the logic while maintaining minimal metadata compatibility. State updates and allocation decisions no longer reference the alternate provider.

Changes

Cohort / File(s) Summary
BTB TAGE Predictor Alt Provider Removal
src/cpu/pred/btb/btb_tage.cc
Removes alternate provider tracking and prediction paths: alt_provided and alt_info logic removed; prediction path simplified to use only main table matches; state updates and allocation no longer compute/use alternate predictions; debug output adjusted to reflect disabled alternate path

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

align-kmhv3

Suggested reviewers

  • tastynoob
  • Yakkhini

Poem

🐰 A twist in the tangle of branches so deep,
Where alternate paths took their leap,
Now simpler streams guide the main way,
One truth leads forward to prediction's say! 🎯

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 'bpu: test tage not use alt table' is partially related to the changeset. It mentions TAGE and disabling the alt table, which aligns with the main change of removing alt provider support, but the phrasing 'test tage' is imprecise and doesn't clearly convey that this is removing alt support rather than just testing it.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings

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.

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

Copy link
Copy Markdown

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: 323d9eead9

ℹ️ 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 thread src/cpu/pred/btb/btb_tage.cc

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/cpu/pred/btb/btb_tage.cc (2)

474-479: Consider removing dead humility mechanism code.

Since alt_is_correct_and_strong is hardcoded to false (line 474), the humility mechanism at lines 477-479 is now dead code:

// a. Special reset (humility mechanism)
if (alt_is_correct_and_strong && main_is_correct) {  // ← never true
    way.useful = 0;
    DPRINTF(TAGEUseful, "useful bit reset to 0 due to humility rule\n");
}

This is intentional (alt provider removed), but the dead code could be removed or documented more clearly.

🔎 Optional cleanup
     // Update useful bit based on several conditions
     bool main_is_correct = main_info.taken() == actual_taken;
-    const bool alt_is_correct_and_strong = false; // no alt provider
-
-    // a. Special reset (humility mechanism)
-    if (alt_is_correct_and_strong && main_is_correct) {
-        way.useful = 0;
-        DPRINTF(TAGEUseful, "useful bit reset to 0 due to humility rule\n");
-    } else if (main_info.taken() != alt_taken) {
-        // b. Original logic to set useful bit high
+    // Humility mechanism (alt_is_correct_and_strong check) disabled with alt provider removal
+    if (main_info.taken() != alt_taken) {
+        // Set useful bit high when main differs from base and is correct
         if (main_is_correct) {
             way.useful = 1;
         }
     }

500-504: Optional: Simplify condition since alt_info.found is always false.

Since the alternate provider is disabled, alt_info.found is always false (line 214), making the condition !alt_info.found always true:

if (used_alt && !alt_info.found) {  // ← !alt_info.found always true

The condition could be simplified to if (used_alt) for clarity, though this doesn't affect correctness.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0f804c and 323d9ee.

📒 Files selected for processing (1)
  • src/cpu/pred/btb/btb_tage.cc
🧰 Additional context used
🧬 Code graph analysis (1)
src/cpu/pred/btb/btb_tage.cc (1)
src/cpu/pred/btb/btb_tage.hh (5)
  • TageTableInfo (85-85)
  • TageTableInfo (86-87)
  • btb_entry (416-418)
  • startPC (170-171)
  • startPC (430-437)
⏰ 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 (1)
src/cpu/pred/btb/btb_tage.cc (1)

211-294: Prediction path correctly implements alt provider removal.

The changes properly disable the alternate TAGE provider while maintaining the base fallback mechanism. Key aspects:

  • alt_info is kept empty for schema compatibility (line 214)
  • First match becomes main prediction; loop breaks to prevent finding a second match (line 254)
  • Alt prediction now means base fallback: alt_taken = base_taken (line 272)
  • use_alt_on_na mechanism preserved to choose between weak main and base fallback (lines 276-288)

The logic is clear and internally consistent.

Comment on lines 439 to +443
Addr base_idx = getBaseTableIndex(startPC);
unsigned branch_idx = getBranchIndexInBlock(entry.pc, startPC);
bool base_taken = baseTable[base_idx][branch_idx] >= 0;
bool alt_taken = alt_info.found ? alt_info.taken() : base_taken;
// Alt provider disabled: "alt" is always the base fallback.
const bool alt_taken = base_taken;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fix inconsistent base_taken calculation in update path.

The update path recalculates base_taken using simplified logic that always reads from baseTable (line 441), but the prediction path uses conditional logic based on getDelay() and usingBasetable (lines 266-269):

// Prediction path (lines 266-269):
const bool base_taken =
    getDelay() != 0 ?
        (usingBasetable ? baseTable[base_idx][branch_idx] >= 0 : btb_entry.ctr >= 0) :
        btb_entry.ctr >= 0;

// Update path (line 441):
bool base_taken = baseTable[base_idx][branch_idx] >= 0;  // ← always baseTable

This inconsistency means the update path may determine alt_correct (line 451) based on a different prediction than what was actually made, leading to incorrect use_alt_on_na counter updates and statistics.

Solution: Use pred.altPred which already contains the correctly calculated prediction from generateSinglePrediction:

🔎 Proposed fix
-    // Use base table instead of entry.ctr for fallback prediction
-    Addr startPC = stream.getRealStartPC();
-    Addr base_idx = getBaseTableIndex(startPC);
-    unsigned branch_idx = getBranchIndexInBlock(entry.pc, startPC);
-    bool base_taken = baseTable[base_idx][branch_idx] >= 0;
-    // Alt provider disabled: "alt" is always the base fallback.
-    const bool alt_taken = base_taken;
+    // Alt provider disabled: use pred.altPred which was calculated in generateSinglePrediction
+    const bool alt_taken = pred.altPred;

This ensures consistency between prediction and update, and you can remove the now-unused base_idx and branch_idx calculations from lines 439-440.

🤖 Prompt for AI Agents
In src/cpu/pred/btb/btb_tage.cc around lines 439-443, the update path recomputes
base_taken directly from baseTable which is inconsistent with the prediction
path that considers getDelay() and usingBasetable; replace the recomputed
base/alt logic by using the already-computed pred.altPred (and/or pred.basePred
as appropriate) from generateSinglePrediction for determining base_taken and
alt_taken, and remove the now-unused base_idx and branch_idx calculations so the
update uses the exact prediction made during the prediction phase.

@XiangShanRobot

Copy link
Copy Markdown

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

Align BTB Performance

Overall Score

PR Master Diff(%)
Score 17.49 17.53 -0.22 🔴

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants