store_set.cc (2632:1bb2f91485ea) | store_set.cc (2654:9559cfa91b9d) |
---|---|
1/* | 1/* |
2 * Copyright (c) 2004-2005 The Regents of The University of Michigan | 2 * Copyright (c) 2004-2006 The Regents of The University of Michigan |
3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the --- 14 unchanged lines hidden (view full) --- 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include "base/trace.hh" 30#include "cpu/o3/store_set.hh" 31 32StoreSet::StoreSet(int _SSIT_size, int _LFST_size) | 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the --- 14 unchanged lines hidden (view full) --- 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include "base/trace.hh" 30#include "cpu/o3/store_set.hh" 31 32StoreSet::StoreSet(int _SSIT_size, int _LFST_size) |
33 : SSIT_size(_SSIT_size), LFST_size(_LFST_size) | 33 : SSITSize(_SSIT_size), LFSTSize(_LFST_size) |
34{ 35 DPRINTF(StoreSet, "StoreSet: Creating store set object.\n"); 36 DPRINTF(StoreSet, "StoreSet: SSIT size: %i, LFST size: %i.\n", | 34{ 35 DPRINTF(StoreSet, "StoreSet: Creating store set object.\n"); 36 DPRINTF(StoreSet, "StoreSet: SSIT size: %i, LFST size: %i.\n", |
37 SSIT_size, LFST_size); | 37 SSITSize, LFSTSize); |
38 | 38 |
39 SSIT = new SSID[SSIT_size]; | 39 SSIT.resize(SSITSize); |
40 | 40 |
41 validSSIT.resize(SSIT_size); | 41 validSSIT.resize(SSITSize); |
42 | 42 |
43 for (int i = 0; i < SSIT_size; ++i) | 43 for (int i = 0; i < SSITSize; ++i) |
44 validSSIT[i] = false; 45 | 44 validSSIT[i] = false; 45 |
46 LFST = new InstSeqNum[LFST_size]; | 46 LFST.resize(LFSTSize); |
47 | 47 |
48 validLFST.resize(LFST_size); | 48 validLFST.resize(LFSTSize); |
49 | 49 |
50 SSCounters = new int[LFST_size]; | 50 for (int i = 0; i < LFSTSize; ++i) { 51 validLFST[i] = false; 52 LFST[i] = 0; 53 } |
51 | 54 |
52 for (int i = 0; i < LFST_size; ++i) 53 { | 55 indexMask = SSITSize - 1; 56 57 offsetBits = 2; 58} 59 60StoreSet::~StoreSet() 61{ 62} 63 64void 65StoreSet::init(int _SSIT_size, int _LFST_size) 66{ 67 SSITSize = _SSIT_size; 68 LFSTSize = _LFST_size; 69 70 DPRINTF(StoreSet, "StoreSet: Creating store set object.\n"); 71 DPRINTF(StoreSet, "StoreSet: SSIT size: %i, LFST size: %i.\n", 72 SSITSize, LFSTSize); 73 74 SSIT.resize(SSITSize); 75 76 validSSIT.resize(SSITSize); 77 78 for (int i = 0; i < SSITSize; ++i) 79 validSSIT[i] = false; 80 81 LFST.resize(LFSTSize); 82 83 validLFST.resize(LFSTSize); 84 85 for (int i = 0; i < LFSTSize; ++i) { |
54 validLFST[i] = false; | 86 validLFST[i] = false; |
55 SSCounters[i] = 0; | 87 LFST[i] = 0; |
56 } 57 | 88 } 89 |
58 index_mask = SSIT_size - 1; | 90 indexMask = SSITSize - 1; |
59 | 91 |
60 offset_bits = 2; | 92 offsetBits = 2; |
61} 62 | 93} 94 |
95 |
|
63void 64StoreSet::violation(Addr store_PC, Addr load_PC) 65{ 66 int load_index = calcIndex(load_PC); 67 int store_index = calcIndex(store_PC); 68 | 96void 97StoreSet::violation(Addr store_PC, Addr load_PC) 98{ 99 int load_index = calcIndex(load_PC); 100 int store_index = calcIndex(store_PC); 101 |
69 assert(load_index < SSIT_size && store_index < SSIT_size); | 102 assert(load_index < SSITSize && store_index < SSITSize); |
70 71 bool valid_load_SSID = validSSIT[load_index]; 72 bool valid_store_SSID = validSSIT[store_index]; 73 74 if (!valid_load_SSID && !valid_store_SSID) { 75 // Calculate a new SSID here. 76 SSID new_set = calcSSID(load_PC); 77 78 validSSIT[load_index] = true; 79 80 SSIT[load_index] = new_set; 81 82 validSSIT[store_index] = true; 83 84 SSIT[store_index] = new_set; 85 | 103 104 bool valid_load_SSID = validSSIT[load_index]; 105 bool valid_store_SSID = validSSIT[store_index]; 106 107 if (!valid_load_SSID && !valid_store_SSID) { 108 // Calculate a new SSID here. 109 SSID new_set = calcSSID(load_PC); 110 111 validSSIT[load_index] = true; 112 113 SSIT[load_index] = new_set; 114 115 validSSIT[store_index] = true; 116 117 SSIT[store_index] = new_set; 118 |
86 assert(new_set < LFST_size); | 119 assert(new_set < LFSTSize); |
87 | 120 |
88 SSCounters[new_set]++; 89 90 | |
91 DPRINTF(StoreSet, "StoreSet: Neither load nor store had a valid " 92 "storeset, creating a new one: %i for load %#x, store %#x\n", 93 new_set, load_PC, store_PC); 94 } else if (valid_load_SSID && !valid_store_SSID) { 95 SSID load_SSID = SSIT[load_index]; 96 97 validSSIT[store_index] = true; 98 99 SSIT[store_index] = load_SSID; 100 | 121 DPRINTF(StoreSet, "StoreSet: Neither load nor store had a valid " 122 "storeset, creating a new one: %i for load %#x, store %#x\n", 123 new_set, load_PC, store_PC); 124 } else if (valid_load_SSID && !valid_store_SSID) { 125 SSID load_SSID = SSIT[load_index]; 126 127 validSSIT[store_index] = true; 128 129 SSIT[store_index] = load_SSID; 130 |
101 assert(load_SSID < LFST_size); | 131 assert(load_SSID < LFSTSize); |
102 | 132 |
103 SSCounters[load_SSID]++; 104 | |
105 DPRINTF(StoreSet, "StoreSet: Load had a valid store set. Adding " 106 "store to that set: %i for load %#x, store %#x\n", 107 load_SSID, load_PC, store_PC); 108 } else if (!valid_load_SSID && valid_store_SSID) { 109 SSID store_SSID = SSIT[store_index]; 110 111 validSSIT[load_index] = true; 112 113 SSIT[load_index] = store_SSID; 114 | 133 DPRINTF(StoreSet, "StoreSet: Load had a valid store set. Adding " 134 "store to that set: %i for load %#x, store %#x\n", 135 load_SSID, load_PC, store_PC); 136 } else if (!valid_load_SSID && valid_store_SSID) { 137 SSID store_SSID = SSIT[store_index]; 138 139 validSSIT[load_index] = true; 140 141 SSIT[load_index] = store_SSID; 142 |
115 // Because we are having a load point to an already existing set, 116 // the size of the store set is not incremented. 117 | |
118 DPRINTF(StoreSet, "StoreSet: Store had a valid store set: %i for " 119 "load %#x, store %#x\n", 120 store_SSID, load_PC, store_PC); 121 } else { 122 SSID load_SSID = SSIT[load_index]; 123 SSID store_SSID = SSIT[store_index]; 124 | 143 DPRINTF(StoreSet, "StoreSet: Store had a valid store set: %i for " 144 "load %#x, store %#x\n", 145 store_SSID, load_PC, store_PC); 146 } else { 147 SSID load_SSID = SSIT[load_index]; 148 SSID store_SSID = SSIT[store_index]; 149 |
125 assert(load_SSID < LFST_size && store_SSID < LFST_size); | 150 assert(load_SSID < LFSTSize && store_SSID < LFSTSize); |
126 | 151 |
127 int load_SS_size = SSCounters[load_SSID]; 128 int store_SS_size = SSCounters[store_SSID]; 129 130 // If the load has the bigger store set, then assign the store 131 // to the same store set as the load. Otherwise vice-versa. 132 if (load_SS_size > store_SS_size) { | 152 // The store set with the lower number wins 153 if (store_SSID > load_SSID) { |
133 SSIT[store_index] = load_SSID; 134 | 154 SSIT[store_index] = load_SSID; 155 |
135 SSCounters[load_SSID]++; 136 SSCounters[store_SSID]--; 137 138 DPRINTF(StoreSet, "StoreSet: Load had bigger store set: %i; " | 156 DPRINTF(StoreSet, "StoreSet: Load had smaller store set: %i; " |
139 "for load %#x, store %#x\n", 140 load_SSID, load_PC, store_PC); 141 } else { 142 SSIT[load_index] = store_SSID; 143 | 157 "for load %#x, store %#x\n", 158 load_SSID, load_PC, store_PC); 159 } else { 160 SSIT[load_index] = store_SSID; 161 |
144 SSCounters[store_SSID]++; 145 SSCounters[load_SSID]--; 146 147 DPRINTF(StoreSet, "StoreSet: Store had bigger store set: %i; " | 162 DPRINTF(StoreSet, "StoreSet: Store had smaller store set: %i; " |
148 "for load %#x, store %#x\n", 149 store_SSID, load_PC, store_PC); 150 } 151 } 152} 153 154void 155StoreSet::insertLoad(Addr load_PC, InstSeqNum load_seq_num) 156{ 157 // Does nothing. 158 return; 159} 160 161void | 163 "for load %#x, store %#x\n", 164 store_SSID, load_PC, store_PC); 165 } 166 } 167} 168 169void 170StoreSet::insertLoad(Addr load_PC, InstSeqNum load_seq_num) 171{ 172 // Does nothing. 173 return; 174} 175 176void |
162StoreSet::insertStore(Addr store_PC, InstSeqNum store_seq_num) | 177StoreSet::insertStore(Addr store_PC, InstSeqNum store_seq_num, 178 unsigned tid) |
163{ 164 int index = calcIndex(store_PC); 165 166 int store_SSID; 167 | 179{ 180 int index = calcIndex(store_PC); 181 182 int store_SSID; 183 |
168 assert(index < SSIT_size); | 184 assert(index < SSITSize); |
169 170 if (!validSSIT[index]) { 171 // Do nothing if there's no valid entry. 172 return; 173 } else { 174 store_SSID = SSIT[index]; 175 | 185 186 if (!validSSIT[index]) { 187 // Do nothing if there's no valid entry. 188 return; 189 } else { 190 store_SSID = SSIT[index]; 191 |
176 assert(store_SSID < LFST_size); | 192 assert(store_SSID < LFSTSize); |
177 178 // Update the last store that was fetched with the current one. 179 LFST[store_SSID] = store_seq_num; 180 181 validLFST[store_SSID] = 1; 182 | 193 194 // Update the last store that was fetched with the current one. 195 LFST[store_SSID] = store_seq_num; 196 197 validLFST[store_SSID] = 1; 198 |
199 storeList[store_seq_num] = store_SSID; 200 |
|
183 DPRINTF(StoreSet, "Store %#x updated the LFST, SSID: %i\n", 184 store_PC, store_SSID); 185 } 186} 187 188InstSeqNum 189StoreSet::checkInst(Addr PC) 190{ 191 int index = calcIndex(PC); 192 193 int inst_SSID; 194 | 201 DPRINTF(StoreSet, "Store %#x updated the LFST, SSID: %i\n", 202 store_PC, store_SSID); 203 } 204} 205 206InstSeqNum 207StoreSet::checkInst(Addr PC) 208{ 209 int index = calcIndex(PC); 210 211 int inst_SSID; 212 |
195 assert(index < SSIT_size); | 213 assert(index < SSITSize); |
196 197 if (!validSSIT[index]) { 198 DPRINTF(StoreSet, "Inst %#x with index %i had no SSID\n", 199 PC, index); 200 201 // Return 0 if there's no valid entry. 202 return 0; 203 } else { 204 inst_SSID = SSIT[index]; 205 | 214 215 if (!validSSIT[index]) { 216 DPRINTF(StoreSet, "Inst %#x with index %i had no SSID\n", 217 PC, index); 218 219 // Return 0 if there's no valid entry. 220 return 0; 221 } else { 222 inst_SSID = SSIT[index]; 223 |
206 assert(inst_SSID < LFST_size); | 224 assert(inst_SSID < LFSTSize); |
207 208 if (!validLFST[inst_SSID]) { 209 210 DPRINTF(StoreSet, "Inst %#x with index %i and SSID %i had no " 211 "dependency\n", PC, index, inst_SSID); 212 213 return 0; 214 } else { --- 12 unchanged lines hidden (view full) --- 227 if (!is_store) { 228 return; 229 } 230 231 int index = calcIndex(issued_PC); 232 233 int store_SSID; 234 | 225 226 if (!validLFST[inst_SSID]) { 227 228 DPRINTF(StoreSet, "Inst %#x with index %i and SSID %i had no " 229 "dependency\n", PC, index, inst_SSID); 230 231 return 0; 232 } else { --- 12 unchanged lines hidden (view full) --- 245 if (!is_store) { 246 return; 247 } 248 249 int index = calcIndex(issued_PC); 250 251 int store_SSID; 252 |
235 assert(index < SSIT_size); | 253 assert(index < SSITSize); |
236 | 254 |
255 SeqNumMapIt store_list_it = storeList.find(issued_seq_num); 256 257 if (store_list_it != storeList.end()) { 258 storeList.erase(store_list_it); 259 } 260 |
|
237 // Make sure the SSIT still has a valid entry for the issued store. 238 if (!validSSIT[index]) { 239 return; 240 } 241 242 store_SSID = SSIT[index]; 243 | 261 // Make sure the SSIT still has a valid entry for the issued store. 262 if (!validSSIT[index]) { 263 return; 264 } 265 266 store_SSID = SSIT[index]; 267 |
244 assert(store_SSID < LFST_size); | 268 assert(store_SSID < LFSTSize); |
245 246 // If the last fetched store in the store set refers to the store that 247 // was just issued, then invalidate the entry. 248 if (validLFST[store_SSID] && LFST[store_SSID] == issued_seq_num) { 249 DPRINTF(StoreSet, "StoreSet: store invalidated itself in LFST.\n"); 250 validLFST[store_SSID] = false; 251 } 252} 253 254void | 269 270 // If the last fetched store in the store set refers to the store that 271 // was just issued, then invalidate the entry. 272 if (validLFST[store_SSID] && LFST[store_SSID] == issued_seq_num) { 273 DPRINTF(StoreSet, "StoreSet: store invalidated itself in LFST.\n"); 274 validLFST[store_SSID] = false; 275 } 276} 277 278void |
255StoreSet::squash(InstSeqNum squashed_num) | 279StoreSet::squash(InstSeqNum squashed_num, unsigned tid) |
256{ | 280{ |
257 // Not really sure how to do this well. 258 // Generally this is small enough that it should be okay; short circuit 259 // evaluation should take care of invalid entries. 260 | |
261 DPRINTF(StoreSet, "StoreSet: Squashing until inum %i\n", 262 squashed_num); 263 | 281 DPRINTF(StoreSet, "StoreSet: Squashing until inum %i\n", 282 squashed_num); 283 |
264 for (int i = 0; i < LFST_size; ++i) { 265 if (validLFST[i] && LFST[i] < squashed_num) { 266 validLFST[i] = false; | 284 int idx; 285 SeqNumMapIt store_list_it = storeList.begin(); 286 287 //@todo:Fix to only delete from correct thread 288 while (!storeList.empty()) { 289 idx = (*store_list_it).second; 290 291 if ((*store_list_it).first <= squashed_num) { 292 break; |
267 } | 293 } |
294 295 bool younger = LFST[idx] > squashed_num; 296 297 if (validLFST[idx] && younger) { 298 DPRINTF(StoreSet, "Squashed [sn:%lli]\n", LFST[idx]); 299 validLFST[idx] = false; 300 301 storeList.erase(store_list_it++); 302 } else if (!validLFST[idx] && younger) { 303 storeList.erase(store_list_it++); 304 } |
|
268 } 269} 270 271void 272StoreSet::clear() 273{ | 305 } 306} 307 308void 309StoreSet::clear() 310{ |
274 for (int i = 0; i < SSIT_size; ++i) { | 311 for (int i = 0; i < SSITSize; ++i) { |
275 validSSIT[i] = false; 276 } 277 | 312 validSSIT[i] = false; 313 } 314 |
278 for (int i = 0; i < LFST_size; ++i) { | 315 for (int i = 0; i < LFSTSize; ++i) { |
279 validLFST[i] = false; 280 } | 316 validLFST[i] = false; 317 } |
281} | |
282 | 318 |
319 storeList.clear(); 320} |
|