Skip to content

cpu: Enable resolve update defaults#933

Open
jensen-yan wants to merge 2 commits into
xs-devfrom
codex/resolve-update-defaults
Open

cpu: Enable resolve update defaults#933
jensen-yan wants to merge 2 commits into
xs-devfrom
codex/resolve-update-defaults

Conversation

@jensen-yan

@jensen-yan jensen-yan commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Motivation

The BTB-based XiangShan configuration should use resolve-stage predictor updates by default for the main resolved-update components. kmhv3.py already forced this for MBTB, TAGE, and ITTAGE, while idealkmhv3.py still inherited the older commit-update default.

Approach

  • Set resolvedUpdate = True on MBTB, BTBTAGE, and BTBITTAGE defaults.
  • Remove the duplicate kmhv3.py resolved-update assignments.
  • Remove redundant enabled = True assignments that matched predictor defaults.

Scope

This keeps the default of other BTB components unchanged; uBTB, ABTB, and RAS still inherit the base resolvedUpdate = False default.

Validation

  • python3 -m py_compile configs/example/kmhv3.py configs/example/idealkmhv3.py src/cpu/pred/BranchPredictor.py
  • git diff --check
  • scons build/RISCV/gem5.opt --gold-linker -j64
  • ./build/RISCV/gem5.opt /tmp/check_resolve_defaults.py prints True True True False False False for MBTB/TAGE/ITTAGE/uBTB/ABTB/RAS.

Summary by CodeRabbit

  • Bug Fixes
    • Adjusted CPU fetch timing defaults, increasing the fetch delay by one cycle in the out-of-order CPU model.
    • Streamlined predictor configuration so the new timing behavior is applied consistently across example setups.
    • Updated branch predictor settings to use the newer resolved-update behavior for supported BTB variants.

Change-Id: I3318de2a96e82d52a4159b31e21d771bb2b1b1f9
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

resolvedUpdate = True is moved from per-instance config overrides into the MBTB, BTBTAGE, and BTBITTAGE class definitions. BaseO3CPU.iewToFetchDelay default increases from 1 to 2 cycles. Corresponding per-CPU assignments and the explicit sub-component enablement block are removed from kmhv3.py and idealkmhv3.py.

Changes

resolvedUpdate class defaults, iewToFetchDelay default, and config cleanup

Layer / File(s) Summary
Set resolvedUpdate=True in predictor classes
src/cpu/pred/BranchPredictor.py
MBTB, BTBTAGE, and BTBITTAGE each gain resolvedUpdate = True as a class-level parameter default.
Raise BaseO3CPU.iewToFetchDelay default to 2
src/cpu/o3/BaseO3CPU.py
iewToFetchDelay default changes from Param.Cycles(1, ...) to Param.Cycles(2, ...).
Remove redundant overrides from configs
configs/example/kmhv3.py, configs/example/idealkmhv3.py
kmhv3.py drops iewToFetchDelay=2 and the DecoupledBPUWithBTB block that set resolvedUpdate and enabled sub-components; idealkmhv3.py drops its iewToFetchDelay=2 assignment.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • OpenXiangShan/GEM5#621: Modifies the same DecoupledBPUWithBTB wiring in kmhv3.py, changing resolvedUpdate and predictor enable flags for mbtb/tage components.
  • OpenXiangShan/GEM5#630: Adds/guards resolve-stage ITTAGE training via getResolvedUpdate() and ittage.resolvedUpdate, directly related to the BTBITTAGE.resolvedUpdate = True default introduced here.
  • OpenXiangShan/GEM5#609: Simplifies the BTB predictor setup in kmhv3.py/idealkmhv3.py, overlapping with this PR's config cleanup of the same files.

Suggested labels

align-kmhv3

Suggested reviewers

  • Yakkhini
  • CJ362ff

Poem

