Skip to content

Tage way tuning align#803

Open
CJ362ff wants to merge 4 commits intoxs-devfrom
tage-way-tuning-align
Open

Tage way tuning align#803
CJ362ff wants to merge 4 commits intoxs-devfrom
tage-way-tuning-align

Conversation

@CJ362ff
Copy link
Collaborator

@CJ362ff CJ362ff commented Mar 19, 2026

Summary by CodeRabbit

  • Refactor

    • Adjusted branch predictor table configuration to increase capacity and associativity for deeper coverage.
  • Performance

    • Expected improvements in prediction accuracy, reduced misprediction penalties, and overall processor efficiency from the retuned predictor defaults.

Cao Jiaming added 2 commits March 19, 2026 17:44
Change-Id: I7ecf06a54cd1183e3200549ee79cb14ff1920636
Change-Id: If809499441e415303b9fec9705de69bab83390a1
@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

📝 Walkthrough

Walkthrough

Updated BTBTAGE defaults in the branch predictor: each of the eight TAGE table sizes increased from 2048 to 8192 entries, and each table's associativity (numWays) increased from 2 to 8. No other logic or parameters changed.

Changes

Cohort / File(s) Summary
Branch Predictor Configuration
src/cpu/pred/BranchPredictor.py
Changed BTBTAGE.tableSizes default from VectorParam.Unsigned([2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048], ...) to VectorParam.Unsigned([8192] * 8, ...). Changed BTBTAGE.numWays default from VectorParam.Unsigned([2] * 8, ...) to VectorParam.Unsigned([8] * 8, ...).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

align-kmhv3, perf

Suggested reviewers

  • jensen-yan

Poem

🐰 I hopped through tables, tall and wide,
From two to eight, each way’s allied,
Eight thousand rows where branches hide,
I twitch my nose — predictor amplified! 🥕

🚥 Pre-merge checks | ✅ 3
✅ 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 'Tage way tuning align' directly relates to the changeset, which updates TAGE table configurations (tableSizes to 8192 and numWays to 8), aligning with the stated objective of TAGE way tuning/alignment.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tage-way-tuning-align
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@github-actions
Copy link

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.2665 -
This PR 2.2655 📉 -0.0010 (-0.05%)

✅ Difftest smoke test passed!

@XiangShanRobot
Copy link

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

Align BTB Performance

Overall Score

PR Master Diff(%)
Score 18.28 18.25 +0.13 🟢

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

Align BTB Performance

Overall Score

PR Previous Commit Diff(%)
Score 18.28 18.30 -0.10 🔴

Change-Id: I65bbdac579a8804658788c94de1a69f747ac59d2
@github-actions
Copy link

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.2665 -
This PR 2.2579 📉 -0.0086 (-0.38%)

✅ Difftest smoke test passed!

@XiangShanRobot
Copy link

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

Align BTB Performance

Overall Score

PR Master Diff(%)
Score 18.27 18.25 +0.09 🟢

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

Align BTB Performance

Overall Score

PR Previous Commit Diff(%)
Score 18.27 18.28 -0.05 🔴

