summaryrefslogtreecommitdiff
path: root/src/mem/cache/prefetch/stride.cc
diff options
context:
space:
mode:
authorStephan Diestelhorst <stephan.diestelhorst@arm.com>2015-03-27 04:56:03 -0400
committerStephan Diestelhorst <stephan.diestelhorst@arm.com>2015-03-27 04:56:03 -0400
commitcb8856f58059df962652243a9a9c7549571d79fa (patch)
tree617812866f12e8b0d89d27c00754689d22e355d3 /src/mem/cache/prefetch/stride.cc
parent0197e580e5761cba7c1f643aa9d85d5465964106 (diff)
downloadgem5-cb8856f58059df962652243a9a9c7549571d79fa.tar.xz
mem: Support any number of master-IDs in stride prefetcher
The stride prefetcher had a hardcoded number of contexts (i.e. master-IDs) that it could handle. Since master IDs need to be unique per system, and every core, cache etc. requires a separate master port, a static limit on these does not make much sense. Instead, this patch adds a small hash map that will map all master IDs to the right prefetch state and dynamically allocates new state for new master IDs.
Diffstat (limited to 'src/mem/cache/prefetch/stride.cc')
-rw-r--r--src/mem/cache/prefetch/stride.cc37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/mem/cache/prefetch/stride.cc b/src/mem/cache/prefetch/stride.cc
index 74c84b94f..bcd72f25a 100644
--- a/src/mem/cache/prefetch/stride.cc
+++ b/src/mem/cache/prefetch/stride.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2013 ARM Limited
+ * Copyright (c) 2012-2013, 2015 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -59,27 +59,40 @@ StridePrefetcher::StridePrefetcher(const StridePrefetcherParams *p)
pcTableAssoc(p->table_assoc),
pcTableSets(p->table_sets),
useMasterId(p->use_master_id),
- degree(p->degree)
+ degree(p->degree),
+ pcTable(pcTableAssoc, pcTableSets, name())
{
// Don't consult stride prefetcher on instruction accesses
onInst = false;
assert(isPowerOf2(pcTableSets));
+}
- for (int c = 0; c < maxContexts; c++) {
- pcTable[c] = new StrideEntry*[pcTableSets];
- for (int s = 0; s < pcTableSets; s++) {
- pcTable[c][s] = new StrideEntry[pcTableAssoc];
- }
+StridePrefetcher::StrideEntry**
+StridePrefetcher::PCTable::allocateNewContext(int context)
+{
+ auto res = entries.insert(std::make_pair(context,
+ new 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);
+
+ StrideEntry** entry = it->second;
+ for (int s = 0; s < pcTableSets; s++) {
+ entry[s] = new StrideEntry[pcTableAssoc];
}
+ return entry;
}
-StridePrefetcher::~StridePrefetcher()
-{
- for (int c = 0; c < maxContexts; c++) {
+StridePrefetcher::PCTable::~PCTable() {
+ for (auto entry : entries) {
for (int s = 0; s < pcTableSets; s++) {
- delete[] pcTable[c][s];
+ delete[] entry.second[s];
}
+ delete[] entry.second;
}
}
@@ -98,8 +111,6 @@ StridePrefetcher::calculatePrefetch(const PacketPtr &pkt,
bool is_secure = pkt->isSecure();
MasterID master_id = useMasterId ? pkt->req->masterId() : 0;
- assert(master_id < maxContexts);
-
// Lookup pc-based information
StrideEntry *entry;