Skip to content

Pair tage 2 taken - #830

Merged
jensen-yan merged 56 commits into
xs-devfrom
pair-tage-2-taken
Aug 20, 2026
Merged

Pair tage 2 taken#830
jensen-yan merged 56 commits into
xs-devfrom
pair-tage-2-taken

Conversation

@Yakkhini

@Yakkhini Yakkhini commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added PairTAGE two-block branch predictor with configurable phase/second-block behavior and optional integration into the decoupled BPU.
    • Added side-effect-free BTB lookup paths to support safe, non-mutating prediction queries.
  • Improvements

    • Added prediction-metadata refresh hooks across BTB/TAGE predictors and extended fetch-target metadata for pair-aware predictions.
    • Improved const-correctness and expanded statistics for pair/second-block workflows.

@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a new two-block PairTAGE BTB/TAGE predictor and integrates it into DecoupledBPUWithBTB; introduces TimedBaseBTBPredictor::refreshPredictionMeta, side-effect-free BTB lookup APIs and const-correct helpers across BTB predictors, extends FetchTarget with PairTAGE fields, and adds FTQ const accessors.

Changes

Cohort / File(s) Summary
PairTAGE implementation
src/cpu/pred/btb/pairtage.hh, src/cpu/pred/btb/pairtage.cc
New TimedBaseBTBPredictor subclass implementing two-block entries, folded-history meta (TageMeta), phase gating, first/second-block prediction assembly, refreshPredictionMeta, training/update, allocation, history recoveries, and statistics.
Predictor wiring & build
src/cpu/pred/BranchPredictor.py, src/cpu/pred/SConscript
Adds PairTAGE SimObject/Params and exposes DecoupledBPUWithBTB.pairtage; registers pairtage source file in build.
Decoupled BPU integration & stats
src/cpu/pred/btb/decoupled_bpred.cc, src/cpu/pred/btb/decoupled_bpred.hh, src/cpu/pred/btb/decoupled_bpred_stats.cc
Integrates PairTAGE into tick/enqueue/squash flows, per-thread pairPhase/state, createFetchTarget overloads, second-block teacher/student flow, history update API changes, and extensive PairTAGE-specific stats.
No-side-effect lookup & meta refresh (BTB family)
src/cpu/pred/btb/abtb.{cc,hh}, mbtb.{cc,hh}, btb_tage.{cc,hh}, btb_ittage.{cc,hh}, btb_mgsc.{cc,hh}, btb_ubtb.{cc,hh}, microtage.{cc,hh}, ras.{cc,hh}
Adds const lookupNoSideEffect/processEntriesNoSideEffect variants and refreshPredictionMeta implementations to recompute FullBTBPrediction metadata without mutating predictor state or stats; tightens const-correctness of many helper methods.
Common BTB types & FetchTarget
src/cpu/pred/btb/common.hh
Adds PairPhase enum; expands FetchTarget with pairPhase, pairtageUsed, pairtageSecondBlock; increases predMetas capacity (8→12); initializes FullBTBPrediction defaults.
Timed base predictor hook
src/cpu/pred/btb/timed_base_pred.hh
Adds virtual refreshPredictionMeta(Addr, const boost::dynamic_bitset<>&, FullBTBPrediction&) hook (default no-op).
FTQ const accessors
src/cpu/pred/btb/ftq.hh
Adds const overloads for front, back, and get to return const FetchTarget&.

Sequence Diagram(s)

sequenceDiagram
    participant Fetch as Fetch Unit
    participant DBPU as DecoupledBPUWithBTB
    participant PT as PairTAGE
    participant FTQ as FetchTargetQueue
    participant Hist as History Tracker

    Fetch->>DBPU: request prediction(startPC, history)
    DBPU->>PT: putPCHistory(startPC, history)
    PT->>PT: TAGE lookup -> build first-block FullBTBPrediction
    PT-->>DBPU: first-block FullBTBPrediction (pairtageUsed, pairPhase)
    DBPU->>FTQ: enqueue first FetchTarget (pairPhase)

    alt PairTAGE enabled && phase allowed && second-block candidate
        DBPU->>PT: refreshPredictionMeta(secondStartPC, history, pred)
        PT->>PT: lookupNoSideEffect -> second-block prediction/meta
        PT-->>DBPU: second-block info (pairtageSecondBlock)
        DBPU->>FTQ: conditionally enqueue second FetchTarget
    end

    Note over DBPU,PT: On resolution
    DBPU->>PT: trainFromActualPred(firstFetchTarget, optionalSecondPred)
    PT->>Hist: specUpdateHist / recoverHist / doUpdateHist
Loading
sequenceDiagram
    participant Caller as DecoupledBPU
    participant Predictor as BTB Predictor
    participant NoSE as NoSideEffect Lookup
    participant Meta as FullBTBPrediction

    Caller->>Predictor: refreshPredictionMeta(startAddr, history, pred)
    Predictor->>NoSE: lookupNoSideEffect(...) / processEntriesNoSideEffect(...)
    NoSE->>NoSE: tag match, select entries (no MRU/LRU/stats changes)
    NoSE-->>Meta: populate hit_entries / per-PC preds
    Meta-->>Caller: refreshed prediction metadata snapshot
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~70 minutes

Possibly related PRs

Suggested reviewers

  • jensen-yan
  • CJ362ff

"🐇
I hop on tags both even and odd,
Two blocks foretold, each stitch a nod.
I peek without a single side effect,
I learn when true and gently correct.
A rabbit's hop: predict, teach, connect."

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.39% 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 'Pair tage 2 taken' is vague and does not clearly convey the main change. It appears to reference PairTAGE but lacks specificity about what 'taken' means in this context, making it unclear to reviewers scanning commit history. Consider a more descriptive title that clearly indicates the main functionality being added or modified, such as 'Add PairTAGE predictor with two-block prediction' or 'Implement PairTAGE for dual-block branch prediction.'
✅ 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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pair-tage-2-taken

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.

