Skip to content

Sc test align#852

Open
jensen-yan wants to merge 9 commits into
xs-devfrom
sc-test-align
Open

Sc test align#852
jensen-yan wants to merge 9 commits into
xs-devfrom
sc-test-align

Conversation

@jensen-yan
Copy link
Copy Markdown
Collaborator

@jensen-yan jensen-yan commented May 7, 2026

test enable each SC table

Summary by CodeRabbit

  • New Features

    • Example configuration exposes an additional branch-predictor toggle allowing users to enable PC-threshold gating.
  • Chores

    • Made branch-prediction override gating more conservative by raising confidence thresholds; this alters when an alternative predictor can override the primary predictor, which may affect prediction behavior and performance trade-offs.

jensen-yan added 7 commits May 7, 2026 17:49
Change-Id: Ie2b38fd880551def364b0b3f0a56ba115dc14a7c
Change-Id: Ic34c0efd1c02cbb88bd4c27e248012eee11bd09d
Change-Id: I6d9d8fb3aae8aa28b4848ca6e0d62f5196e9e140
Change-Id: I2e585ec892473c4b83747f05018cf2464a0d5f52
Change-Id: Ib9c372a0183349af7d106f6f60cfaac9f02d1905
Change-Id: I060cbdf18dc7c0dbf75df01faf88538cb1be7f9c
Change-Id: I89179c4c5b1e5b7b30001d9ea535c43c84dc8eb4
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b2a75542-46b9-4ca2-8dc4-e7bd8af445ab

📥 Commits

Reviewing files that changed from the base of the PR and between 65f9222 and 847b2e4.

📒 Files selected for processing (1)
  • configs/example/kmhv3.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • configs/example/kmhv3.py

📝 Walkthrough

Walkthrough

Enables MGSC PC-threshold in KMHV3 DecoupledBPUWithBTB config and raises SC gating thresholds in BTBMGSC so SC overrides TAGE only at larger margin values; trace effective_gate recording is updated to match the new gating levels.

Changes

MGSC threshold + SC/TAGE gating

Layer / File(s) Summary
KMHV3 MGSC config
configs/example/kmhv3.py
Sets cpu.branchPred.mgsc.enablePCThreshold = True in the DecoupledBPUWithBTB branch-predictor configuration.
BTBMGSC prediction gating
src/cpu/pred/btb/btb_mgsc.cc
In generateSinglePrediction, increases the SC gating thresholds by comparing abs(total_sum) against larger total_thres-derived gates for high/mid/low confidence buckets.
BTBMGSC update trace
src/cpu/pred/btb/btb_mgsc.cc
In updateSinglePredictor, adjusts the trace effective_gate computation to use the updated high/mid/low threshold levels.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • Yakkhini
  • CJ362ff

Poem

🐰 I nudged a threshold, small and bright,
So SC waits longer in the night,
Configs flipped a single flag true,
Tracing gates to match what's new,
Hop, test, and watch the predictors chew.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title "Sc test align" is vague and non-descriptive, using generic terminology that does not clearly convey the specific changes made to the codebase. Revise the title to be more specific and descriptive, such as "Adjust MGSC confidence-gating thresholds and enable MGSC table tests" or "Update SC predictor confidence thresholds for MGSC configuration."
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.

✏️ 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 sc-test-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
Copy Markdown

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

ℹ️ 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 configs/example/kmhv3.py
Comment on lines +115 to +119
cpu.branchPred.mgsc.enableBwTable = False
cpu.branchPred.mgsc.enableLTable = False
cpu.branchPred.mgsc.enableITable = False
cpu.branchPred.mgsc.enableGTable = False
cpu.branchPred.mgsc.enablePTable = False
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 Keep SC table ablation out of default kmhv3 config

For any kmhv3.py run using the default DecoupledBPUWithBTB path, these assignments disable every MGSC component table except bias, and there is no CLI gate or later override to restore the normal predictor. The SimObject defaults keep the BW/I/G/P tables enabled, so baking a “gcc15 slice CI” ablation into the shared config silently turns normal SPEC/checkpoint experiments into a bias-only SC configuration and will skew performance results outside that one test slice.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@configs/example/kmhv3.py`:
- Around line 114-120: The MGSC table ablation lines in kmhv3.py (inside the
DecoupledBPUWithBTB block) unconditionally disable enableBwTable, enableLTable,
enableITable, enableGTable and enablePTable, which should be gated: add a
CLI/config flag (e.g., --mgsc-ablation or --mgsc-ablation-table with a table
name) that defaults to false/None and only when set overrides the
cpu.branchPred.mgsc.enable* flags to perform the ablation; leave the default
behavior as full-MGSC enabled, and wire the flag into the config loading path so
the code that sets cpu.branchPred.mgsc.enableBwTable, enableLTable,
enableITable, enableGTable, enablePTable checks the flag before forcing False
(or selectively disables only the requested table).
🪄 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: 776f3384-9532-456c-9b8b-6525412422d9

📥 Commits

Reviewing files that changed from the base of the PR and between c345ad8 and f56da4a.

📒 Files selected for processing (1)
  • configs/example/kmhv3.py

Comment thread configs/example/kmhv3.py Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.3130 -
This PR 2.2787 📉 -0.0343 (-1.48%)

✅ Difftest smoke test passed!

@XiangShanRobot
Copy link
Copy Markdown

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

Align BTB Performance

Overall Score

PR Master Diff(%)
Score 18.44 18.73 -1.57 🔴

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

Align BTB Performance

Overall Score

PR Previous Commit Diff(%)
Score 18.44 17.27 +6.77 🟢

Change-Id: Id1906f09efc28fe566bf1223a765e8b57576b917
Copy link
Copy Markdown

@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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cpu/pred/btb/btb_mgsc.cc`:
- Around line 795-797: The ternary used to compute effective_gate can fall
through to total_thres/4 when no confidence flags are set, producing a
misleading margin; change the calculation to mirror the prediction-side if/else
if structure: test pred.tage_conf_high, then else if pred.tage_conf_mid, then
else if pred.tage_conf_low, and only if none are set use a sensible default
(e.g. treat as no gate or skip logging) before computing margin =
std::abs(total_sum) - effective_gate; update the logic around effective_gate,
margin, and any code paths involving forceUseSC so margin reflects the same gate
selection rules as the predictor.
🪄 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: 7f30d5a7-27c5-428d-a72b-378bb479cf31