🐇 Defaults now live where classes reside,
No more per-instance flags to override.
Two cycles for fetch, baked right in the base,
The config grows leaner, a tidier place.
Hop hop, less noise — the defaults suffice! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: enabling resolved-update defaults for CPU branch predictors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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 codex/resolve-update-defaults

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.

@jensen-yan jensen-yan marked this pull request as ready for review June 30, 2026 08:05
Copilot AI review requested due to automatic review settings June 30, 2026 08:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates XiangShan’s BTB-based branch predictor defaults so key BTB components (MBTB/TAGE/ITTAGE) use resolve-stage (resolved) updates by default, and simplifies the XiangShan kmhv3.py configuration by removing now-redundant overrides.

Changes:

  • Set resolvedUpdate = True as the default for MBTB, BTBTAGE, and BTBITTAGE (inheriting from TimedBaseBTBPredictor.resolvedUpdate = False).
  • Remove kmhv3.py’s redundant per-instance resolvedUpdate assignments for MBTB/TAGE/ITTAGE now that the defaults are updated.
  • Remove redundant enabled = True assignments in kmhv3.py (the base predictor component default is already enabled = True).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/cpu/pred/BranchPredictor.py Changes default resolvedUpdate behavior for MBTB/BTBTAGE/BTBITTAGE to resolve-stage updates.
configs/example/kmhv3.py Removes redundant resolved-update and enabled overrides now covered by predictor defaults.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@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: 24213d67dd

ℹ️ 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/BranchPredictor.py
@github-actions

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

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

✅ Difftest smoke test passed!

Change-Id: Id2fb11d63a7ba4cfcbb91a25b281bc8fcdbb1f4c

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cpu/o3/BaseO3CPU.py`:
- Around line 123-124: The timing change is currently applied at the BaseO3CPU
default, which affects every O3 CPU inheriting from BaseO3CPU through Fetch’s
use of params.iewToFetchDelay and getWire(-iewToFetchDelay). Keep the shared
BaseO3CPU default unchanged, and move the iewToFetchDelay override into the
XiangShan-specific CPU/config class or equivalent override point used by
kmhv3/idealkmhv3 so only those targets get the 2-cycle delay.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2bd45980-657b-4b06-93d5-5e1b6f7e1ca2

📥 Commits

Reviewing files that changed from the base of the PR and between 24213d6 and f2fc196.

📒 Files selected for processing (3)
  • configs/example/idealkmhv3.py
  • configs/example/kmhv3.py
  • src/cpu/o3/BaseO3CPU.py
💤 Files with no reviewable changes (2)
  • configs/example/idealkmhv3.py
  • configs/example/kmhv3.py

Comment thread src/cpu/o3/BaseO3CPU.py

@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: f2fc1966eb

ℹ️ 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".

cxx_class = 'gem5::branch_prediction::btb_pred::MBTB'
cxx_header = 'cpu/pred/btb/mbtb.hh'

resolvedUpdate = True

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Guard resolved updates for SMT runs

When running the SMT path (checked configs/example/smt_idealkmhv3.py, which sets args.smt = True with DecoupledBPUWithBTB), IEW::executeInsts only clears toFetch->iewInfo[tid].resolvedCFIs for *activeThreads->begin(), and repo-wide search shows no other clear. Enabling resolved updates by default makes stale resolved-CFI entries from non-first threads retrain MBTB/TAGE/ITTAGE every cycle after they first execute a branch, corrupting SMT predictor state instead of being a harmless no-op as before.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

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

✅ Difftest smoke test passed!

@jensen-yan

jensen-yan commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

用CI 触发了ideal 版本的0.8c 性能测试,发现相对主线降低了0.2分,参考 本commit https://github.com/OpenXiangShan/GEM5/actions/runs/28429735723 vs 主线https://github.com/OpenXiangShan/GEM5/actions/runs/28369635805

@Yakkhini

Yakkhini commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Maybe this PR can be rebased and re-evaluate after PR #934 merged, since the delay strongly affect the resolve training performance.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants