Daniel Carvalho has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/14357
Change subject: mem-cache: Vectorize StridePrefetcher's entries.
......................................................................
mem-cache: Vectorize StridePrefetcher's entries.
Turn StridePrefetcher::PCTable::entries into a vector of vectors.
Change-Id: I2a4589a76eb205910c43723638b7989eddd5ca24
---
M src/mem/cache/prefetch/stride.cc
M src/mem/cache/prefetch/stride.hh
2 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/src/mem/cache/prefetch/stride.cc
b/src/mem/cache/prefetch/stride.cc
index a00b10a..fde4f30 100644
--- a/src/mem/cache/prefetch/stride.cc
+++ b/src/mem/cache/prefetch/stride.cc
@@ -72,32 +72,26 @@
assert(isPowerOf2(pcTableSets));
}
-StridePrefetcher::StrideEntry**
+std::vector<std::vector<StridePrefetcher::StrideEntry>>&
StridePrefetcher::PCTable::allocateNewContext(int context)
{
auto res = entries.insert(std::make_pair(context,
- new StrideEntry*[pcTableSets]));
+ std::vector<std::vector<StrideEntry>>(pcTableSets)));
auto it = res.first;
chatty_assert(res.second, "Allocating an already created context\n");
assert(it->first == context);
- DPRINTF(HWPrefetch, "Adding context %i with stride entries at %p\n",
- context, it->second);
+ DPRINTF(HWPrefetch, "Adding context %i with stride entries\n",
context);
- StrideEntry** entry = it->second;
- for (int s = 0; s < pcTableSets; s++) {
- entry[s] = new StrideEntry[pcTableAssoc];
+ std::vector<std::vector<StrideEntry>>& table = it->second;
+ for (auto& set : table) {
+ set.resize(pcTableAssoc);
}
- return entry;
+ return table;
}
-StridePrefetcher::PCTable::~PCTable() {
- for (auto entry : entries) {
- for (int s = 0; s < pcTableSets; s++) {
- delete[] entry.second[s];
- }
- delete[] entry.second;
- }
+StridePrefetcher::PCTable::~PCTable()
+{
}
void
@@ -202,7 +196,7 @@
StridePrefetcher::findEntry(Addr pc, bool is_secure, int master_id)
{
int set = pcHash(pc);
- StrideEntry* set_entries = pcTable[master_id][set];
+ std::vector<StrideEntry>& set_entries = pcTable[master_id][set];
for (int way = 0; way < pcTableAssoc; way++) {
StrideEntry* entry = &set_entries[way];
// Search ways for match
diff --git a/src/mem/cache/prefetch/stride.hh
b/src/mem/cache/prefetch/stride.hh
index 605b543..da3bbb3 100644
--- a/src/mem/cache/prefetch/stride.hh
+++ b/src/mem/cache/prefetch/stride.hh
@@ -50,6 +50,7 @@
#include <string>
#include <unordered_map>
+#include <vector>
#include "base/types.hh"
#include "mem/cache/prefetch/queued.hh"
@@ -90,7 +91,8 @@
public:
PCTable(int assoc, int sets, const std::string name) :
pcTableAssoc(assoc), pcTableSets(sets), _name(name) {}
- StrideEntry** operator[] (int context) {
+
+ std::vector<std::vector<StrideEntry>>& operator[] (int context) {
auto it = entries.find(context);
if (it != entries.end())
return it->second;
@@ -104,9 +106,9 @@
const int pcTableAssoc;
const int pcTableSets;
const std::string _name;
- std::unordered_map<int, StrideEntry**> entries;
+ std::unordered_map<int, std::vector<std::vector<StrideEntry>>>
entries;
- StrideEntry** allocateNewContext(int context);
+ std::vector<std::vector<StrideEntry>>& allocateNewContext(int
context);
};
PCTable pcTable;
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/14357
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I2a4589a76eb205910c43723638b7989eddd5ca24
Gerrit-Change-Number: 14357
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev