Skip to content

Commit

Permalink
pred: support DecoupledBPUWithBTB
Browse files Browse the repository at this point in the history
- Add support for DecoupledBPUWithBTB in xiangshan.py configuration
- Disable loop predictor, loop buffer, and jump ahead predictor for DecoupledBPUWithBTB
- Add enableSC parameter to BTBTAGE branch predictor
  • Loading branch information
jensen-yan committed Mar 4, 2025
1 parent 1d1c79d commit d021465
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ llvm-pgo/
*.profraw
*nemu*
ready-to-run/
*.out
*.out
.cursorrules
.cursorignore
16 changes: 13 additions & 3 deletions configs/example/xiangshan.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,25 @@ def build_test_system(np, args):
args.enable_loop_buffer = True

for i in range(np):
if args.bp_type is None or args.bp_type == 'DecoupledBPUWithFTB':
if args.bp_type is None or args.bp_type == 'DecoupledBPUWithFTB' or args.bp_type == 'DecoupledBPUWithBTB':
enable_bp_db = len(args.enable_bp_db) > 1
if enable_bp_db:
bp_db_switches = args.enable_bp_db[1] + ['basic']
print("BP db switches:", bp_db_switches)
else:
bp_db_switches = []

test_sys.cpu[i].branchPred = DecoupledBPUWithFTB(
# for DecoupledBPUWithBTB, loop predictor and jump ahead predictor are not supported
if args.bp_type == 'DecoupledBPUWithBTB':
if args.enable_loop_predictor or args.enable_loop_buffer:
print("loop predictor and loop buffer not supported for DecoupledBPUWithBTB")
args.enable_loop_predictor = False
args.enable_loop_buffer = False
if args.enable_jump_ahead_predictor:
print("jump ahead predictor not supported for DecoupledBPUWithBTB")
args.enable_jump_ahead_predictor = False

BPClass = DecoupledBPUWithBTB() if args.bp_type == 'DecoupledBPUWithBTB' else DecoupledBPUWithFTB()
test_sys.cpu[i].branchPred = BPClass(
bpDBSwitches=bp_db_switches,
enableLoopBuffer=args.enable_loop_buffer,
enableLoopPredictor=args.enable_loop_predictor,
Expand Down
1 change: 1 addition & 0 deletions src/cpu/pred/BranchPredictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,7 @@ class BTBTAGE(TimedBaseBTBPredictor):
cxx_class = 'gem5::branch_prediction::btb_pred::BTBTAGE'
cxx_header = "cpu/pred/btb/btb_tage.hh"

enableSC = Param.Bool(False, "Enable SC or not") # TODO: BTBTAGE doesn't support SC
numPredictors = Param.Unsigned(4, "Number of TAGE predictors")
tableSizes = VectorParam.Unsigned([4096]*4, "the ITTAGE T0~Tn length")
TTagBitSizes = VectorParam.Unsigned([8]*4, "the T0~Tn entry's tag bit size")
Expand Down
1 change: 1 addition & 0 deletions src/cpu/pred/btb/btb_tage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ tablePcShifts(p.TTagPcShifts),
histLengths(p.histLengths),
maxHistLen(p.maxHistLen),
numTablesToAlloc(p.numTablesToAlloc),
enableSC(p.enableSC),
tageStats(this, p.numPredictors)
{
DPRINTF(TAGE, "BTBTAGE constructor\n");
Expand Down

0 comments on commit d021465

Please sign in to comment.