53 #include "debug/HWPrefetch.hh"
58 threshConf(p->thresh_conf),
60 startConf(p->start_conf),
61 pcTableAssoc(p->table_assoc),
62 pcTableSets(p->table_sets),
63 useMasterId(p->use_master_id),
65 pcTable(pcTableAssoc, pcTableSets,
name())
76 auto res =
entries.insert(std::make_pair(context,
79 chatty_assert(res.second,
"Allocating an already created context\n");
80 assert(it->first == context);
82 DPRINTF(HWPrefetch,
"Adding context %i with stride entries at %p\n",
93 for (
auto entry : entries) {
95 delete[] entry.second[
s];
97 delete[] entry.second;
106 DPRINTF(HWPrefetch,
"Ignoring request with no PC.\n");
119 if (
pcTableHit(pc, is_secure, master_id, entry)) {
121 int new_stride = pkt_addr - entry->
lastAddr;
122 bool stride_match = (new_stride == entry->
stride);
125 if (stride_match && new_stride != 0) {
133 entry->
stride = new_stride;
136 DPRINTF(HWPrefetch,
"Hit: PC %x pkt_addr %x (%s) stride %d (%s), "
137 "conf %d\n", pc, pkt_addr, is_secure ?
"s" :
"ns", new_stride,
138 stride_match ?
"match" :
"change",
150 int prefetch_stride = new_stride;
151 if (abs(new_stride) <
blkSize) {
155 Addr new_addr = pkt_addr +
d * prefetch_stride;
157 DPRINTF(HWPrefetch,
"Queuing prefetch to %#x.\n", new_addr);
162 DPRINTF(HWPrefetch,
"Ignoring page crossing prefetch.\n");
168 DPRINTF(HWPrefetch,
"Miss: PC %x pkt_addr %x (%s)\n", pc, pkt_addr,
169 is_secure ?
"s" :
"ns");
183 Addr hash1 = pc >> 1;
195 DPRINTF(HWPrefetch,
"Victimizing lookup table[%d][%d].\n", set, way);
196 return &
pcTable[master_id][set][way];
207 if (set_entries[way].instAddr == pc &&
208 set_entries[way].isSecure == is_secure) {
209 DPRINTF(HWPrefetch,
"Lookup hit table[%d][%d].\n", set, way);
210 entry = &set_entries[way];
218 StridePrefetcherParams::create()
#define chatty_assert(cond,...)
The chatty assert macro will function like a normal assert, but will allow the specification of addit...
const std::string & name()
StridePrefetcher(const StridePrefetcherParams *p)
StrideEntry * pcTableVictim(Addr pc, int master_id)
Addr getPC() const
Accessor function for pc.
Addr pcHash(Addr pc) const
std::enable_if< std::is_integral< T >::value, T >::type random()
Use the SFINAE idiom to choose an implementation based on whether the type is integral or floating po...
Describes a strided prefetcher.
std::pair< Addr, int32_t > AddrPriority
const RequestPtr req
A pointer to the original request.
bool isPowerOf2(const T &n)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
bool pcTableHit(Addr pc, bool is_secure, int master_id, StrideEntry *&entry)
MasterID masterId() const
Accesssor for the requestor id.
void calculatePrefetch(const PacketPtr &pkt, std::vector< AddrPriority > &addresses)
int floorLog2(unsigned x)
bool onInst
Consult prefetcher on instruction accesses?
StrideEntry ** allocateNewContext(int context)
unsigned blkSize
The block size of the parent cache.
std::unordered_map< int, StrideEntry ** > entries
bool samePage(Addr a, Addr b) const
Determine if addresses are on the same page.