stride.cc (13423:a414d6fccc4e) stride.cc (13424:1744211c9a65)
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

--- 58 unchanged lines hidden (view full) ---

67 pcTableSets(p->table_sets),
68 useMasterId(p->use_master_id),
69 degree(p->degree),
70 pcTable(pcTableAssoc, pcTableSets, name())
71{
72 assert(isPowerOf2(pcTableSets));
73}
74
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

--- 58 unchanged lines hidden (view full) ---

67 pcTableSets(p->table_sets),
68 useMasterId(p->use_master_id),
69 degree(p->degree),
70 pcTable(pcTableAssoc, pcTableSets, name())
71{
72 assert(isPowerOf2(pcTableSets));
73}
74
75StridePrefetcher::StrideEntry**
75std::vector<std::vector<StridePrefetcher::StrideEntry>>&
76StridePrefetcher::PCTable::allocateNewContext(int context)
77{
78 auto res = entries.insert(std::make_pair(context,
76StridePrefetcher::PCTable::allocateNewContext(int context)
77{
78 auto res = entries.insert(std::make_pair(context,
79 new StrideEntry*[pcTableSets]));
79 std::vector<std::vector<StrideEntry>>(pcTableSets)));
80 auto it = res.first;
81 chatty_assert(res.second, "Allocating an already created context\n");
82 assert(it->first == context);
83
80 auto it = res.first;
81 chatty_assert(res.second, "Allocating an already created context\n");
82 assert(it->first == context);
83
84 DPRINTF(HWPrefetch, "Adding context %i with stride entries at %p\n",
85 context, it->second);
84 DPRINTF(HWPrefetch, "Adding context %i with stride entries\n", context);
86
85
87 StrideEntry** entry = it->second;
88 for (int s = 0; s < pcTableSets; s++) {
89 entry[s] = new StrideEntry[pcTableAssoc];
86 std::vector<std::vector<StrideEntry>>& table = it->second;
87 for (auto& set : table) {
88 set.resize(pcTableAssoc);
90 }
89 }
91 return entry;
90 return table;
92}
93
91}
92
94StridePrefetcher::PCTable::~PCTable() {
95 for (auto entry : entries) {
96 for (int s = 0; s < pcTableSets; s++) {
97 delete[] entry.second[s];
98 }
99 delete[] entry.second;
100 }
93StridePrefetcher::PCTable::~PCTable()
94{
101}
102
103void
104StridePrefetcher::calculatePrefetch(const PacketPtr &pkt,
105 std::vector<AddrPriority> &addresses)
106{
107 if (!pkt->req->hasPC()) {
108 DPRINTF(HWPrefetch, "Ignoring request with no PC.\n");

--- 88 unchanged lines hidden (view full) ---

197 DPRINTF(HWPrefetch, "Victimizing lookup table[%d][%d].\n", set, way);
198 return &pcTable[master_id][set][way];
199}
200
201inline StridePrefetcher::StrideEntry*
202StridePrefetcher::findEntry(Addr pc, bool is_secure, int master_id)
203{
204 int set = pcHash(pc);
95}
96
97void
98StridePrefetcher::calculatePrefetch(const PacketPtr &pkt,
99 std::vector<AddrPriority> &addresses)
100{
101 if (!pkt->req->hasPC()) {
102 DPRINTF(HWPrefetch, "Ignoring request with no PC.\n");

--- 88 unchanged lines hidden (view full) ---

191 DPRINTF(HWPrefetch, "Victimizing lookup table[%d][%d].\n", set, way);
192 return &pcTable[master_id][set][way];
193}
194
195inline StridePrefetcher::StrideEntry*
196StridePrefetcher::findEntry(Addr pc, bool is_secure, int master_id)
197{
198 int set = pcHash(pc);
205 StrideEntry* set_entries = pcTable[master_id][set];
199 std::vector<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
209 if ((entry->instAddr == pc) && (entry->isSecure == is_secure)) {
210 DPRINTF(HWPrefetch, "Lookup hit table[%d][%d].\n", set, way);
211 return entry;
212 }
213 }
214 return nullptr;
215}
216
217StridePrefetcher*
218StridePrefetcherParams::create()
219{
220 return new StridePrefetcher(this);
221}
200 for (int way = 0; way < pcTableAssoc; way++) {
201 StrideEntry* entry = &set_entries[way];
202 // Search ways for match
203 if ((entry->instAddr == pc) && (entry->isSecure == is_secure)) {
204 DPRINTF(HWPrefetch, "Lookup hit table[%d][%d].\n", set, way);
205 return entry;
206 }
207 }
208 return nullptr;
209}
210
211StridePrefetcher*
212StridePrefetcherParams::create()
213{
214 return new StridePrefetcher(this);
215}