stride.cc (13422:4ec52da74cd5) | stride.cc (13423:a414d6fccc4e) |
---|---|
1/* 2 * Copyright (c) 2012-2013, 2015 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 101 unchanged lines hidden (view full) --- 110 } 111 112 // Get required packet info 113 Addr pkt_addr = pkt->getAddr(); 114 Addr pc = pkt->req->getPC(); 115 bool is_secure = pkt->isSecure(); 116 MasterID master_id = useMasterId ? pkt->req->masterId() : 0; 117 | 1/* 2 * Copyright (c) 2012-2013, 2015 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 101 unchanged lines hidden (view full) --- 110 } 111 112 // Get required packet info 113 Addr pkt_addr = pkt->getAddr(); 114 Addr pc = pkt->req->getPC(); 115 bool is_secure = pkt->isSecure(); 116 MasterID master_id = useMasterId ? pkt->req->masterId() : 0; 117 |
118 // Lookup pc-based information 119 StrideEntry *entry; | 118 // Search for entry in the pc table 119 StrideEntry *entry = findEntry(pc, is_secure, master_id); |
120 | 120 |
121 if (pcTableHit(pc, is_secure, master_id, entry)) { | 121 if (entry != nullptr) { |
122 // Hit in table 123 int new_stride = pkt_addr - entry->lastAddr; 124 bool stride_match = (new_stride == entry->stride); 125 126 // Adjust confidence for stride entry 127 if (stride_match && new_stride != 0) { 128 if (entry->confidence < maxConf) 129 entry->confidence++; --- 63 unchanged lines hidden (view full) --- 193 // Rand replacement for now 194 int set = pcHash(pc); 195 int way = random_mt.random<int>(0, pcTableAssoc - 1); 196 197 DPRINTF(HWPrefetch, "Victimizing lookup table[%d][%d].\n", set, way); 198 return &pcTable[master_id][set][way]; 199} 200 | 122 // Hit in table 123 int new_stride = pkt_addr - entry->lastAddr; 124 bool stride_match = (new_stride == entry->stride); 125 126 // Adjust confidence for stride entry 127 if (stride_match && new_stride != 0) { 128 if (entry->confidence < maxConf) 129 entry->confidence++; --- 63 unchanged lines hidden (view full) --- 193 // Rand replacement for now 194 int set = pcHash(pc); 195 int way = random_mt.random<int>(0, pcTableAssoc - 1); 196 197 DPRINTF(HWPrefetch, "Victimizing lookup table[%d][%d].\n", set, way); 198 return &pcTable[master_id][set][way]; 199} 200 |
201inline bool 202StridePrefetcher::pcTableHit(Addr pc, bool is_secure, int master_id, 203 StrideEntry* &entry) | 201inline StridePrefetcher::StrideEntry* 202StridePrefetcher::findEntry(Addr pc, bool is_secure, int master_id) |
204{ 205 int set = pcHash(pc); 206 StrideEntry* set_entries = pcTable[master_id][set]; 207 for (int way = 0; way < pcTableAssoc; way++) { | 203{ 204 int set = pcHash(pc); 205 StrideEntry* set_entries = pcTable[master_id][set]; 206 for (int way = 0; way < pcTableAssoc; way++) { |
207 StrideEntry* entry = &set_entries[way]; |
|
208 // Search ways for match | 208 // Search ways for match |
209 if (set_entries[way].instAddr == pc && 210 set_entries[way].isSecure == is_secure) { | 209 if ((entry->instAddr == pc) && (entry->isSecure == is_secure)) { |
211 DPRINTF(HWPrefetch, "Lookup hit table[%d][%d].\n", set, way); | 210 DPRINTF(HWPrefetch, "Lookup hit table[%d][%d].\n", set, way); |
212 entry = &set_entries[way]; 213 return true; | 211 return entry; |
214 } 215 } | 212 } 213 } |
216 return false; | 214 return nullptr; |
217} 218 219StridePrefetcher* 220StridePrefetcherParams::create() 221{ 222 return new StridePrefetcher(this); 223} | 215} 216 217StridePrefetcher* 218StridePrefetcherParams::create() 219{ 220 return new StridePrefetcher(this); 221} |