ltage.cc (13413:b84a7c832ead) ltage.cc (13420:5cb2b90e1cb5)
1/*
2 * Copyright (c) 2014 The University of Wisconsin
3 *
4 * Copyright (c) 2006 INRIA (Institut National de Recherche en
5 * Informatique et en Automatique / French National Research Institute
6 * for Computer Science and Applied Mathematics)
7 *
8 * All rights reserved.

--- 36 unchanged lines hidden (view full) ---

45#include "base/random.hh"
46#include "base/trace.hh"
47#include "debug/Fetch.hh"
48#include "debug/LTage.hh"
49
50LTAGE::LTAGE(const LTAGEParams *params)
51 : BPredUnit(params),
52 logSizeBiMP(params->logSizeBiMP),
1/*
2 * Copyright (c) 2014 The University of Wisconsin
3 *
4 * Copyright (c) 2006 INRIA (Institut National de Recherche en
5 * Informatique et en Automatique / French National Research Institute
6 * for Computer Science and Applied Mathematics)
7 *
8 * All rights reserved.

--- 36 unchanged lines hidden (view full) ---

45#include "base/random.hh"
46#include "base/trace.hh"
47#include "debug/Fetch.hh"
48#include "debug/LTage.hh"
49
50LTAGE::LTAGE(const LTAGEParams *params)
51 : BPredUnit(params),
52 logSizeBiMP(params->logSizeBiMP),
53 logRatioBiModalHystEntries(params->logRatioBiModalHystEntries),
53 logSizeTagTables(params->logSizeTagTables),
54 logSizeLoopPred(params->logSizeLoopPred),
55 nHistoryTables(params->nHistoryTables),
56 tagTableCounterBits(params->tagTableCounterBits),
57 histBufferSize(params->histBufferSize),
58 minHist(params->minHist),
59 maxHist(params->maxHist),
60 minTagWidth(params->minTagWidth),

--- 56 unchanged lines hidden (view full) ---

117 history.computeIndices[i].origLength, tagWidths[i]);
118 history.computeTags[1][i].init(
119 history.computeIndices[i].origLength, tagWidths[i] - 1);
120 DPRINTF(LTage, "HistLength:%d, TTSize:%d, TTTWidth:%d\n",
121 histLengths[i], tagTableSizes[i], tagWidths[i]);
122 }
123 }
124
54 logSizeTagTables(params->logSizeTagTables),
55 logSizeLoopPred(params->logSizeLoopPred),
56 nHistoryTables(params->nHistoryTables),
57 tagTableCounterBits(params->tagTableCounterBits),
58 histBufferSize(params->histBufferSize),
59 minHist(params->minHist),
60 maxHist(params->maxHist),
61 minTagWidth(params->minTagWidth),

--- 56 unchanged lines hidden (view full) ---

118 history.computeIndices[i].origLength, tagWidths[i]);
119 history.computeTags[1][i].init(
120 history.computeIndices[i].origLength, tagWidths[i] - 1);
121 DPRINTF(LTage, "HistLength:%d, TTSize:%d, TTTWidth:%d\n",
122 histLengths[i], tagTableSizes[i], tagWidths[i]);
123 }
124 }
125
125 btable = new BimodalEntry[ULL(1) << logSizeBiMP];
126 const uint64_t bimodalTableSize = ULL(1) << logSizeBiMP;
127 btablePrediction.resize(bimodalTableSize, false);
128 btableHysteresis.resize(bimodalTableSize >> logRatioBiModalHystEntries,
129 true);
130
126 ltable = new LoopEntry[ULL(1) << logSizeLoopPred];
127 gtable = new TageEntry*[nHistoryTables + 1];
128 for (int i = 1; i <= nHistoryTables; i++) {
129 gtable[i] = new TageEntry[1<<(tagTableSizes[i])];
130 }
131
132 tableIndices = new int [nHistoryTables+1];
133 tableTags = new int [nHistoryTables+1];

--- 72 unchanged lines hidden (view full) ---

206 ctr--;
207 }
208}
209
210// Bimodal prediction
211bool
212LTAGE::getBimodePred(Addr pc, BranchInfo* bi) const
213{
131 ltable = new LoopEntry[ULL(1) << logSizeLoopPred];
132 gtable = new TageEntry*[nHistoryTables + 1];
133 for (int i = 1; i <= nHistoryTables; i++) {
134 gtable[i] = new TageEntry[1<<(tagTableSizes[i])];
135 }
136
137 tableIndices = new int [nHistoryTables+1];
138 tableTags = new int [nHistoryTables+1];

--- 72 unchanged lines hidden (view full) ---

211 ctr--;
212 }
213}
214
215// Bimodal prediction
216bool
217LTAGE::getBimodePred(Addr pc, BranchInfo* bi) const
218{
214 return (btable[bi->bimodalIndex].pred > 0);
219 return btablePrediction[bi->bimodalIndex];
215}
216
217
220}
221
222
218// Update the bimodal predictor: a hysteresis bit is shared among 4 prediction
219// bits
223// Update the bimodal predictor: a hysteresis bit is shared among N prediction
224// bits (N = 2 ^ logRatioBiModalHystEntries)
220void
221LTAGE::baseUpdate(Addr pc, bool taken, BranchInfo* bi)
222{
225void
226LTAGE::baseUpdate(Addr pc, bool taken, BranchInfo* bi)
227{
223 int inter = (btable[bi->bimodalIndex].pred << 1)
224 + btable[bi->bimodalIndex ].hyst;
228 int inter = (btablePrediction[bi->bimodalIndex] << 1)
229 + btableHysteresis[bi->bimodalIndex >> logRatioBiModalHystEntries];
225 if (taken) {
226 if (inter < 3)
227 inter++;
228 } else if (inter > 0) {
229 inter--;
230 }
230 if (taken) {
231 if (inter < 3)
232 inter++;
233 } else if (inter > 0) {
234 inter--;
235 }
231 btable[bi->bimodalIndex].pred = inter >> 1;
232 btable[bi->bimodalIndex].hyst = (inter & 1);
233 DPRINTF(LTage, "Updating branch %lx, pred:%d, hyst:%d\n",
234 pc, btable[bi->bimodalIndex].pred,btable[bi->bimodalIndex].hyst);
236 const bool pred = inter >> 1;
237 const bool hyst = inter & 1;
238 btablePrediction[bi->bimodalIndex] = pred;
239 btableHysteresis[bi->bimodalIndex >> logRatioBiModalHystEntries] = hyst;
240 DPRINTF(LTage, "Updating branch %lx, pred:%d, hyst:%d\n", pc, pred, hyst);
235}
236
237
238//loop prediction: only used if high confidence
239bool
240LTAGE::getLoop(Addr pc, BranchInfo* bi) const
241{
242 bi->loopHit = -1;

--- 507 unchanged lines hidden ---
241}
242
243
244//loop prediction: only used if high confidence
245bool
246LTAGE::getLoop(Addr pc, BranchInfo* bi) const
247{
248 bi->loopHit = -1;

--- 507 unchanged lines hidden ---