From d7a1db5cc44ad9a1bd5742f9fc4ffa5ea2e3b2f4 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 11 Nov 2018 17:56:08 +0100 Subject: mem-cache: Add invalidation function to StrideEntry Add invalidation function to StrideEntry so that every entry can be invalidated appropriately. Change-Id: I38c42b7d7c93d839f797d116f1d2c88572123c0e Signed-off-by: Daniel Reviewed-on: https://gem5-review.googlesource.com/c/14359 Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris --- src/mem/cache/prefetch/stride.cc | 21 ++++++++++++++++++++- src/mem/cache/prefetch/stride.hh | 8 +++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/mem/cache/prefetch/stride.cc b/src/mem/cache/prefetch/stride.cc index c09facef0..4520f12c2 100644 --- a/src/mem/cache/prefetch/stride.cc +++ b/src/mem/cache/prefetch/stride.cc @@ -57,6 +57,21 @@ #include "debug/HWPrefetch.hh" #include "params/StridePrefetcher.hh" +StridePrefetcher::StrideEntry::StrideEntry() +{ + invalidate(); +} + +void +StridePrefetcher::StrideEntry::invalidate() +{ + instAddr = 0; + lastAddr = 0; + isSecure = false; + stride = 0; + confidence = 0; +} + StridePrefetcher::StridePrefetcher(const StridePrefetcherParams *p) : QueuedPrefetcher(p), maxConf(p->max_conf), @@ -182,10 +197,14 @@ StridePrefetcher::calculatePrefetch(const PacketPtr &pkt, is_secure ? "s" : "ns"); StrideEntry* entry = pcTable->findVictim(pc); + + // Invalidate victim + entry->invalidate(); + + // Insert new entry's data entry->instAddr = pc; entry->lastAddr = pkt_addr; entry->isSecure= is_secure; - entry->stride = 0; entry->confidence = startConf; } } diff --git a/src/mem/cache/prefetch/stride.hh b/src/mem/cache/prefetch/stride.hh index ec22ca63f..772c3a511 100644 --- a/src/mem/cache/prefetch/stride.hh +++ b/src/mem/cache/prefetch/stride.hh @@ -75,9 +75,11 @@ class StridePrefetcher : public QueuedPrefetcher struct StrideEntry { - StrideEntry() : instAddr(0), lastAddr(0), isSecure(false), stride(0), - confidence(0) - { } + /** Default constructor */ + StrideEntry(); + + /** Invalidate the entry */ + void invalidate(); Addr instAddr; Addr lastAddr; -- cgit v1.2.3