Timing optimisation for Tournament Predictor.
Start global-history-indexed lookups in the previous cycle. This is a general timing optimisation that should be pushed upstream at some point.
This commit is contained in:
@@ -131,7 +131,10 @@ module mkBtbCore(NextAddrPred#(hashSz))
|
||||
// Start SupSizeX2 BTB lookups, but ensure to lookup in the appropriate
|
||||
// bank for the alignment of each potential branch.
|
||||
for (Integer i = 0; i < valueOf(SupSizeX2); i = i + 1) begin
|
||||
BtbAddr a = unpack(pack(getBtbAddr(pc)) + fromInteger(i));
|
||||
// Only add lower bits for timing.
|
||||
BtbAddr a = getBtbAddr(pc);
|
||||
a = unpack({a.tag, {a.index,a.bank} + fromInteger(i)});
|
||||
//BtbAddr a = unpack(pack(getBtbAddr(pc)) + fromInteger(i));
|
||||
fullRecords[a.bank].lookupStart(MapKeyIndex{key: hash(a.tag), index: a.index});
|
||||
compressedRecords[a.bank].lookupStart(MapKeyIndex{key: hash(a.tag), index: a.index});
|
||||
end
|
||||
|
||||
@@ -114,6 +114,8 @@ module mkTourPred(DirPredictor#(TourTrainInfo));
|
||||
endfunction
|
||||
|
||||
TourGlobalHist curGHist = gHistReg.history; // global history: MSB is the latest branch
|
||||
Reg#(Vector#(SupSize, Bool)) globalTakenVec <- mkRegU;
|
||||
Reg#(Vector#(SupSize, Bool)) useLocalVec <- mkRegU;
|
||||
|
||||
Vector#(SupSize, DirPred#(TourTrainInfo)) predIfc;
|
||||
for(Integer i = 0; i < valueof(SupSize); i = i+1) begin
|
||||
@@ -127,12 +129,11 @@ module mkTourPred(DirPredictor#(TourTrainInfo));
|
||||
// all previous branch in this cycle must be not taken
|
||||
// otherwise this branch should be on wrong path
|
||||
// because all inst in same cycle are fetched consecutively
|
||||
TourGlobalHist globalHist = curGHist >> predCnt[i];
|
||||
// get global prediction
|
||||
Bool globalTaken = isTaken(globalBht.sub(globalHist));
|
||||
Bool globalTaken = globalTakenVec[predCnt[i]];
|
||||
|
||||
// make choice
|
||||
Bool useLocal = isTaken(choiceBht.sub(globalHist));
|
||||
Bool useLocal = useLocalVec[predCnt[i]];
|
||||
Bool taken = useLocal ? localTaken : globalTaken;
|
||||
|
||||
// record prediction
|
||||
@@ -145,7 +146,7 @@ module mkTourPred(DirPredictor#(TourTrainInfo));
|
||||
return DirPredResult {
|
||||
taken: taken,
|
||||
train: TourTrainInfo {
|
||||
globalHist: globalHist,
|
||||
globalHist: curGHist >> predCnt[i],
|
||||
localHist: localHist,
|
||||
globalTaken: globalTaken,
|
||||
localTaken: localTaken
|
||||
@@ -158,6 +159,14 @@ module mkTourPred(DirPredictor#(TourTrainInfo));
|
||||
(* fire_when_enabled, no_implicit_conditions *)
|
||||
rule canonGlobalHist;
|
||||
gHistReg.addHistory(predRes[valueof(SupSize)], predCnt[valueof(SupSize)]);
|
||||
// Buffer useLocalVec
|
||||
// Reproduce next history; this would ideally be done in GlobalBrHistReg to avoid duplicating logic.
|
||||
TourGlobalHist nHist = truncate({predRes[valueof(SupSize)], curGHist} >> predCnt[valueof(SupSize)]);
|
||||
function Bool globalTakenLookup (Integer i) = isTaken(globalBht.sub(nHist >> i));
|
||||
function Bool useLocalLookup (Integer i) = isTaken(choiceBht.sub(nHist >> i));
|
||||
globalTakenVec <= genWith(globalTakenLookup);
|
||||
useLocalVec <= genWith(useLocalLookup);
|
||||
// Reset counters and prediction.
|
||||
predRes[valueof(SupSize)] <= 0;
|
||||
predCnt[valueof(SupSize)] <= 0;
|
||||
endrule
|
||||
|
||||
Reference in New Issue
Block a user