Change-Id: Id2cda6131f2d6f09993aca591506c3d515b9b15e
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/BranchPredictor.py`:
- Around line 1047-1055: The change to the base params (tableSizes and numWays
in BranchPredictor.py) unintentionally increases BTBTAGE capacity; either
restore conservative defaults on the base class or isolate the larger geometry
into a dedicated subclass: if your intent is an 8-way ×8K-entry BTBTAGE, set
tableSizes = VectorParam.Unsigned([1024] * 8, ...) while keeping numWays =
VectorParam.Unsigned([8] * 8, ...); otherwise revert tableSizes and numWays in
the base BranchPredictor default to the previous smaller values (or create a new
BTBTAGE-specific subclass used by BTBTAGE(), DecoupledBPUWithBTB and
BTBTAGEUpperBound that overrides tableSizes/numWays) so the global default does
not inflate all BTB instances.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cbe60c45-94ab-46c6-8211-546c8550797c

📥 Commits

Reviewing files that changed from the base of the PR and between 8bdbac9 and c113f1c.

📒 Files selected for processing (1)
  • src/cpu/pred/BranchPredictor.py

Comment on lines +1047 to +1055
tableSizes = VectorParam.Unsigned([8192] * 8, "the TAGE T0~Tn length")
TTagBitSizes = VectorParam.Unsigned([13] * 8, "the T0~Tn entry's tag bit size")
TTagPcShifts = VectorParam.Unsigned([1] * 8, "when the T0~Tn entry's tag generating, PC right shift")
blockSize = 32 # tage index function uses 32B aligned block address

histLengths = VectorParam.Unsigned([4, 9, 17, 29, 56, 109, 211,397],"the BTB TAGE T0~Tn history length")
maxHistLen = Param.Unsigned(970, "The length of history passed from DBP")
numTablesToAlloc = Param.Unsigned(1,"The number of table to allocated each time")
numWays = VectorParam.Unsigned([2] * 8,"the T0~Tn number of ways per set")
numWays = VectorParam.Unsigned([8] * 8, "the T0~Tn number of ways per set")
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify that BTBTAGE capacity is derived as tableSizes * numWays,
# and locate the default consumers of BTBTAGE().
# Expected:
# - btb_tage.cc shows outer resize by tableSizes[i] and inner resize by way count.
# - BranchPredictor.py shows BTBTAGEUpperBound inheriting BTBTAGE and
#   DecoupledBPUWithBTB constructing BTBTAGE() directly.

rg -n -C2 'tageTable\[i\]\.resize\(tableSizes\[i\]\)|tageTable\[i\]\[j\]\.resize\(ways\)|getNumWays\(|class BTBTAGEUpperBound|Param\.BTBTAGE\(BTBTAGE\(\)' \
  src/cpu/pred/btb/btb_tage.cc src/cpu/pred/BranchPredictor.py

Repository: OpenXiangShan/GEM5

Length of output: 3100


Verify this doesn't unintentionally increase BTBTAGE capacity by 16x.

Line 1047 sets the number of indices (tableSizes: [8192] * 8), and line 1055 sets the associativity (numWays: [8] * 8). In src/cpu/pred/btb/btb_tage.cc:116-119, these are multiplied during allocation: each table now allocates 8192 × 8 = 65,536 entries instead of the previous 2048 × 2 = 4,096 entries—a 16x increase per table.

This base class change propagates to all default BTBTAGE() instantiations, including DecoupledBPUWithBTB (line 1202) and BTBTAGEUpperBound (line 1063). If the intended target is an 8-way 8K-entry configuration, reduce tableSizes to [1024] * 8. Otherwise, isolate this geometry into a dedicated subclass instead of modifying the base default.

🧰 Tools
🪛 Ruff (0.15.6)

[error] 1047-1047: VectorParam may be undefined, or defined from star imports

(F405)


[error] 1048-1048: VectorParam may be undefined, or defined from star imports

(F405)


[error] 1049-1049: VectorParam may be undefined, or defined from star imports

(F405)


[error] 1052-1052: VectorParam may be undefined, or defined from star imports

(F405)


[error] 1053-1053: Param may be undefined, or defined from star imports

(F405)


[error] 1054-1054: Param may be undefined, or defined from star imports

(F405)


[error] 1055-1055: VectorParam may be undefined, or defined from star imports

(F405)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cpu/pred/BranchPredictor.py` around lines 1047 - 1055, The change to the
base params (tableSizes and numWays in BranchPredictor.py) unintentionally
increases BTBTAGE capacity; either restore conservative defaults on the base
class or isolate the larger geometry into a dedicated subclass: if your intent
is an 8-way ×8K-entry BTBTAGE, set tableSizes = VectorParam.Unsigned([1024] * 8,
...) while keeping numWays = VectorParam.Unsigned([8] * 8, ...); otherwise
revert tableSizes and numWays in the base BranchPredictor default to the
previous smaller values (or create a new BTBTAGE-specific subclass used by
BTBTAGE(), DecoupledBPUWithBTB and BTBTAGEUpperBound that overrides
tableSizes/numWays) so the global default does not inflate all BTB instances.

@github-actions
Copy link

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.2665 -
This PR 2.2975 📈 +0.0310 (+1.37%)

✅ Difftest smoke test passed!

@XiangShanRobot
Copy link

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

Align BTB Performance

Overall Score

PR Master Diff(%)
Score 18.56 18.25 +1.68 🟢

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

Align BTB Performance

Overall Score

PR Previous Commit Diff(%)
Score 18.56 18.27 +1.59 🟢

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