cpu-o3: add fine-grained branch type stats to BPU#620
Conversation
Implement fine-grained RISC-V branch classification stats in the decoupled BPU so we can track per-class resolve squashes and commit mispredictions (e.g., cond, direct/indirect call, return, direct/indirect jump) via DBPBTBStats. Change-Id: Ie0b99fa76844505dc8688b99b5760fa48a15d8c9
WalkthroughIntroduces branch classification capabilities to DecoupledBPUWithBTB, adding a BranchClass enum with eight classification types and per-class statistics collection infrastructure. Instruments commit and squash paths to track branch-specific metrics including counts, misses, and control squashes. Changes
Sequence DiagramsequenceDiagram
participant Commit as Commit Path
participant Classify as Branch Classification
participant Stats as Per-Class Stats
participant Squash as Squash Path
Commit->>Classify: classifyBranch(DynInstPtr)
Classify-->>Commit: BranchClass
Commit->>Stats: addBranchClassStat(class, mispred)
Stats->>Stats: Update branchClassCounts,<br/>branchClassMisses
Squash->>Classify: classifyBranch(DynInstPtr)
Classify-->>Squash: BranchClass
Squash->>Stats: addControlSquashCommitStat(class)
Stats->>Stats: Update controlSquashByClass
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/cpu/pred/btb/decoupled_bpred.cc(7 hunks)src/cpu/pred/btb/decoupled_bpred.hh(4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/cpu/pred/btb/decoupled_bpred.cc (1)
src/cpu/pred/btb/decoupled_bpred.hh (3)
cls(884-884)cls(885-885)cls(886-886)
⏰ 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). (1)
- GitHub Check: Quick Build, Unit Tests & Smoke Test
🔇 Additional comments (10)
src/cpu/pred/btb/decoupled_bpred.hh (3)
838-854: Well-structured branch classification enum.The enum design is clean with a
NumClassessentinel for sizing stat containers. Theuint8_tunderlying type is appropriate for the small number of values.
313-316: Statistics vector declarations look correct.The per-class statistics vectors align with the classification framework and will provide granular misprediction tracking.
882-886: Good API surface for branch classification.The method signatures provide a complete interface: classification from both
DynInstPtrandStaticInstPtr, name lookup, and stat accumulation helpers.src/cpu/pred/btb/decoupled_bpred.cc (7)
496-528: Classification logic is well-ordered.The priority order (Return → Call → CondCtrl → IndirectCtrl → DirectCtrl) correctly handles the RISC-V control flow taxonomy. Returns are checked first since they're technically indirect, and conditional branches take precedence over indirect jumps.
1025-1031: Clean integration of per-class squash tracking.The classification and stat update are correctly scoped to commit-path squashes only (
fromCommit == true).
1418-1428: Clean delegation to template implementation.The two overloads correctly delegate to the common template, avoiding code duplication.
1430-1438: Bounds check present but incomplete for current array state.The bounds check
idx < BranchClassLabels.size()passes foridx = 7, butBranchClassLabels[7]is currentlynullptr. After fixing the array initialization (adding the 8th element), this function will work correctly.
1440-1457: Proper bounds checking before stat updates.The guard
idx >= NumBranchClassesprevents out-of-bounds access to the statistics vectors. The debug logging provides useful traceability.
1459-1473: Consistent pattern with addBranchClassStat.Follows the same defensive bounds-checking pattern. Good consistency.
1491-1492: Fine-grained classification complements existing CFI tracking.The new per-class stats augment the existing coarse
addCfi()tracking (COND/UNCOND/RETURN/OTHER) with more specific categories.
🚀 Coremark Smoke Test Results
✅ Difftest smoke test passed! |
Implement fine-grained RISC-V branch classification stats in the decoupled BPU so we can track per-class resolve squashes and commit mispredictions (e.g., cond, direct/indirect call, return, direct/indirect jump) via DBPBTBStats.
Change-Id: Ie0b99fa76844505dc8688b99b5760fa48a15d8c9
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.