summaryrefslogtreecommitdiff
path: root/src/mem/cache/prefetch/base.cc
diff options
context:
space:
mode:
authorRekai Gonzalez Alberquilla <Rekai.GonzalezAlberquilla@arm.com>2016-04-07 11:32:38 -0500
committerRekai Gonzalez Alberquilla <Rekai.GonzalezAlberquilla@arm.com>2016-04-07 11:32:38 -0500
commitdad7d9277b571305ee248cd761a7dbb9400b3681 (patch)
tree4d4127f796ca0b12b04e113b1a841e7055d48bf1 /src/mem/cache/prefetch/base.cc
parentdf5a81183303fa941d71e866ff8d258e4d6a510e (diff)
downloadgem5-dad7d9277b571305ee248cd761a7dbb9400b3681.tar.xz
mem: Handful extra features for BasePrefetcher
Some common functionality added to the base prefetcher, mainly dealing with extracting the block address, page address, block index inside the page and some other information that can be inferred from the block address. This is used for some prefetching algorithms, and having the methods in the base, as well as the block size and other information is the sensible way.
Diffstat (limited to 'src/mem/cache/prefetch/base.cc')
-rw-r--r--src/mem/cache/prefetch/base.cc35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/mem/cache/prefetch/base.cc b/src/mem/cache/prefetch/base.cc
index de4eaca01..0b296144c 100644
--- a/src/mem/cache/prefetch/base.cc
+++ b/src/mem/cache/prefetch/base.cc
@@ -48,13 +48,14 @@
#include <list>
+#include "base/intmath.hh"
#include "mem/cache/prefetch/base.hh"
#include "mem/cache/base.hh"
#include "sim/system.hh"
BasePrefetcher::BasePrefetcher(const BasePrefetcherParams *p)
- : ClockedObject(p), cache(nullptr), blkSize(0), system(p->sys),
- onMiss(p->on_miss), onRead(p->on_read),
+ : ClockedObject(p), cache(nullptr), blkSize(0), lBlkSize(0),
+ system(p->sys), onMiss(p->on_miss), onRead(p->on_read),
onWrite(p->on_write), onData(p->on_data), onInst(p->on_inst),
masterId(system->getMasterId(name())),
pageBytes(system->getPageBytes())
@@ -67,6 +68,7 @@ BasePrefetcher::setCache(BaseCache *_cache)
assert(!cache);
cache = _cache;
blkSize = cache->getBlockSize();
+ lBlkSize = floorLog2(blkSize);
}
void
@@ -76,6 +78,7 @@ BasePrefetcher::regStats()
.name(name() + ".num_hwpf_issued")
.desc("number of hwpf issued")
;
+
}
bool
@@ -127,4 +130,32 @@ BasePrefetcher::samePage(Addr a, Addr b) const
return roundDown(a, pageBytes) == roundDown(b, pageBytes);
}
+Addr
+BasePrefetcher::blockAddress(Addr a) const
+{
+ return a & ~(blkSize-1);
+}
+
+Addr
+BasePrefetcher::blockIndex(Addr a) const
+{
+ return a >> lBlkSize;
+}
+
+Addr
+BasePrefetcher::pageAddress(Addr a) const
+{
+ return roundDown(a, pageBytes);
+}
+Addr
+BasePrefetcher::pageOffset(Addr a) const
+{
+ return a & (pageBytes - 1);
+}
+
+Addr
+BasePrefetcher::pageIthBlockAddress(Addr page, uint32_t blockIndex) const
+{
+ return page + (blockIndex << lBlkSize);
+}