Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configs/example/kmhv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def setKmhV3Params(args, system):
cpu.branchPred.mbtb.enabled = True
cpu.branchPred.tage.enabled = True
cpu.branchPred.ittage.enabled = True
cpu.branchPred.mgsc.enabled = False
cpu.branchPred.mgsc.enabled = True
cpu.branchPred.ras.enabled = True

# l1 cache per core
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/pred/BranchPredictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ class BTBMGSC(TimedBaseBTBPredictor):
thresholdTablelogSize = Param.Unsigned(6,
"Log size of update threshold counters tables")

updateThresholdWidth = Param.Unsigned(12,
updateThresholdWidth = Param.Unsigned(14,
"Number of bits for the update threshold counter")

pUpdateThresholdWidth = Param.Unsigned(8,
Expand Down
8 changes: 8 additions & 0 deletions src/cpu/pred/btb/btb_mgsc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,9 @@ BTBMGSC::generateSinglePrediction(const BTBEntry &btb_entry, const Addr &startPC
int p_update_thres = enablePCThreshold ? findThreshold(pUpdateThreshold, btb_entry.pc) : 0;

int total_thres = (updateThreshold / 8) + p_update_thres;
// Threshold is used as a confidence gate; avoid negative values which
// effectively disable the gate (abs(sum) > negative is almost always true).
total_thres = std::max(total_thres, 0);

bool use_sc_pred = forceUseSC; // Force use SC if configured
if (!use_sc_pred) {
Expand Down Expand Up @@ -656,6 +659,11 @@ void
BTBMGSC::updateGlobalThreshold(Addr pc, bool update_direction)
{
updateCounter(update_direction, updateThresholdWidth, updateThreshold);
// Keep global threshold non-negative; negative thresholds make SC gating
// degenerate and can cause overuse of SC.
if (updateThreshold < 0) {
updateThreshold = 0;
}
}

void
Expand Down