📥 Commits

Reviewing files that changed from the base of the PR and between f56da4a and 65f9222.

📒 Files selected for processing (2)
  • configs/example/kmhv3.py
  • src/cpu/pred/btb/btb_mgsc.cc
🚧 Files skipped from review as they are similar to previous changes (1)
  • configs/example/kmhv3.py

Comment on lines +795 to 797
auto effective_gate = pred.tage_conf_high ? total_thres
: (pred.tage_conf_mid ? (total_thres / 2) : (total_thres / 4));
auto margin = std::abs(total_sum) - effective_gate;
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 | 🟡 Minor | ⚡ Quick win

effective_gate defaults to total_thres/4 when no confidence flag is set

The ternary chain falls through to total_thres / 4 when all three conf flags (tage_conf_high, tage_conf_mid, tage_conf_low) are false — e.g. when forceUseSC = true with no conf flag asserted, or any future code path where the flags are all clear. In that state the logged margin is computed against a phantom gate value, making the trace misleading for those rows.

🐛 Proposed fix — mirror the prediction-side `if/else if` structure
-        auto effective_gate = pred.tage_conf_high ? total_thres
-            : (pred.tage_conf_mid ? (total_thres / 2) : (total_thres / 4));
+        auto effective_gate = pred.tage_conf_high   ? total_thres
+            : pred.tage_conf_mid                    ? (total_thres / 2)
+            : pred.tage_conf_low                    ? (total_thres / 4)
+            : 0;  // no confidence tier active (e.g. forceUseSC); gate is irrelevant
📝 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
auto effective_gate = pred.tage_conf_high ? total_thres
: (pred.tage_conf_mid ? (total_thres / 2) : (total_thres / 4));
auto margin = std::abs(total_sum) - effective_gate;
auto effective_gate = pred.tage_conf_high ? total_thres
: pred.tage_conf_mid ? (total_thres / 2)
: pred.tage_conf_low ? (total_thres / 4)
: 0; // no confidence tier active (e.g. forceUseSC); gate is irrelevant
auto margin = std::abs(total_sum) - effective_gate;
🤖 Prompt for 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.

In `@src/cpu/pred/btb/btb_mgsc.cc` around lines 795 - 797, The ternary used to
compute effective_gate can fall through to total_thres/4 when no confidence
flags are set, producing a misleading margin; change the calculation to mirror
the prediction-side if/else if structure: test pred.tage_conf_high, then else if
pred.tage_conf_mid, then else if pred.tage_conf_low, and only if none are set
use a sensible default (e.g. treat as no gate or skip logging) before computing
margin = std::abs(total_sum) - effective_gate; update the logic around
effective_gate, margin, and any code paths involving forceUseSC so margin
reflects the same gate selection rules as the predictor.

@XiangShanRobot
Copy link
Copy Markdown

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

Align BTB Performance

Overall Score

PR Master Diff(%)
Score 18.74 18.73 +0.04 🟢

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

Align BTB Performance

Overall Score

PR Previous Commit Diff(%)
Score 18.74 18.44 +1.64 🟢

Change-Id: Ia9832e1fd0d060625391939ef0de4ba5e54549cc
Copy link
Copy Markdown

@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: 847b2e4d5a

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

if (!use_sc_pred) {
if (tage_info.tage_pred_conf_high) {
if (abs(total_sum) > total_thres / 2) {
if (abs(total_sum) > total_thres) {
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 Update the high-confidence MGSC gate test vector

With the unchanged BTBMGSCTest.GateHighConfUsesSCWhenStrong vector, total_sum is 18 and the default total_thres is 35. After this threshold bump, high-confidence predictions require 18 > 35, so use_mgsc stays false and the prediction falls back to TAGE/not-taken instead of the test's expected SC/taken result; please update the unit test inputs/expectations along with the new gate semantics so the MGSC test suite does not fail.

Useful? React with 👍 / 👎.

@XiangShanRobot
Copy link
Copy Markdown

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

Align BTB Performance

Overall Score

PR Master Diff(%)
Score 17.94 18.73 -4.20 🔴

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

Align BTB Performance

Overall Score

PR Previous Commit Diff(%)
Score 17.94 18.74 -4.25 🔴

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