ltage.cc (12334:e0ab29a34764) | ltage.cc (13413:b84a7c832ead) |
---|---|
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. --- 124 unchanged lines hidden (view full) --- 133 tableTags = new int [nHistoryTables+1]; 134 135 loopUseCounter = 0; 136} 137 138int 139LTAGE::bindex(Addr pc_in) const 140{ | 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. --- 124 unchanged lines hidden (view full) --- 133 tableTags = new int [nHistoryTables+1]; 134 135 loopUseCounter = 0; 136} 137 138int 139LTAGE::bindex(Addr pc_in) const 140{ |
141 return ((pc_in) & ((ULL(1) << (logSizeBiMP)) - 1)); | 141 return ((pc_in >> instShiftAmt) & ((ULL(1) << (logSizeBiMP)) - 1)); |
142} 143 144int 145LTAGE::lindex(Addr pc_in) const 146{ | 142} 143 144int 145LTAGE::lindex(Addr pc_in) const 146{ |
147 return (((pc_in) & ((ULL(1) << (logSizeLoopPred - 2)) - 1)) << 2); | 147 return (((pc_in >> instShiftAmt) & 148 ((ULL(1) << (logSizeLoopPred - 2)) - 1)) << 2); |
148} 149 150int 151LTAGE::F(int A, int size, int bank) const 152{ 153 int A1, A2; 154 155 A = A & ((ULL(1) << size) - 1); --- 10 unchanged lines hidden (view full) --- 166 167// gindex computes a full hash of pc, ghist and pathHist 168int 169LTAGE::gindex(ThreadID tid, Addr pc, int bank) const 170{ 171 int index; 172 int hlen = (histLengths[bank] > 16) ? 16 : histLengths[bank]; 173 index = | 149} 150 151int 152LTAGE::F(int A, int size, int bank) const 153{ 154 int A1, A2; 155 156 A = A & ((ULL(1) << size) - 1); --- 10 unchanged lines hidden (view full) --- 167 168// gindex computes a full hash of pc, ghist and pathHist 169int 170LTAGE::gindex(ThreadID tid, Addr pc, int bank) const 171{ 172 int index; 173 int hlen = (histLengths[bank] > 16) ? 16 : histLengths[bank]; 174 index = |
174 (pc) ^ ((pc) >> ((int) abs(tagTableSizes[bank] - bank) + 1)) ^ | 175 (pc >> instShiftAmt) ^ 176 ((pc >> instShiftAmt) >> ((int) abs(tagTableSizes[bank] - bank) + 1)) ^ |
175 threadHistory[tid].computeIndices[bank].comp ^ 176 F(threadHistory[tid].pathHist, hlen, bank); 177 178 return (index & ((ULL(1) << (tagTableSizes[bank])) - 1)); 179} 180 181 182// Tag computation 183uint16_t 184LTAGE::gtag(ThreadID tid, Addr pc, int bank) const 185{ | 177 threadHistory[tid].computeIndices[bank].comp ^ 178 F(threadHistory[tid].pathHist, hlen, bank); 179 180 return (index & ((ULL(1) << (tagTableSizes[bank])) - 1)); 181} 182 183 184// Tag computation 185uint16_t 186LTAGE::gtag(ThreadID tid, Addr pc, int bank) const 187{ |
186 int tag = (pc) ^ threadHistory[tid].computeTags[0][bank].comp 187 ^ (threadHistory[tid].computeTags[1][bank].comp << 1); | 188 int tag = (pc >> instShiftAmt) ^ 189 threadHistory[tid].computeTags[0][bank].comp ^ 190 (threadHistory[tid].computeTags[1][bank].comp << 1); |
188 189 return (tag & ((ULL(1) << tagWidths[bank]) - 1)); 190} 191 192 193// Up-down saturating counter 194void 195LTAGE::ctrUpdate(int8_t & ctr, bool taken, int nbits) --- 38 unchanged lines hidden (view full) --- 234 235//loop prediction: only used if high confidence 236bool 237LTAGE::getLoop(Addr pc, BranchInfo* bi) const 238{ 239 bi->loopHit = -1; 240 bi->loopPredValid = false; 241 bi->loopIndex = lindex(pc); | 191 192 return (tag & ((ULL(1) << tagWidths[bank]) - 1)); 193} 194 195 196// Up-down saturating counter 197void 198LTAGE::ctrUpdate(int8_t & ctr, bool taken, int nbits) --- 38 unchanged lines hidden (view full) --- 237 238//loop prediction: only used if high confidence 239bool 240LTAGE::getLoop(Addr pc, BranchInfo* bi) const 241{ 242 bi->loopHit = -1; 243 bi->loopPredValid = false; 244 bi->loopIndex = lindex(pc); |
242 bi->loopTag = ((pc) >> (logSizeLoopPred - 2)); | 245 bi->loopTag = ((pc) >> (instShiftAmt + logSizeLoopPred - 2)); |
243 244 for (int i = 0; i < 4; i++) { 245 if (ltable[bi->loopIndex + i].tag == bi->loopTag) { 246 bi->loopHit = i; 247 bi->loopPredValid = (ltable[bi->loopIndex + i].confidence >= 3); 248 bi->currentIter = ltable[bi->loopIndex + i].currentIterSpec; 249 if (ltable[bi->loopIndex + i].currentIterSpec + 1 == 250 ltable[bi->loopIndex + i].numIter) { --- 374 unchanged lines hidden (view full) --- 625} 626 627void 628LTAGE::updateHistories(ThreadID tid, Addr branch_pc, bool taken, void* b) 629{ 630 BranchInfo* bi = (BranchInfo*)(b); 631 ThreadHistory& tHist = threadHistory[tid]; 632 // UPDATE HISTORIES | 246 247 for (int i = 0; i < 4; i++) { 248 if (ltable[bi->loopIndex + i].tag == bi->loopTag) { 249 bi->loopHit = i; 250 bi->loopPredValid = (ltable[bi->loopIndex + i].confidence >= 3); 251 bi->currentIter = ltable[bi->loopIndex + i].currentIterSpec; 252 if (ltable[bi->loopIndex + i].currentIterSpec + 1 == 253 ltable[bi->loopIndex + i].numIter) { --- 374 unchanged lines hidden (view full) --- 628} 629 630void 631LTAGE::updateHistories(ThreadID tid, Addr branch_pc, bool taken, void* b) 632{ 633 BranchInfo* bi = (BranchInfo*)(b); 634 ThreadHistory& tHist = threadHistory[tid]; 635 // UPDATE HISTORIES |
633 bool pathbit = ((branch_pc) & 1); | 636 bool pathbit = ((branch_pc >> instShiftAmt) & 1); |
634 //on a squash, return pointers to this and recompute indices. 635 //update user history 636 updateGHist(tHist.gHist, taken, tHist.globalHistory, tHist.ptGhist); 637 tHist.pathHist = (tHist.pathHist << 1) + pathbit; 638 tHist.pathHist = (tHist.pathHist & ((ULL(1) << 16) - 1)); 639 640 bi->ptGhist = tHist.ptGhist; 641 bi->pathHist = tHist.pathHist; --- 105 unchanged lines hidden --- | 637 //on a squash, return pointers to this and recompute indices. 638 //update user history 639 updateGHist(tHist.gHist, taken, tHist.globalHistory, tHist.ptGhist); 640 tHist.pathHist = (tHist.pathHist << 1) + pathbit; 641 tHist.pathHist = (tHist.pathHist & ((ULL(1) << 16) - 1)); 642 643 bi->ptGhist = tHist.ptGhist; 644 bi->pathHist = tHist.pathHist; --- 105 unchanged lines hidden --- |