@github-actions

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

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

✅ Difftest smoke test passed!

1 similar comment
@github-actions

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

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

✅ Difftest smoke test passed!

@Yakkhini Yakkhini added the perf label Apr 16, 2026
@github-actions

Copy link
Copy Markdown

🚀 Performance test triggered: gcc15-spec06-0.8c

@Yakkhini Yakkhini added perf and removed perf labels Apr 16, 2026
@github-actions

Copy link
Copy Markdown

🚀 Performance test triggered: gcc15-spec06-0.8c

@Yakkhini Yakkhini added perf and removed perf labels Apr 16, 2026
@github-actions

Copy link
Copy Markdown

🚀 Performance test triggered: gcc15-spec06-0.8c

@github-actions

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.3051 -
This PR 1.9659 📉 -0.3392 (-14.72%)

✅ Difftest smoke test passed!

@Yakkhini
Yakkhini force-pushed the pair-tage-2-taken branch from 105484a to becfce1 Compare April 21, 2026 08:24
@github-actions

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

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

✅ Difftest smoke test passed!

@Yakkhini
Yakkhini force-pushed the pair-tage-2-taken branch from 6b5465f to 59f9782 Compare April 22, 2026 14:29
@github-actions

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.3051 -
This PR 2.1343 📉 -0.1708 (-7.41%)

✅ Difftest smoke test passed!

@Yakkhini Yakkhini added perf and removed perf labels Apr 22, 2026
@github-actions

Copy link
Copy Markdown

🚀 Performance test triggered: gcc15-spec06-0.8c

@github-actions

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.3051 -
This PR 2.2801 📉 -0.0250 (-1.08%)

✅ Difftest smoke test passed!

@Yakkhini Yakkhini added perf and removed perf labels Apr 22, 2026
@github-actions

Copy link
Copy Markdown

🚀 Performance test triggered: gcc15-spec06-0.8c

@github-actions

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.3051 -
This PR 2.2875 📉 -0.0176 (-0.76%)

✅ Difftest smoke test passed!

@Yakkhini
Yakkhini marked this pull request as ready for review April 23, 2026 04:30
@Yakkhini Yakkhini added perf and removed perf labels Apr 23, 2026
@github-actions

Copy link
Copy Markdown

🚀 Performance test triggered: gcc15-spec06-0.8c

Change-Id: Ib4664b24db5194f524d7d5beb09f8749b4e6a9a6
Change-Id: I6d36ab621c338750f4a7ebd15ba0d5341e31c355
Change-Id: I736a2eba11bf8e5e297b572fb47335152eb50729
Change-Id: I7f9602e61370c328fc00e9f3f28ca2b7c9f718bb
Change-Id: I3fbbe413f46435d72dae908c6832089838669cd2
Change-Id: I20e915941b2765d3c6d5bff2a0fd7da6ff5d63e7
Change-Id: I75ff694758168a14fbb867a8028a8e965660f58f
The unit test and performance counters will be re-designed later.

Change-Id: I129546906625411e7809085c440f7cbdb068aaad
Change-Id: Id554b8a3cfd9b0caa3b49d2345d458b24f8256a1
Remove dead pending second-block state, FetchTarget flags, duplicated PairTAGE metadata, no-op overrides, and unconsumed SimObject parameters.

Keep prediction, training, history recovery, and two-fetch behavior unchanged.

Test: scons build/RISCV/cpu/pred/btb/pairtage.o build/RISCV/cpu/pred/btb/decoupled_bpred.o build/RISCV/cpu/pred/btb/decoupled_bpred_stats.o -j64
Change-Id: I3f9efac3b170c63c9a86c4582ab9d1e1ea3320f0
Change-Id: I1d21a5b0d33fe7093b76d583d009ee4aabc6659e
Change-Id: I11730f645be338857e4d7b4aad9c31c205b59b3c
Change-Id: I1893c94e21729ca439a8a5007c252d0651bef7d5
Change-Id: I6c254a4c833acfea6ff3cc27ad11caa547a607ad
Change-Id: I62220194453b37e03767d99b7a60bf1eec56d02e
Change-Id: I0e250fb514463aa4efe41a41b98cb9b329758215
Change-Id: I8b9082e9f4d08bb79ce64894938908ffe6894af2
Change-Id: I3f6a4a10fba0839155e57ea0bc412c221d0e598d
Change-Id: I1fc0a8312f9e94d0c830139d41e4e537bdbfabeb
Change-Id: Ib6f8cf7c0acef0f7e3e7a5cffd8f565b2421170d
Change-Id: I81370bf4d9c16e652e0f4941ecd064b87a7cf11b
Change-Id: I7a970014cfdedefccc33fe4bde5a03c36da51459
Change-Id: Ibf1db7c1ec941eb633414feb91b552b084b14cff
RTL has a implemented 2 Fetch that only allow double fetch block in 64B.
GEM5 will follow them later.

Change-Id: Ic99921357c1da94809f3c00aa31a3832be1a9486
Change-Id: I9a35615c551f07e122f0b7f39befd01b3a18abd7
@github-actions

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

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

✅ Difftest smoke test passed!

@Yakkhini

Yakkhini commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

No performance change in Aligned Evaluation (20.88 score per GHz) and SMT Evaluation (26.11 score per GHz) with commit 541137b as baseline.

Change-Id: I1a04002d2cc77c621a8275b4cd74affc96b6b74f
@github-actions

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

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

✅ Difftest smoke test passed!

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