ltage.hh (13455:56e25a5f9603) | ltage.hh (13493:91ae6168ef27) |
---|---|
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. --- 62 unchanged lines hidden (view full) --- 71 72 private: 73 // Prediction Structures 74 // Loop Predictor Entry 75 struct LoopEntry 76 { 77 uint16_t numIter; 78 uint16_t currentIter; | 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. --- 62 unchanged lines hidden (view full) --- 71 72 private: 73 // Prediction Structures 74 // Loop Predictor Entry 75 struct LoopEntry 76 { 77 uint16_t numIter; 78 uint16_t currentIter; |
79 uint16_t currentIterSpec; | 79 uint16_t currentIterSpec; // only for useSpeculation |
80 uint8_t confidence; 81 uint16_t tag; 82 uint8_t age; | 80 uint8_t confidence; 81 uint16_t tag; 82 uint8_t age; |
83 bool dir; | 83 bool dir; // only for useDirectionBit |
84 85 LoopEntry() : numIter(0), currentIter(0), currentIterSpec(0), 86 confidence(0), tag(0), age(0), dir(0) { } 87 }; 88 89 // more provider types 90 enum { 91 LOOP = LAST_TAGE_PROVIDER_TYPE + 1 92 }; 93 94 // Primary branch history entry 95 struct LTageBranchInfo : public TageBranchInfo 96 { 97 uint16_t loopTag; 98 uint16_t currentIter; 99 100 bool loopPred; 101 bool loopPredValid; 102 int loopIndex; | 84 85 LoopEntry() : numIter(0), currentIter(0), currentIterSpec(0), 86 confidence(0), tag(0), age(0), dir(0) { } 87 }; 88 89 // more provider types 90 enum { 91 LOOP = LAST_TAGE_PROVIDER_TYPE + 1 92 }; 93 94 // Primary branch history entry 95 struct LTageBranchInfo : public TageBranchInfo 96 { 97 uint16_t loopTag; 98 uint16_t currentIter; 99 100 bool loopPred; 101 bool loopPredValid; 102 int loopIndex; |
103 int loopLowPcBits; // only for useHashing |
|
103 int loopHit; 104 105 LTageBranchInfo(int sz) 106 : TageBranchInfo(sz), 107 loopTag(0), currentIter(0), 108 loopPred(false), | 104 int loopHit; 105 106 LTageBranchInfo(int sz) 107 : TageBranchInfo(sz), 108 loopTag(0), currentIter(0), 109 loopPred(false), |
109 loopPredValid(false), loopIndex(0), loopHit(0) | 110 loopPredValid(false), loopIndex(0), loopLowPcBits(0), loopHit(0) |
110 {} 111 }; 112 113 /** 114 * Computes the index used to access the 115 * loop predictor. 116 * @param pc_in The unshifted branch PC. 117 */ 118 int lindex(Addr pc_in) const; 119 120 /** | 111 {} 112 }; 113 114 /** 115 * Computes the index used to access the 116 * loop predictor. 117 * @param pc_in The unshifted branch PC. 118 */ 119 int lindex(Addr pc_in) const; 120 121 /** |
122 * Computes the index used to access the 123 * ltable structures. 124 * It may take hashing into account 125 * @param index Result of lindex function 126 * @param lowPcBits PC bits masked with set size 127 * @param way Way to be used 128 */ 129 int finallindex(int lindex, int lowPcBits, int way) const; 130 131 /** |
|
121 * Get a branch prediction from the loop 122 * predictor. 123 * @param pc The unshifted branch PC. 124 * @param bi Pointer to information on the 125 * prediction. | 132 * Get a branch prediction from the loop 133 * predictor. 134 * @param pc The unshifted branch PC. 135 * @param bi Pointer to information on the 136 * prediction. |
137 * @param speculative Use speculative number of iterations |
|
126 */ | 138 */ |
127 bool getLoop(Addr pc, LTageBranchInfo* bi) const; | 139 bool getLoop(Addr pc, LTageBranchInfo* bi, bool speculative) const; |
128 129 /** 130 * Updates the loop predictor. 131 * @param pc The unshifted branch PC. 132 * @param taken The actual branch outcome. 133 * @param bi Pointer to information on the 134 * prediction recorded at prediction time. 135 */ 136 void loopUpdate(Addr pc, bool Taken, LTageBranchInfo* bi); 137 138 /** 139 * Speculatively updates the loop predictor | 140 141 /** 142 * Updates the loop predictor. 143 * @param pc The unshifted branch PC. 144 * @param taken The actual branch outcome. 145 * @param bi Pointer to information on the 146 * prediction recorded at prediction time. 147 */ 148 void loopUpdate(Addr pc, bool Taken, LTageBranchInfo* bi); 149 150 /** 151 * Speculatively updates the loop predictor |
140 * iteration count. 141 * @param pc The unshifted branch PC. | 152 * iteration count (only for useSpeculation). |
142 * @param taken The predicted branch outcome. 143 * @param bi Pointer to information on the prediction 144 * recorded at prediction time. 145 */ | 153 * @param taken The predicted branch outcome. 154 * @param bi Pointer to information on the prediction 155 * recorded at prediction time. 156 */ |
146 void specLoopUpdate(Addr pc, bool taken, LTageBranchInfo* bi); | 157 void specLoopUpdate(bool taken, LTageBranchInfo* bi); |
147 148 /** 149 * Update LTAGE for conditional branches. 150 * @param branch_pc The unshifted branch PC. 151 * @param taken Actual branch outcome. 152 * @param bi Pointer to information on the prediction 153 * recorded at prediction time. 154 * @nrand Random int number from 0 to 3 --- 41 unchanged lines hidden (view full) --- 196 const unsigned loopTableAgeBits; 197 const unsigned loopTableConfidenceBits; 198 const unsigned loopTableTagBits; 199 const unsigned loopTableIterBits; 200 const unsigned logLoopTableAssoc; 201 const uint8_t confidenceThreshold; 202 const uint16_t loopTagMask; 203 const uint16_t loopNumIterMask; | 158 159 /** 160 * Update LTAGE for conditional branches. 161 * @param branch_pc The unshifted branch PC. 162 * @param taken Actual branch outcome. 163 * @param bi Pointer to information on the prediction 164 * recorded at prediction time. 165 * @nrand Random int number from 0 to 3 --- 41 unchanged lines hidden (view full) --- 207 const unsigned loopTableAgeBits; 208 const unsigned loopTableConfidenceBits; 209 const unsigned loopTableTagBits; 210 const unsigned loopTableIterBits; 211 const unsigned logLoopTableAssoc; 212 const uint8_t confidenceThreshold; 213 const uint16_t loopTagMask; 214 const uint16_t loopNumIterMask; |
215 const int loopSetMask; |
|
204 205 LoopEntry *ltable; 206 207 int8_t loopUseCounter; 208 unsigned withLoopBits; 209 | 216 217 LoopEntry *ltable; 218 219 int8_t loopUseCounter; 220 unsigned withLoopBits; 221 |
222 const bool useDirectionBit; 223 const bool useSpeculation; 224 const bool useHashing; 225 |
|
210 // stats 211 Stats::Scalar loopPredictorCorrect; 212 Stats::Scalar loopPredictorWrong; 213}; 214 215#endif // __CPU_PRED_LTAGE | 226 // stats 227 Stats::Scalar loopPredictorCorrect; 228 Stats::Scalar loopPredictorWrong; 229}; 230 231#endif // __CPU_PRED_LTAGE |