Skip to content

Commit def3dcd

Browse files
author
Cao Jiaming
committed
cpu-o3: add support for choice MBTB basetable in branch predict
Change-Id: Iebed52eb9e3a60ac5ef3bbc0e96095d2d16ef0fa
1 parent 043f6d7 commit def3dcd

File tree

6 files changed

+25
-11
lines changed

6 files changed

+25
-11
lines changed

configs/example/kmhv3.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ def setKmhV3Params(args, system):
108108
cpu.branchPred.mgsc.enabled = False
109109
cpu.branchPred.ras.enabled = True
110110

111+
usingMbtbBaseEiterTage = True
112+
cpu.branchPred.mbtb.usingMbtbBaseEiterTage = usingMbtbBaseEiterTage
113+
cpu.branchPred.tage.usingMbtbBaseEiterTage = usingMbtbBaseEiterTage
114+
111115
# l1 cache per core
112116
if args.caches:
113117
cpu.icache.size = '64kB'

src/cpu/pred/BranchPredictor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,7 @@ class MBTB(TimedBaseBTBPredictor):
985985
blockSize = 32 # max 64 byte block, 32 byte aligned
986986
# MBTB is always half-aligned - no parameter needed
987987
victimCacheSize = Param.Unsigned(0, "Number of entries in the victim cache")
988+
usingMbtbBaseEiterTage = Param.Bool(True, "Whether using MBTB basetable either TAGE ")
988989

989990
class AheadBTB(TimedBaseBTBPredictor):
990991
type = 'AheadBTB'
@@ -1060,6 +1061,7 @@ class BTBTAGE(TimedBaseBTBPredictor):
10601061
numBanks = Param.Unsigned(4, "Number of banks for bank conflict simulation")
10611062
enableBankConflict = Param.Bool(True, "Enable bank conflict simulation")
10621063
numDelay = 2
1064+
usingMbtbBaseEiterTage = Param.Bool(True, "Whether using MBTB basetable either TAGE ")
10631065

10641066
class MicroTAGE(BTBTAGE):
10651067
"""A smaller TAGE predictor configuration to assist uBTB"""

src/cpu/pred/btb/btb_tage.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ indexShift(bankBaseShift + ceilLog2(p.numBanks)),
9191
enableBankConflict(p.enableBankConflict),
9292
lastPredBankId(0),
9393
predBankValid(false),
94+
usingBasetable( !p.usingMbtbBaseEiterTage),
9495
tageStats(this, p.numPredictors, p.numBanks)
9596
{
9697
this->needMoreHistories = p.needMoreHistories;
@@ -269,8 +270,9 @@ BTBTAGE::generateSinglePrediction(const BTBEntry &btb_entry,
269270
// Use base table instead of btb_entry.ctr
270271
Addr base_idx = getBaseTableIndex(startPC);
271272
unsigned branch_idx = getBranchIndexInBlock(btb_entry.pc, startPC);
272-
//bool base_taken = getDelay() != 0 ? baseTable[base_idx][branch_idx] >= 0 : btb_entry.ctr >= 0;
273-
bool base_taken = btb_entry.ctr >= 0;
273+
bool base_taken = getDelay() != 0 ? (usingBasetable ? baseTable[base_idx][branch_idx] >= 0 : btb_entry.ctr >= 0)
274+
: btb_entry.ctr >= 0;
275+
//bool base_taken = btb_entry.ctr >= 0;
274276
bool alt_pred = alt_provided ? alt_taken : base_taken; // if alt provided, use alt prediction, otherwise use base
275277

276278
// use_alt_on_na gating: when provider weak, consult per-PC counter

src/cpu/pred/btb/btb_tage.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ class BTBTAGE : public TimedBaseBTBPredictor
315315
// Track last prediction bank for conflict detection
316316
unsigned lastPredBankId; // Bank ID of last prediction
317317
bool predBankValid; // Whether lastPredBankId is valid
318+
bool usingBasetable; // Whether using basetable for either MBTB or TAGE
318319

319320
#ifdef UNIT_TEST
320321
typedef uint64_t Scalar;

src/cpu/pred/btb/mbtb.cc

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ MBTB::MBTB(const Params &p)
8181
numEntries(p.numEntries),
8282
numWays(p.numWays),
8383
tagBits(p.tagBits),
84+
usingBasetable(p.usingMbtbBaseEiterTage),
8485
btbStats(this, p.numWays)
8586
{
8687
// MBTB doesn't support ahead-pipelined stages
@@ -696,16 +697,19 @@ MBTB::update(const FetchStream &stream)
696697
// 1. Check prediction hit status, for stats recording
697698
checkPredictionHit(stream,
698699
std::static_pointer_cast<BTBMeta>(stream.predMetas[getComponentIdx()]).get());
699-
700-
// only update btb entry for control squash T-> NT or NT -> T
701-
// if (stream.squashType == SQUASH_CTRL) {
702-
// warn_if(stream.exeBranchInfo.pc > stream.updateEndInstPC, "exeBranchInfo.pc > updateEndInstPC");
703-
// updateBTBEntry(stream.exeBranchInfo, stream);
704-
// }
705-
auto entries_need_update = prepareUpdateEntries(stream);
706-
for (auto &entry : entries_need_update) {
707-
updateBTBEntry(entry, stream);
700+
if (!usingBasetable) {
701+
// only update btb entry for control squash T-> NT or NT -> T
702+
if (stream.squashType == SQUASH_CTRL) {
703+
warn_if(stream.exeBranchInfo.pc > stream.updateEndInstPC, "exeBranchInfo.pc > updateEndInstPC");
704+
updateBTBEntry(stream.exeBranchInfo, stream);
705+
}
706+
}else {
707+
auto entries_need_update = prepareUpdateEntries(stream);
708+
for (auto &entry : entries_need_update) {
709+
updateBTBEntry(entry, stream);
710+
}
708711
}
712+
709713
}
710714

711715

src/cpu/pred/btb/mbtb.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ class MBTB : public TimedBaseBTBPredictor
395395
/** Address calculation masks and shifts */
396396
Addr idxMask; // Mask for extracting index bits
397397
unsigned tagBits; // Number of tag bits
398+
bool usingBasetable; // Whether using basetable for either MBTB or TAGE
398399
Addr tagMask; // Mask for extracting tag bits
399400
unsigned idxShiftAmt; // Amount to shift PC for index
400401
unsigned tagShiftAmt; // Amount to shift PC for tag

0 commit comments

Comments
 (0)