Go to the documentation of this file.
44 #include "params/StatisticalCorrector.hh"
47 const StatisticalCorrectorParams *
p)
50 logSizeUp(
p->logSizeUp),
51 logSizeUps(logSizeUp / 2),
52 numEntriesFirstLocalHistories(
p->numEntriesFirstLocalHistories),
62 chooserConfWidth(
p->chooserConfWidth),
63 updateThresholdWidth(
p->updateThresholdWidth),
64 pUpdateThresholdWidth(
p->pUpdateThresholdWidth),
65 extraWeightsWidth(
p->extraWeightsWidth),
66 scCountersWidth(
p->scCountersWidth),
132 assert(lengths.size() == numLenghts);
133 if (numLenghts == 0) {
137 for (
int i = 0;
i < numLenghts; ++
i) {
138 table[
i].resize(1 << logNumEntries, 0);
139 for (
int j = 0;
j < ((1 << logNumEntries) - 1); ++
j) {
153 return (((((branch_pc ^(branch_pc >>2))<<1) ^ (
bi->lowConf &
bias)) <<1)
160 return (((((branch_pc ^ (branch_pc >> (
logBias-2)))<<1) ^
161 (
bi->highConf))<<1) +
bi->predBeforeSC) & ((1<<
logBias) -1);
167 return ((branch_pc ^ (branch_pc >>2)) & ((1 << (
logSizeUp)) - 1));
173 return ((branch_pc ^ (branch_pc >>2)) & ((1 << (
logSizeUps)) - 1));
180 return (((int64_t) branch_pc) ^ bhist ^ (bhist >> (8 -
i)) ^
181 (bhist >> (16 - 2 *
i)) ^ (bhist >> (24 - 3 *
i)) ^
182 (bhist >> (32 - 3 *
i)) ^ (bhist >> (40 - 4 *
i))) &
192 for (
int i = 0;
i < nbr;
i++) {
193 int64_t bhist = hist & ((int64_t) ((1 <<
length[
i]) - 1));
195 int8_t ctr = tab[
i][
index];
196 percsum += (2 * ctr + 1);
198 percsum = (1 + (
w[
getIndUpds(branch_pc)] >= 0)) * percsum;
209 for (
int i = 0;
i < nbr;
i++) {
210 int64_t bhist = hist & ((int64_t) ((1 <<
length[
i]) - 1));
212 percsum += (2 * tab[
i][
index] + 1);
216 int xsum =
bi->lsum - ((
w[
getIndUpds(branch_pc)] >= 0)) * percsum;
217 if ((xsum + percsum >= 0) != (xsum >= 0)) {
226 bool use_conf_ctr, int8_t conf_ctr,
unsigned conf_bits,
227 int hitBank,
int altBank, int64_t phist,
int init_lsum)
229 bool pred_taken = prev_pred_taken;
232 bi->predBeforeSC = prev_pred_taken;
236 bi->lowConf = (abs(2 * conf_ctr + 1) == 1);
237 bi->medConf = (abs(2 * conf_ctr + 1) == 5);
238 bi->highConf = (abs(2 * conf_ctr + 1) >= (1<<conf_bits) - 1);
241 int lsum = init_lsum;
244 lsum += (2 * ctr + 1);
246 lsum += (2 * ctr + 1);
248 lsum += (2 * ctr + 1);
258 bool scPred = (lsum >= 0);
260 if (pred_taken != scPred) {
261 bool useScPred =
true;
264 if (abs (lsum) < (thres / 4)) {
266 }
else if (abs (lsum) < (thres / 2)) {
272 if (abs (lsum) < (thres / 4)) {
277 bi->usedScPred = useScPred;
299 if (corrTarget < branch_pc) {
312 (taken & (corrTarget < branch_pc));
320 int altBank, int64_t phist)
322 bool scPred = (
bi->lsum >= 0);
324 if (
bi->predBeforeSC != scPred) {
325 if (abs(
bi->lsum) <
bi->thres) {
327 if ((abs(
bi->lsum) <
bi->thres / 2)) {
328 if ((abs(
bi->lsum) >=
bi->thres / 4)) {
336 if ((abs(
bi->lsum) <
bi->thres / 4)) {
343 if ((scPred != taken) || ((abs(
bi->lsum) <
bi->thres))) {
353 int xsum =
bi->lsum -
354 ((
wb[indUpds] >= 0) * ((2 *
bias[indBias] + 1) +
355 (2 *
biasSK[indBiasSK] + 1) +
358 if ((xsum + ((2 *
bias[indBias] + 1) + (2 *
biasSK[indBiasSK] + 1) +
359 (2 *
biasBank[indBiasBank] + 1)) >= 0) != (xsum >= 0))
362 (((2 *
bias[indBias] + 1) +
363 (2 *
biasSK[indBiasSK] + 1) +
364 (2 *
biasBank[indBiasBank] + 1) >= 0) == taken),
379 if (taken ==
bi->scPred) {
402 :
Stats::Group(parent),
403 ADD_STAT(correct,
"Number of time the SC predictor is the"
404 " provider and the prediction is correct"),
405 ADD_STAT(wrong,
"Number of time the SC predictor is the"
406 " provider and the prediction is wrong")
const unsigned updateThresholdWidth
virtual void gUpdates(ThreadID tid, Addr pc, bool taken, BranchInfo *bi, int64_t phist)=0
const unsigned logSizeUps
bool isDirectCtrl() const
virtual unsigned getIndBiasBank(Addr branch_pc, BranchInfo *bi, int hitBank, int altBank) const =0
int64_t gIndex(Addr branch_pc, int64_t bhist, int logs, int nbr, int i)
virtual size_t getSizeInBits() const
virtual SCThreadHistory * makeThreadHistory()
virtual int gPredictions(ThreadID tid, Addr branch_pc, BranchInfo *bi, int &lsum, int64_t phist)=0
unsigned getIndUpds(Addr branch_pc) const
int16_t ThreadID
Thread index/ID type.
const unsigned chooserConfWidth
std::vector< int8_t > bias
StatisticalCorrector(const StatisticalCorrectorParams *p)
std::vector< int8_t > * lgehl
const unsigned scCountersWidth
virtual unsigned getIndBias(Addr branch_pc, BranchInfo *bi, bool b) const
std::vector< int > pUpdateThreshold
virtual unsigned getIndUpd(Addr branch_pc) const
std::vector< int8_t > * bwgehl
virtual BranchInfo * makeBranchInfo()
void updateLocalHistory(int ordinal, Addr branch_pc, bool taken, Addr extraXor=0)
std::vector< int8_t > biasBank
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
StatisticalCorrectorStats(Stats::Group *parent)
virtual void gUpdate(Addr branch_pc, bool taken, int64_t hist, std::vector< int > &length, std::vector< int8_t > *tab, int nbr, int logs, std::vector< int8_t > &w, BranchInfo *bi)
std::vector< int8_t > wbw
void updateStats(bool taken, BranchInfo *bi)
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
StatisticalCorrector::StatisticalCorrectorStats stats
virtual int gIndexLogsSubstr(int nbr, int i)=0
SCThreadHistory * scHistory
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
virtual bool scPredict(ThreadID tid, Addr branch_pc, bool cond_branch, BranchInfo *bi, bool prev_pred_taken, bool bias_bit, bool use_conf_ctr, int8_t conf_ctr, unsigned conf_bits, int hitBank, int altBank, int64_t phist, int init_lsum=0)
virtual void scHistoryUpdate(Addr branch_pc, const StaticInstPtr &inst, bool taken, BranchInfo *tage_bi, Addr corrTarget)
void initGEHLTable(unsigned numLenghts, std::vector< int > lengths, std::vector< int8_t > *&table, unsigned logNumEntries, std::vector< int8_t > &w, int8_t wInitValue)
std::vector< int8_t > biasSK
virtual unsigned getIndBiasSK(Addr branch_pc, BranchInfo *bi) const
void ctrUpdate(T &ctr, bool taken, int nbits)
std::vector< int8_t > * igehl
virtual void condBranchUpdate(ThreadID tid, Addr branch_pc, bool taken, BranchInfo *bi, Addr corrTarget, bool bias_bit, int hitBank, int altBank, int64_t phist)
int gPredict(Addr branch_pc, int64_t hist, std::vector< int > &length, std::vector< int8_t > *tab, int nbr, int logs, std::vector< int8_t > &w)
const unsigned pUpdateThresholdWidth
const unsigned extraWeightsWidth
bool isUncondCtrl() const
Abstract superclass for simulation objects.
Generated on Wed Sep 30 2020 14:02:09 for gem5 by doxygen 1.8.17