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 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 * Authors: Kevin Lim 29 */ 30 31#include "base/trace.hh" 32#include "cpu/o3/store_set.hh" 33 34StoreSet::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 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 * Authors: Kevin Lim 29 */ 30 31#include "base/trace.hh" 32#include "cpu/o3/store_set.hh" 33 34StoreSet::StoreSet(int _SSIT_size, int _LFST_size)
|
35 : SSIT_size(_SSIT_size), LFST_size(_LFST_size)
| 35 : SSITSize(_SSIT_size), LFSTSize(_LFST_size)
|
36{ 37 DPRINTF(StoreSet, "StoreSet: Creating store set object.\n"); 38 DPRINTF(StoreSet, "StoreSet: SSIT size: %i, LFST size: %i.\n",
| 36{ 37 DPRINTF(StoreSet, "StoreSet: Creating store set object.\n"); 38 DPRINTF(StoreSet, "StoreSet: SSIT size: %i, LFST size: %i.\n",
|
39 SSIT_size, LFST_size);
| 39 SSITSize, LFSTSize);
|
40
| 40
|
41 SSIT = new SSID[SSIT_size];
| 41 SSIT.resize(SSITSize);
|
42
| 42
|
43 validSSIT.resize(SSIT_size);
| 43 validSSIT.resize(SSITSize);
|
44
| 44
|
45 for (int i = 0; i < SSIT_size; ++i)
| 45 for (int i = 0; i < SSITSize; ++i)
|
46 validSSIT[i] = false; 47
| 46 validSSIT[i] = false; 47
|
48 LFST = new InstSeqNum[LFST_size];
| 48 LFST.resize(LFSTSize);
|
49
| 49
|
50 validLFST.resize(LFST_size);
| 50 validLFST.resize(LFSTSize);
|
51
| 51
|
52 SSCounters = new int[LFST_size];
| 52 for (int i = 0; i < LFSTSize; ++i) { 53 validLFST[i] = false; 54 LFST[i] = 0; 55 }
|
53
| 56
|
54 for (int i = 0; i < LFST_size; ++i) 55 {
| 57 indexMask = SSITSize - 1; 58 59 offsetBits = 2; 60} 61 62StoreSet::~StoreSet() 63{ 64} 65 66void 67StoreSet::init(int _SSIT_size, int _LFST_size) 68{ 69 SSITSize = _SSIT_size; 70 LFSTSize = _LFST_size; 71 72 DPRINTF(StoreSet, "StoreSet: Creating store set object.\n"); 73 DPRINTF(StoreSet, "StoreSet: SSIT size: %i, LFST size: %i.\n", 74 SSITSize, LFSTSize); 75 76 SSIT.resize(SSITSize); 77 78 validSSIT.resize(SSITSize); 79 80 for (int i = 0; i < SSITSize; ++i) 81 validSSIT[i] = false; 82 83 LFST.resize(LFSTSize); 84 85 validLFST.resize(LFSTSize); 86 87 for (int i = 0; i < LFSTSize; ++i) {
|
56 validLFST[i] = false;
| 88 validLFST[i] = false;
|
57 SSCounters[i] = 0;
| 89 LFST[i] = 0;
|
58 } 59
| 90 } 91
|
60 index_mask = SSIT_size - 1;
| 92 indexMask = SSITSize - 1;
|
61
| 93
|
62 offset_bits = 2;
| 94 offsetBits = 2;
|
63} 64
| 95} 96
|
| 97
|
65void 66StoreSet::violation(Addr store_PC, Addr load_PC) 67{ 68 int load_index = calcIndex(load_PC); 69 int store_index = calcIndex(store_PC); 70
| 98void 99StoreSet::violation(Addr store_PC, Addr load_PC) 100{ 101 int load_index = calcIndex(load_PC); 102 int store_index = calcIndex(store_PC); 103
|
71 assert(load_index < SSIT_size && store_index < SSIT_size);
| 104 assert(load_index < SSITSize && store_index < SSITSize);
|
72 73 bool valid_load_SSID = validSSIT[load_index]; 74 bool valid_store_SSID = validSSIT[store_index]; 75 76 if (!valid_load_SSID && !valid_store_SSID) { 77 // Calculate a new SSID here. 78 SSID new_set = calcSSID(load_PC); 79 80 validSSIT[load_index] = true; 81 82 SSIT[load_index] = new_set; 83 84 validSSIT[store_index] = true; 85 86 SSIT[store_index] = new_set; 87
| 105 106 bool valid_load_SSID = validSSIT[load_index]; 107 bool valid_store_SSID = validSSIT[store_index]; 108 109 if (!valid_load_SSID && !valid_store_SSID) { 110 // Calculate a new SSID here. 111 SSID new_set = calcSSID(load_PC); 112 113 validSSIT[load_index] = true; 114 115 SSIT[load_index] = new_set; 116 117 validSSIT[store_index] = true; 118 119 SSIT[store_index] = new_set; 120
|
88 assert(new_set < LFST_size);
| 121 assert(new_set < LFSTSize);
|
89
| 122
|
90 SSCounters[new_set]++; 91 92
| |
93 DPRINTF(StoreSet, "StoreSet: Neither load nor store had a valid " 94 "storeset, creating a new one: %i for load %#x, store %#x\n", 95 new_set, load_PC, store_PC); 96 } else if (valid_load_SSID && !valid_store_SSID) { 97 SSID load_SSID = SSIT[load_index]; 98 99 validSSIT[store_index] = true; 100 101 SSIT[store_index] = load_SSID; 102
| 123 DPRINTF(StoreSet, "StoreSet: Neither load nor store had a valid " 124 "storeset, creating a new one: %i for load %#x, store %#x\n", 125 new_set, load_PC, store_PC); 126 } else if (valid_load_SSID && !valid_store_SSID) { 127 SSID load_SSID = SSIT[load_index]; 128 129 validSSIT[store_index] = true; 130 131 SSIT[store_index] = load_SSID; 132
|
103 assert(load_SSID < LFST_size);
| 133 assert(load_SSID < LFSTSize);
|
104
| 134
|
105 SSCounters[load_SSID]++; 106
| |
107 DPRINTF(StoreSet, "StoreSet: Load had a valid store set. Adding " 108 "store to that set: %i for load %#x, store %#x\n", 109 load_SSID, load_PC, store_PC); 110 } else if (!valid_load_SSID && valid_store_SSID) { 111 SSID store_SSID = SSIT[store_index]; 112 113 validSSIT[load_index] = true; 114 115 SSIT[load_index] = store_SSID; 116
| 135 DPRINTF(StoreSet, "StoreSet: Load had a valid store set. Adding " 136 "store to that set: %i for load %#x, store %#x\n", 137 load_SSID, load_PC, store_PC); 138 } else if (!valid_load_SSID && valid_store_SSID) { 139 SSID store_SSID = SSIT[store_index]; 140 141 validSSIT[load_index] = true; 142 143 SSIT[load_index] = store_SSID; 144
|
117 // Because we are having a load point to an already existing set, 118 // the size of the store set is not incremented. 119
| |
120 DPRINTF(StoreSet, "StoreSet: Store had a valid store set: %i for " 121 "load %#x, store %#x\n", 122 store_SSID, load_PC, store_PC); 123 } else { 124 SSID load_SSID = SSIT[load_index]; 125 SSID store_SSID = SSIT[store_index]; 126
| 145 DPRINTF(StoreSet, "StoreSet: Store had a valid store set: %i for " 146 "load %#x, store %#x\n", 147 store_SSID, load_PC, store_PC); 148 } else { 149 SSID load_SSID = SSIT[load_index]; 150 SSID store_SSID = SSIT[store_index]; 151
|
127 assert(load_SSID < LFST_size && store_SSID < LFST_size);
| 152 assert(load_SSID < LFSTSize && store_SSID < LFSTSize);
|
128
| 153
|
129 int load_SS_size = SSCounters[load_SSID]; 130 int store_SS_size = SSCounters[store_SSID]; 131 132 // If the load has the bigger store set, then assign the store 133 // to the same store set as the load. Otherwise vice-versa. 134 if (load_SS_size > store_SS_size) {
| 154 // The store set with the lower number wins 155 if (store_SSID > load_SSID) {
|
135 SSIT[store_index] = load_SSID; 136
| 156 SSIT[store_index] = load_SSID; 157
|
137 SSCounters[load_SSID]++; 138 SSCounters[store_SSID]--; 139 140 DPRINTF(StoreSet, "StoreSet: Load had bigger store set: %i; "
| 158 DPRINTF(StoreSet, "StoreSet: Load had smaller store set: %i; "
|
141 "for load %#x, store %#x\n", 142 load_SSID, load_PC, store_PC); 143 } else { 144 SSIT[load_index] = store_SSID; 145
| 159 "for load %#x, store %#x\n", 160 load_SSID, load_PC, store_PC); 161 } else { 162 SSIT[load_index] = store_SSID; 163
|
146 SSCounters[store_SSID]++; 147 SSCounters[load_SSID]--; 148 149 DPRINTF(StoreSet, "StoreSet: Store had bigger store set: %i; "
| 164 DPRINTF(StoreSet, "StoreSet: Store had smaller store set: %i; "
|
150 "for load %#x, store %#x\n", 151 store_SSID, load_PC, store_PC); 152 } 153 } 154} 155 156void 157StoreSet::insertLoad(Addr load_PC, InstSeqNum load_seq_num) 158{ 159 // Does nothing. 160 return; 161} 162 163void
| 165 "for load %#x, store %#x\n", 166 store_SSID, load_PC, store_PC); 167 } 168 } 169} 170 171void 172StoreSet::insertLoad(Addr load_PC, InstSeqNum load_seq_num) 173{ 174 // Does nothing. 175 return; 176} 177 178void
|
164StoreSet::insertStore(Addr store_PC, InstSeqNum store_seq_num)
| 179StoreSet::insertStore(Addr store_PC, InstSeqNum store_seq_num, 180 unsigned tid)
|
165{ 166 int index = calcIndex(store_PC); 167 168 int store_SSID; 169
| 181{ 182 int index = calcIndex(store_PC); 183 184 int store_SSID; 185
|
170 assert(index < SSIT_size);
| 186 assert(index < SSITSize);
|
171 172 if (!validSSIT[index]) { 173 // Do nothing if there's no valid entry. 174 return; 175 } else { 176 store_SSID = SSIT[index]; 177
| 187 188 if (!validSSIT[index]) { 189 // Do nothing if there's no valid entry. 190 return; 191 } else { 192 store_SSID = SSIT[index]; 193
|
178 assert(store_SSID < LFST_size);
| 194 assert(store_SSID < LFSTSize);
|
179 180 // Update the last store that was fetched with the current one. 181 LFST[store_SSID] = store_seq_num; 182 183 validLFST[store_SSID] = 1; 184
| 195 196 // Update the last store that was fetched with the current one. 197 LFST[store_SSID] = store_seq_num; 198 199 validLFST[store_SSID] = 1; 200
|
| 201 storeList[store_seq_num] = store_SSID; 202
|
185 DPRINTF(StoreSet, "Store %#x updated the LFST, SSID: %i\n", 186 store_PC, store_SSID); 187 } 188} 189 190InstSeqNum 191StoreSet::checkInst(Addr PC) 192{ 193 int index = calcIndex(PC); 194 195 int inst_SSID; 196
| 203 DPRINTF(StoreSet, "Store %#x updated the LFST, SSID: %i\n", 204 store_PC, store_SSID); 205 } 206} 207 208InstSeqNum 209StoreSet::checkInst(Addr PC) 210{ 211 int index = calcIndex(PC); 212 213 int inst_SSID; 214
|
197 assert(index < SSIT_size);
| 215 assert(index < SSITSize);
|
198 199 if (!validSSIT[index]) { 200 DPRINTF(StoreSet, "Inst %#x with index %i had no SSID\n", 201 PC, index); 202 203 // Return 0 if there's no valid entry. 204 return 0; 205 } else { 206 inst_SSID = SSIT[index]; 207
| 216 217 if (!validSSIT[index]) { 218 DPRINTF(StoreSet, "Inst %#x with index %i had no SSID\n", 219 PC, index); 220 221 // Return 0 if there's no valid entry. 222 return 0; 223 } else { 224 inst_SSID = SSIT[index]; 225
|
208 assert(inst_SSID < LFST_size);
| 226 assert(inst_SSID < LFSTSize);
|
209 210 if (!validLFST[inst_SSID]) { 211 212 DPRINTF(StoreSet, "Inst %#x with index %i and SSID %i had no " 213 "dependency\n", PC, index, inst_SSID); 214 215 return 0; 216 } else { 217 DPRINTF(StoreSet, "Inst %#x with index %i and SSID %i had LFST " 218 "inum of %i\n", PC, index, inst_SSID, LFST[inst_SSID]); 219 220 return LFST[inst_SSID]; 221 } 222 } 223} 224 225void 226StoreSet::issued(Addr issued_PC, InstSeqNum issued_seq_num, bool is_store) 227{ 228 // This only is updated upon a store being issued. 229 if (!is_store) { 230 return; 231 } 232 233 int index = calcIndex(issued_PC); 234 235 int store_SSID; 236
| 227 228 if (!validLFST[inst_SSID]) { 229 230 DPRINTF(StoreSet, "Inst %#x with index %i and SSID %i had no " 231 "dependency\n", PC, index, inst_SSID); 232 233 return 0; 234 } else { 235 DPRINTF(StoreSet, "Inst %#x with index %i and SSID %i had LFST " 236 "inum of %i\n", PC, index, inst_SSID, LFST[inst_SSID]); 237 238 return LFST[inst_SSID]; 239 } 240 } 241} 242 243void 244StoreSet::issued(Addr issued_PC, InstSeqNum issued_seq_num, bool is_store) 245{ 246 // This only is updated upon a store being issued. 247 if (!is_store) { 248 return; 249 } 250 251 int index = calcIndex(issued_PC); 252 253 int store_SSID; 254
|
237 assert(index < SSIT_size);
| 255 assert(index < SSITSize);
|
238
| 256
|
| 257 SeqNumMapIt store_list_it = storeList.find(issued_seq_num); 258 259 if (store_list_it != storeList.end()) { 260 storeList.erase(store_list_it); 261 } 262
|
239 // Make sure the SSIT still has a valid entry for the issued store. 240 if (!validSSIT[index]) { 241 return; 242 } 243 244 store_SSID = SSIT[index]; 245
| 263 // Make sure the SSIT still has a valid entry for the issued store. 264 if (!validSSIT[index]) { 265 return; 266 } 267 268 store_SSID = SSIT[index]; 269
|
246 assert(store_SSID < LFST_size);
| 270 assert(store_SSID < LFSTSize);
|
247 248 // If the last fetched store in the store set refers to the store that 249 // was just issued, then invalidate the entry. 250 if (validLFST[store_SSID] && LFST[store_SSID] == issued_seq_num) { 251 DPRINTF(StoreSet, "StoreSet: store invalidated itself in LFST.\n"); 252 validLFST[store_SSID] = false; 253 } 254} 255 256void
| 271 272 // If the last fetched store in the store set refers to the store that 273 // was just issued, then invalidate the entry. 274 if (validLFST[store_SSID] && LFST[store_SSID] == issued_seq_num) { 275 DPRINTF(StoreSet, "StoreSet: store invalidated itself in LFST.\n"); 276 validLFST[store_SSID] = false; 277 } 278} 279 280void
|
257StoreSet::squash(InstSeqNum squashed_num)
| 281StoreSet::squash(InstSeqNum squashed_num, unsigned tid)
|
258{
| 282{
|
259 // Not really sure how to do this well. 260 // Generally this is small enough that it should be okay; short circuit 261 // evaluation should take care of invalid entries. 262
| |
263 DPRINTF(StoreSet, "StoreSet: Squashing until inum %i\n", 264 squashed_num); 265
| 283 DPRINTF(StoreSet, "StoreSet: Squashing until inum %i\n", 284 squashed_num); 285
|
266 for (int i = 0; i < LFST_size; ++i) { 267 if (validLFST[i] && LFST[i] < squashed_num) { 268 validLFST[i] = false;
| 286 int idx; 287 SeqNumMapIt store_list_it = storeList.begin(); 288 289 //@todo:Fix to only delete from correct thread 290 while (!storeList.empty()) { 291 idx = (*store_list_it).second; 292 293 if ((*store_list_it).first <= squashed_num) { 294 break;
|
269 }
| 295 }
|
| 296 297 bool younger = LFST[idx] > squashed_num; 298 299 if (validLFST[idx] && younger) { 300 DPRINTF(StoreSet, "Squashed [sn:%lli]\n", LFST[idx]); 301 validLFST[idx] = false; 302 303 storeList.erase(store_list_it++); 304 } else if (!validLFST[idx] && younger) { 305 storeList.erase(store_list_it++); 306 }
|
270 } 271} 272 273void 274StoreSet::clear() 275{
| 307 } 308} 309 310void 311StoreSet::clear() 312{
|
276 for (int i = 0; i < SSIT_size; ++i) {
| 313 for (int i = 0; i < SSITSize; ++i) {
|
277 validSSIT[i] = false; 278 } 279
| 314 validSSIT[i] = false; 315 } 316
|
280 for (int i = 0; i < LFST_size; ++i) {
| 317 for (int i = 0; i < LFSTSize; ++i) {
|
281 validLFST[i] = false; 282 }
| 318 validLFST[i] = false; 319 }
|
283}
| |
284
| 320
|
| 321 storeList.clear(); 322}
|
| |