From 0be2496dd5aedeeca98d1273d39c5e4bb935a254 Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Sun, 29 Dec 2019 00:45:44 +0100 Subject: [PATCH] mem-cache: Create Prefetcher namespace Create a namespace for the Prefetcher classes. As a side effect the Prefetcher suffix has been removed from the C++'s classes names, and the memory leaking destructor overrides have been fixed. Change-Id: I9bae492d2fd4734bcdfb68c164345898e65102b2 Signed-off-by: Daniel R. Carvalho Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24537 Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris Tested-by: kokoro --- src/mem/cache/base.hh | 6 +- src/mem/cache/prefetch/Prefetcher.py | 35 +++++------ .../prefetch/access_map_pattern_matching.cc | 35 ++++++----- .../prefetch/access_map_pattern_matching.hh | 24 ++++---- src/mem/cache/prefetch/base.cc | 44 +++++++------- src/mem/cache/prefetch/base.hh | 17 +++--- src/mem/cache/prefetch/bop.cc | 32 +++++----- src/mem/cache/prefetch/bop.hh | 10 +++- .../delta_correlating_prediction_tables.cc | 34 ++++++----- .../delta_correlating_prediction_tables.hh | 25 ++++---- src/mem/cache/prefetch/indirect_memory.cc | 22 ++++--- src/mem/cache/prefetch/indirect_memory.hh | 11 +++- .../cache/prefetch/irregular_stream_buffer.cc | 58 ++++++++++--------- .../cache/prefetch/irregular_stream_buffer.hh | 13 +++-- src/mem/cache/prefetch/multi.cc | 19 +++--- src/mem/cache/prefetch/multi.hh | 12 ++-- src/mem/cache/prefetch/pif.cc | 30 +++++----- src/mem/cache/prefetch/pif.hh | 14 +++-- src/mem/cache/prefetch/queued.cc | 38 ++++++------ src/mem/cache/prefetch/queued.hh | 14 +++-- src/mem/cache/prefetch/sbooe.cc | 20 ++++--- src/mem/cache/prefetch/sbooe.hh | 8 ++- src/mem/cache/prefetch/signature_path.cc | 41 +++++++------ src/mem/cache/prefetch/signature_path.hh | 11 +++- src/mem/cache/prefetch/signature_path_v2.cc | 23 ++++---- src/mem/cache/prefetch/signature_path_v2.hh | 10 +++- src/mem/cache/prefetch/slim_ampm.cc | 14 +++-- src/mem/cache/prefetch/slim_ampm.hh | 12 ++-- .../spatio_temporal_memory_streaming.cc | 21 ++++--- .../spatio_temporal_memory_streaming.hh | 11 +++- src/mem/cache/prefetch/stride.cc | 40 +++++++------ src/mem/cache/prefetch/stride.hh | 8 ++- src/mem/cache/prefetch/tagged.cc | 16 +++-- src/mem/cache/prefetch/tagged.hh | 11 ++-- 34 files changed, 434 insertions(+), 305 deletions(-) diff --git a/src/mem/cache/base.hh b/src/mem/cache/base.hh index e77bfe0d0..3efc7c7ed 100644 --- a/src/mem/cache/base.hh +++ b/src/mem/cache/base.hh @@ -75,7 +75,9 @@ #include "sim/sim_exit.hh" #include "sim/system.hh" -class BasePrefetcher; +namespace Prefetcher { + class Base; +} class MSHR; class MasterPort; class QueueEntry; @@ -321,7 +323,7 @@ class BaseCache : public ClockedObject BaseCacheCompressor* compressor; /** Prefetcher */ - BasePrefetcher *prefetcher; + Prefetcher::Base *prefetcher; /** To probe when a cache hit occurs */ ProbePointArg *ppHit; diff --git a/src/mem/cache/prefetch/Prefetcher.py b/src/mem/cache/prefetch/Prefetcher.py index 33eb1ea6f..8cfefe1af 100644 --- a/src/mem/cache/prefetch/Prefetcher.py +++ b/src/mem/cache/prefetch/Prefetcher.py @@ -59,6 +59,7 @@ class HWPProbeEvent(object): class BasePrefetcher(ClockedObject): type = 'BasePrefetcher' abstract = True + cxx_class = 'Prefetcher::Base' cxx_header = "mem/cache/prefetch/base.hh" cxx_exports = [ PyBindMethod("addEventProbe"), @@ -106,7 +107,7 @@ class BasePrefetcher(ClockedObject): class MultiPrefetcher(BasePrefetcher): type = 'MultiPrefetcher' - cxx_class = 'MultiPrefetcher' + cxx_class = 'Prefetcher::Multi' cxx_header = 'mem/cache/prefetch/multi.hh' prefetchers = VectorParam.BasePrefetcher([], "Array of prefetchers") @@ -114,7 +115,7 @@ class MultiPrefetcher(BasePrefetcher): class QueuedPrefetcher(BasePrefetcher): type = "QueuedPrefetcher" abstract = True - cxx_class = "QueuedPrefetcher" + cxx_class = "Prefetcher::Queued" cxx_header = "mem/cache/prefetch/queued.hh" latency = Param.Int(1, "Latency for generated prefetches") queue_size = Param.Int(32, "Maximum number of queued prefetches") @@ -140,7 +141,7 @@ class QueuedPrefetcher(BasePrefetcher): class StridePrefetcher(QueuedPrefetcher): type = 'StridePrefetcher' - cxx_class = 'StridePrefetcher' + cxx_class = 'Prefetcher::Stride' cxx_header = "mem/cache/prefetch/stride.hh" # Do not consult stride prefetcher on instruction accesses @@ -163,14 +164,14 @@ class StridePrefetcher(QueuedPrefetcher): class TaggedPrefetcher(QueuedPrefetcher): type = 'TaggedPrefetcher' - cxx_class = 'TaggedPrefetcher' + cxx_class = 'Prefetcher::Tagged' cxx_header = "mem/cache/prefetch/tagged.hh" degree = Param.Int(2, "Number of prefetches to generate") class IndirectMemoryPrefetcher(QueuedPrefetcher): type = 'IndirectMemoryPrefetcher' - cxx_class = 'IndirectMemoryPrefetcher' + cxx_class = 'Prefetcher::IndirectMemory' cxx_header = "mem/cache/prefetch/indirect_memory.hh" pt_table_entries = Param.MemorySize("16", "Number of entries of the Prefetch Table") @@ -205,7 +206,7 @@ class IndirectMemoryPrefetcher(QueuedPrefetcher): class SignaturePathPrefetcher(QueuedPrefetcher): type = 'SignaturePathPrefetcher' - cxx_class = 'SignaturePathPrefetcher' + cxx_class = 'Prefetcher::SignaturePath' cxx_header = "mem/cache/prefetch/signature_path.hh" signature_shift = Param.UInt8(3, @@ -245,7 +246,7 @@ class SignaturePathPrefetcher(QueuedPrefetcher): class SignaturePathPrefetcherV2(SignaturePathPrefetcher): type = 'SignaturePathPrefetcherV2' - cxx_class = 'SignaturePathPrefetcherV2' + cxx_class = 'Prefetcher::SignaturePathV2' cxx_header = "mem/cache/prefetch/signature_path_v2.hh" signature_table_entries = "256" @@ -268,7 +269,7 @@ class SignaturePathPrefetcherV2(SignaturePathPrefetcher): class AccessMapPatternMatching(ClockedObject): type = 'AccessMapPatternMatching' - cxx_class = 'AccessMapPatternMatching' + cxx_class = 'Prefetcher::AccessMapPatternMatching' cxx_header = "mem/cache/prefetch/access_map_pattern_matching.hh" block_size = Param.Unsigned(Parent.block_size, @@ -307,14 +308,14 @@ class AccessMapPatternMatching(ClockedObject): class AMPMPrefetcher(QueuedPrefetcher): type = 'AMPMPrefetcher' - cxx_class = 'AMPMPrefetcher' + cxx_class = 'Prefetcher::AMPM' cxx_header = "mem/cache/prefetch/access_map_pattern_matching.hh" ampm = Param.AccessMapPatternMatching( AccessMapPatternMatching(), "Access Map Pattern Matching object") class DeltaCorrelatingPredictionTables(SimObject): type = 'DeltaCorrelatingPredictionTables' - cxx_class = 'DeltaCorrelatingPredictionTables' + cxx_class = 'Prefetcher::DeltaCorrelatingPredictionTables' cxx_header = "mem/cache/prefetch/delta_correlating_prediction_tables.hh" deltas_per_entry = Param.Unsigned(20, "Number of deltas stored in each table entry") @@ -334,7 +335,7 @@ class DeltaCorrelatingPredictionTables(SimObject): class DCPTPrefetcher(QueuedPrefetcher): type = 'DCPTPrefetcher' - cxx_class = 'DCPTPrefetcher' + cxx_class = 'Prefetcher::DCPT' cxx_header = "mem/cache/prefetch/delta_correlating_prediction_tables.hh" dcpt = Param.DeltaCorrelatingPredictionTables( DeltaCorrelatingPredictionTables(), @@ -342,7 +343,7 @@ class DCPTPrefetcher(QueuedPrefetcher): class IrregularStreamBufferPrefetcher(QueuedPrefetcher): type = "IrregularStreamBufferPrefetcher" - cxx_class = "IrregularStreamBufferPrefetcher" + cxx_class = "Prefetcher::IrregularStreamBuffer" cxx_header = "mem/cache/prefetch/irregular_stream_buffer.hh" num_counter_bits = Param.Unsigned(2, @@ -395,7 +396,7 @@ class SlimDeltaCorrelatingPredictionTables(DeltaCorrelatingPredictionTables): class SlimAMPMPrefetcher(QueuedPrefetcher): type = 'SlimAMPMPrefetcher' - cxx_class = 'SlimAMPMPrefetcher' + cxx_class = 'Prefetcher::SlimAMPM' cxx_header = "mem/cache/prefetch/slim_ampm.hh" ampm = Param.AccessMapPatternMatching(SlimAccessMapPatternMatching(), @@ -406,7 +407,7 @@ class SlimAMPMPrefetcher(QueuedPrefetcher): class BOPPrefetcher(QueuedPrefetcher): type = "BOPPrefetcher" - cxx_class = "BOPPrefetcher" + cxx_class = "Prefetcher::BOP" cxx_header = "mem/cache/prefetch/bop.hh" score_max = Param.Unsigned(31, "Max. score to update the best offset") round_max = Param.Unsigned(100, "Max. round to update the best offset") @@ -428,7 +429,7 @@ class BOPPrefetcher(QueuedPrefetcher): class SBOOEPrefetcher(QueuedPrefetcher): type = 'SBOOEPrefetcher' - cxx_class = 'SBOOEPrefetcher' + cxx_class = 'Prefetcher::SBOOE' cxx_header = "mem/cache/prefetch/sbooe.hh" latency_buffer_size = Param.Int(32, "Entries in the latency buffer") sequential_prefetchers = Param.Int(9, "Number of sequential prefetchers") @@ -438,7 +439,7 @@ class SBOOEPrefetcher(QueuedPrefetcher): class STeMSPrefetcher(QueuedPrefetcher): type = "STeMSPrefetcher" - cxx_class = "STeMSPrefetcher" + cxx_class = "Prefetcher::STeMS" cxx_header = "mem/cache/prefetch/spatio_temporal_memory_streaming.hh" spatial_region_size = Param.MemorySize("2kB", @@ -481,7 +482,7 @@ class HWPProbeEventRetiredInsts(HWPProbeEvent): class PIFPrefetcher(QueuedPrefetcher): type = 'PIFPrefetcher' - cxx_class = 'PIFPrefetcher' + cxx_class = 'Prefetcher::PIF' cxx_header = "mem/cache/prefetch/pif.hh" cxx_exports = [ PyBindMethod("addEventProbeRetiredInsts"), diff --git a/src/mem/cache/prefetch/access_map_pattern_matching.cc b/src/mem/cache/prefetch/access_map_pattern_matching.cc index 4d4acd6a4..28371c789 100644 --- a/src/mem/cache/prefetch/access_map_pattern_matching.cc +++ b/src/mem/cache/prefetch/access_map_pattern_matching.cc @@ -33,6 +33,8 @@ #include "params/AMPMPrefetcher.hh" #include "params/AccessMapPatternMatching.hh" +namespace Prefetcher { + AccessMapPatternMatching::AccessMapPatternMatching( const AccessMapPatternMatchingParams *p) : ClockedObject(p), blkSize(p->block_size), limitStride(p->limit_stride), @@ -149,9 +151,8 @@ AccessMapPatternMatching::setEntryState(AccessMapEntry &entry, } void -AccessMapPatternMatching::calculatePrefetch( - const BasePrefetcher::PrefetchInfo &pfi, - std::vector &addresses) +AccessMapPatternMatching::calculatePrefetch(const Base::PrefetchInfo &pfi, + std::vector &addresses) { assert(addresses.empty()); @@ -218,7 +219,7 @@ AccessMapPatternMatching::calculatePrefetch( pf_addr = am_addr * hotZoneSize + blk * blkSize; setEntryState(*am_entry_curr, blk, AM_PREFETCH); } - addresses.push_back(QueuedPrefetcher::AddrPriority(pf_addr, 0)); + addresses.push_back(Queued::AddrPriority(pf_addr, 0)); if (addresses.size() == degree) { break; } @@ -242,7 +243,7 @@ AccessMapPatternMatching::calculatePrefetch( pf_addr = am_addr * hotZoneSize + blk * blkSize; setEntryState(*am_entry_curr, blk, AM_PREFETCH); } - addresses.push_back(QueuedPrefetcher::AddrPriority(pf_addr, 0)); + addresses.push_back(Queued::AddrPriority(pf_addr, 0)); if (addresses.size() == degree) { break; } @@ -250,26 +251,28 @@ AccessMapPatternMatching::calculatePrefetch( } } -AccessMapPatternMatching* -AccessMapPatternMatchingParams::create() -{ - return new AccessMapPatternMatching(this); -} - -AMPMPrefetcher::AMPMPrefetcher(const AMPMPrefetcherParams *p) - : QueuedPrefetcher(p), ampm(*p->ampm) +AMPM::AMPM(const AMPMPrefetcherParams *p) + : Queued(p), ampm(*p->ampm) { } void -AMPMPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, +AMPM::calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) { ampm.calculatePrefetch(pfi, addresses); } -AMPMPrefetcher* +} // namespace Prefetcher + +Prefetcher::AccessMapPatternMatching* +AccessMapPatternMatchingParams::create() +{ + return new Prefetcher::AccessMapPatternMatching(this); +} + +Prefetcher::AMPM* AMPMPrefetcherParams::create() { - return new AMPMPrefetcher(this); + return new Prefetcher::AMPM(this); } diff --git a/src/mem/cache/prefetch/access_map_pattern_matching.hh b/src/mem/cache/prefetch/access_map_pattern_matching.hh index abc15031b..0064917af 100644 --- a/src/mem/cache/prefetch/access_map_pattern_matching.hh +++ b/src/mem/cache/prefetch/access_map_pattern_matching.hh @@ -44,6 +44,9 @@ #include "sim/clocked_object.hh" struct AccessMapPatternMatchingParams; +struct AMPMPrefetcherParams; + +namespace Prefetcher { class AccessMapPatternMatching : public ClockedObject { @@ -179,23 +182,24 @@ class AccessMapPatternMatching : public ClockedObject public: AccessMapPatternMatching(const AccessMapPatternMatchingParams* p); - ~AccessMapPatternMatching() - {} + ~AccessMapPatternMatching() = default; + void startup() override; - void calculatePrefetch(const BasePrefetcher::PrefetchInfo &pfi, - std::vector &addresses); + void calculatePrefetch(const Base::PrefetchInfo &pfi, + std::vector &addresses); }; -struct AMPMPrefetcherParams; - -class AMPMPrefetcher : public QueuedPrefetcher +class AMPM : public Queued { AccessMapPatternMatching &m; public: - AMPMPrefetcher(const AMPMPrefetcherParams* p); - ~AMPMPrefetcher() - {} + AMPM(const AMPMPrefetcherParams* p); + ~AMPM() = default; + void calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) override; }; + +} // namespace Prefetcher + #endif//__MEM_CACHE_PREFETCH_ACCESS_MAP_PATTERN_MATCHING_HH__ diff --git a/src/mem/cache/prefetch/base.cc b/src/mem/cache/prefetch/base.cc index f57409269..d4223aacd 100644 --- a/src/mem/cache/prefetch/base.cc +++ b/src/mem/cache/prefetch/base.cc @@ -53,7 +53,9 @@ #include "params/BasePrefetcher.hh" #include "sim/system.hh" -BasePrefetcher::PrefetchInfo::PrefetchInfo(PacketPtr pkt, Addr addr, bool miss) +namespace Prefetcher { + +Base::PrefetchInfo::PrefetchInfo(PacketPtr pkt, Addr addr, bool miss) : address(addr), pc(pkt->req->hasPC() ? pkt->req->getPC() : 0), masterId(pkt->req->masterId()), validPC(pkt->req->hasPC()), secure(pkt->isSecure()), size(pkt->req->getSize()), write(pkt->isWrite()), @@ -69,7 +71,7 @@ BasePrefetcher::PrefetchInfo::PrefetchInfo(PacketPtr pkt, Addr addr, bool miss) } } -BasePrefetcher::PrefetchInfo::PrefetchInfo(PrefetchInfo const &pfi, Addr addr) +Base::PrefetchInfo::PrefetchInfo(PrefetchInfo const &pfi, Addr addr) : address(addr), pc(pfi.pc), masterId(pfi.masterId), validPC(pfi.validPC), secure(pfi.secure), size(pfi.size), write(pfi.write), paddress(pfi.paddress), cacheMiss(pfi.cacheMiss), data(nullptr) @@ -77,7 +79,7 @@ BasePrefetcher::PrefetchInfo::PrefetchInfo(PrefetchInfo const &pfi, Addr addr) } void -BasePrefetcher::PrefetchListener::notify(const PacketPtr &pkt) +Base::PrefetchListener::notify(const PacketPtr &pkt) { if (isFill) { parent.notifyFill(pkt); @@ -86,7 +88,7 @@ BasePrefetcher::PrefetchListener::notify(const PacketPtr &pkt) } } -BasePrefetcher::BasePrefetcher(const BasePrefetcherParams *p) +Base::Base(const BasePrefetcherParams *p) : ClockedObject(p), listeners(), cache(nullptr), blkSize(p->block_size), lBlkSize(floorLog2(blkSize)), onMiss(p->on_miss), onRead(p->on_read), onWrite(p->on_write), onData(p->on_data), onInst(p->on_inst), @@ -98,7 +100,7 @@ BasePrefetcher::BasePrefetcher(const BasePrefetcherParams *p) } void -BasePrefetcher::setCache(BaseCache *_cache) +Base::setCache(BaseCache *_cache) { assert(!cache); cache = _cache; @@ -109,7 +111,7 @@ BasePrefetcher::setCache(BaseCache *_cache) } void -BasePrefetcher::regStats() +Base::regStats() { ClockedObject::regStats(); @@ -121,7 +123,7 @@ BasePrefetcher::regStats() } bool -BasePrefetcher::observeAccess(const PacketPtr &pkt, bool miss) const +Base::observeAccess(const PacketPtr &pkt, bool miss) const { bool fetch = pkt->req->isInstFetch(); bool read = pkt->isRead(); @@ -143,61 +145,61 @@ BasePrefetcher::observeAccess(const PacketPtr &pkt, bool miss) const } bool -BasePrefetcher::inCache(Addr addr, bool is_secure) const +Base::inCache(Addr addr, bool is_secure) const { return cache->inCache(addr, is_secure); } bool -BasePrefetcher::inMissQueue(Addr addr, bool is_secure) const +Base::inMissQueue(Addr addr, bool is_secure) const { return cache->inMissQueue(addr, is_secure); } bool -BasePrefetcher::hasBeenPrefetched(Addr addr, bool is_secure) const +Base::hasBeenPrefetched(Addr addr, bool is_secure) const { return cache->hasBeenPrefetched(addr, is_secure); } bool -BasePrefetcher::samePage(Addr a, Addr b) const +Base::samePage(Addr a, Addr b) const { return roundDown(a, pageBytes) == roundDown(b, pageBytes); } Addr -BasePrefetcher::blockAddress(Addr a) const +Base::blockAddress(Addr a) const { return a & ~((Addr)blkSize-1); } Addr -BasePrefetcher::blockIndex(Addr a) const +Base::blockIndex(Addr a) const { return a >> lBlkSize; } Addr -BasePrefetcher::pageAddress(Addr a) const +Base::pageAddress(Addr a) const { return roundDown(a, pageBytes); } Addr -BasePrefetcher::pageOffset(Addr a) const +Base::pageOffset(Addr a) const { return a & (pageBytes - 1); } Addr -BasePrefetcher::pageIthBlockAddress(Addr page, uint32_t blockIndex) const +Base::pageIthBlockAddress(Addr page, uint32_t blockIndex) const { return page + (blockIndex << lBlkSize); } void -BasePrefetcher::probeNotify(const PacketPtr &pkt, bool miss) +Base::probeNotify(const PacketPtr &pkt, bool miss) { // Don't notify prefetcher on SWPrefetch, cache maintenance // operations or for writes that we are coaslescing. @@ -225,7 +227,7 @@ BasePrefetcher::probeNotify(const PacketPtr &pkt, bool miss) } void -BasePrefetcher::regProbeListeners() +Base::regProbeListeners() { /** * If no probes were added by the configuration scripts, connect to the @@ -246,15 +248,17 @@ BasePrefetcher::regProbeListeners() } void -BasePrefetcher::addEventProbe(SimObject *obj, const char *name) +Base::addEventProbe(SimObject *obj, const char *name) { ProbeManager *pm(obj->getProbeManager()); listeners.push_back(new PrefetchListener(*this, pm, name)); } void -BasePrefetcher::addTLB(BaseTLB *t) +Base::addTLB(BaseTLB *t) { fatal_if(tlb != nullptr, "Only one TLB can be registered"); tlb = t; } + +} // namespace Prefetcher diff --git a/src/mem/cache/prefetch/base.hh b/src/mem/cache/prefetch/base.hh index ebe97c36b..7009db76e 100644 --- a/src/mem/cache/prefetch/base.hh +++ b/src/mem/cache/prefetch/base.hh @@ -61,19 +61,21 @@ class BaseCache; struct BasePrefetcherParams; -class BasePrefetcher : public ClockedObject +namespace Prefetcher { + +class Base : public ClockedObject { class PrefetchListener : public ProbeListenerArgBase { public: - PrefetchListener(BasePrefetcher &_parent, ProbeManager *pm, + PrefetchListener(Base &_parent, ProbeManager *pm, const std::string &name, bool _isFill = false, bool _miss = false) : ProbeListenerArgBase(pm, name), parent(_parent), isFill(_isFill), miss(_miss) {} void notify(const PacketPtr &pkt) override; protected: - BasePrefetcher &parent; + Base &parent; const bool isFill; const bool miss; }; @@ -328,10 +330,8 @@ class BasePrefetcher : public ClockedObject BaseTLB * tlb; public: - - BasePrefetcher(const BasePrefetcherParams *p); - - virtual ~BasePrefetcher() {} + Base(const BasePrefetcherParams *p); + virtual ~Base() = default; virtual void setCache(BaseCache *_cache); @@ -381,4 +381,7 @@ class BasePrefetcher : public ClockedObject */ void addTLB(BaseTLB *tlb); }; + +} // namespace Prefetcher + #endif //__MEM_CACHE_PREFETCH_BASE_HH__ diff --git a/src/mem/cache/prefetch/bop.cc b/src/mem/cache/prefetch/bop.cc index 3881c7376..83eeda1c4 100644 --- a/src/mem/cache/prefetch/bop.cc +++ b/src/mem/cache/prefetch/bop.cc @@ -31,8 +31,10 @@ #include "debug/HWPrefetch.hh" #include "params/BOPPrefetcher.hh" -BOPPrefetcher::BOPPrefetcher(const BOPPrefetcherParams *p) - : QueuedPrefetcher(p), +namespace Prefetcher { + +BOP::BOP(const BOPPrefetcherParams *p) + : Queued(p), scoreMax(p->score_max), roundMax(p->round_max), badScore(p->bad_score), rrEntries(p->rr_size), tagMask((1 << p->tag_bits) - 1), @@ -91,7 +93,7 @@ BOPPrefetcher::BOPPrefetcher(const BOPPrefetcherParams *p) } void -BOPPrefetcher::delayQueueEventWrapper() +BOP::delayQueueEventWrapper() { while (!delayQueue.empty() && delayQueue.front().processTick <= curTick()) @@ -108,7 +110,7 @@ BOPPrefetcher::delayQueueEventWrapper() } unsigned int -BOPPrefetcher::hash(Addr addr, unsigned int way) const +BOP::hash(Addr addr, unsigned int way) const { Addr hash1 = addr >> way; Addr hash2 = hash1 >> floorLog2(rrEntries); @@ -116,7 +118,7 @@ BOPPrefetcher::hash(Addr addr, unsigned int way) const } void -BOPPrefetcher::insertIntoRR(Addr addr, unsigned int way) +BOP::insertIntoRR(Addr addr, unsigned int way) { switch (way) { case RRWay::Left: @@ -129,7 +131,7 @@ BOPPrefetcher::insertIntoRR(Addr addr, unsigned int way) } void -BOPPrefetcher::insertIntoDelayQueue(Addr x) +BOP::insertIntoDelayQueue(Addr x) { if (delayQueue.size() == delayQueueSize) { return; @@ -147,7 +149,7 @@ BOPPrefetcher::insertIntoDelayQueue(Addr x) } void -BOPPrefetcher::resetScores() +BOP::resetScores() { for (auto& it : offsetsList) { it.second = 0; @@ -155,13 +157,13 @@ BOPPrefetcher::resetScores() } inline Addr -BOPPrefetcher::tag(Addr addr) const +BOP::tag(Addr addr) const { return (addr >> blkSize) & tagMask; } bool -BOPPrefetcher::testRR(Addr addr) const +BOP::testRR(Addr addr) const { for (auto& it : rrLeft) { if (it == addr) { @@ -179,7 +181,7 @@ BOPPrefetcher::testRR(Addr addr) const } void -BOPPrefetcher::bestOffsetLearning(Addr x) +BOP::bestOffsetLearning(Addr x) { Addr offset_addr = (*offsetsListIterator).first; Addr lookup_addr = x - offset_addr; @@ -220,7 +222,7 @@ BOPPrefetcher::bestOffsetLearning(Addr x) } void -BOPPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, +BOP::calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) { Addr addr = pfi.getAddr(); @@ -246,7 +248,7 @@ BOPPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, } void -BOPPrefetcher::notifyFill(const PacketPtr& pkt) +BOP::notifyFill(const PacketPtr& pkt) { // Only insert into the RR right way if it's the pkt is a HWP if (!pkt->cmd.isHWPrefetch()) return; @@ -258,8 +260,10 @@ BOPPrefetcher::notifyFill(const PacketPtr& pkt) } } -BOPPrefetcher* +} // namespace Prefetcher + +Prefetcher::BOP* BOPPrefetcherParams::create() { - return new BOPPrefetcher(this); + return new Prefetcher::BOP(this); } diff --git a/src/mem/cache/prefetch/bop.hh b/src/mem/cache/prefetch/bop.hh index a784bf038..d4252af1a 100644 --- a/src/mem/cache/prefetch/bop.hh +++ b/src/mem/cache/prefetch/bop.hh @@ -43,7 +43,9 @@ struct BOPPrefetcherParams; -class BOPPrefetcher : public QueuedPrefetcher +namespace Prefetcher { + +class BOP : public Queued { private: @@ -145,11 +147,13 @@ class BOPPrefetcher : public QueuedPrefetcher public: - BOPPrefetcher(const BOPPrefetcherParams *p); - ~BOPPrefetcher() {} + BOP(const BOPPrefetcherParams *p); + ~BOP() = default; void calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) override; }; +} // namespace Prefetcher + #endif /* __MEM_CACHE_PREFETCH_BOP_HH__ */ diff --git a/src/mem/cache/prefetch/delta_correlating_prediction_tables.cc b/src/mem/cache/prefetch/delta_correlating_prediction_tables.cc index 505cbc763..ba9d22f0e 100644 --- a/src/mem/cache/prefetch/delta_correlating_prediction_tables.cc +++ b/src/mem/cache/prefetch/delta_correlating_prediction_tables.cc @@ -33,6 +33,8 @@ #include "params/DCPTPrefetcher.hh" #include "params/DeltaCorrelatingPredictionTables.hh" +namespace Prefetcher { + DeltaCorrelatingPredictionTables::DeltaCorrelatingPredictionTables( DeltaCorrelatingPredictionTablesParams *p) : SimObject(p), deltaBits(p->delta_bits), deltaMaskBits(p->delta_mask_bits), @@ -80,7 +82,7 @@ DeltaCorrelatingPredictionTables::DCPTEntry::addAddress(Addr address, void DeltaCorrelatingPredictionTables::DCPTEntry::getCandidates( - std::vector &pfs, unsigned int mask) const + std::vector &pfs, unsigned int mask) const { // most recent index unsigned int last = (deltaPointer - 1) % deltas.size(); @@ -115,7 +117,7 @@ DeltaCorrelatingPredictionTables::DCPTEntry::getCandidates( do { int pf_delta = deltas[(idx_0 + i) % deltas.size()]; addr += pf_delta; - pfs.push_back(QueuedPrefetcher::AddrPriority(addr, 0)); + pfs.push_back(Queued::AddrPriority(addr, 0)); i += 1; } while (i < deltas.size() - 2); } @@ -124,8 +126,8 @@ DeltaCorrelatingPredictionTables::DCPTEntry::getCandidates( void DeltaCorrelatingPredictionTables::calculatePrefetch( - const BasePrefetcher::PrefetchInfo &pfi, - std::vector &addresses) + const Base::PrefetchInfo &pfi, + std::vector &addresses) { if (!pfi.hasPC()) { DPRINTF(HWPrefetch, "Ignoring request with no PC.\n"); @@ -149,26 +151,28 @@ DeltaCorrelatingPredictionTables::calculatePrefetch( } } -DeltaCorrelatingPredictionTables * -DeltaCorrelatingPredictionTablesParams::create() -{ - return new DeltaCorrelatingPredictionTables(this); -} - -DCPTPrefetcher::DCPTPrefetcher(const DCPTPrefetcherParams *p) - : QueuedPrefetcher(p), dcpt(*p->dcpt) +DCPT::DCPT(const DCPTPrefetcherParams *p) + : Queued(p), dcpt(*p->dcpt) { } void -DCPTPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, +DCPT::calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) { dcpt.calculatePrefetch(pfi, addresses); } -DCPTPrefetcher* +} // namespace Prefetcher + +Prefetcher::DeltaCorrelatingPredictionTables* +DeltaCorrelatingPredictionTablesParams::create() +{ + return new Prefetcher::DeltaCorrelatingPredictionTables(this); +} + +Prefetcher::DCPT* DCPTPrefetcherParams::create() { - return new DCPTPrefetcher(this); + return new Prefetcher::DCPT(this); } diff --git a/src/mem/cache/prefetch/delta_correlating_prediction_tables.hh b/src/mem/cache/prefetch/delta_correlating_prediction_tables.hh index 6ac2c419c..c051eca9a 100644 --- a/src/mem/cache/prefetch/delta_correlating_prediction_tables.hh +++ b/src/mem/cache/prefetch/delta_correlating_prediction_tables.hh @@ -33,6 +33,9 @@ #include "mem/cache/prefetch/queued.hh" struct DeltaCorrelatingPredictionTablesParams; +struct DCPTPrefetcherParams; + +namespace Prefetcher { /** * Delta Correlating Prediction Tables Prefetcher @@ -95,7 +98,7 @@ class DeltaCorrelatingPredictionTables : public SimObject * @param mask_bits the number of lower bits that should be masked * (ignored) when comparing deltas */ - void getCandidates(std::vector &pfs, + void getCandidates(std::vector &pfs, unsigned int mask_bits) const; }; @@ -105,31 +108,31 @@ class DeltaCorrelatingPredictionTables : public SimObject public: DeltaCorrelatingPredictionTables( DeltaCorrelatingPredictionTablesParams *p); - ~DeltaCorrelatingPredictionTables() - {} + ~DeltaCorrelatingPredictionTables() = default; /** * Computes the prefetch candidates given a prefetch event. * @param pfi The prefetch event information * @param addresses prefetch candidates generated */ - void calculatePrefetch(const BasePrefetcher::PrefetchInfo &pfi, - std::vector &addresses); + void calculatePrefetch(const Base::PrefetchInfo &pfi, + std::vector &addresses); }; -struct DCPTPrefetcherParams; - /** The prefetcher object using the DCPT */ -class DCPTPrefetcher : public QueuedPrefetcher +class DCPT : public Queued { /** DCPT object */ DeltaCorrelatingPredictionTables &dcpt; public: - DCPTPrefetcher(const DCPTPrefetcherParams *p); - ~DCPTPrefetcher() - {} + DCPT(const DCPTPrefetcherParams *p); + ~DCPT() = default; + void calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) override; }; + +} // namespace Prefetcher + #endif//__MEM_CACHE_PREFETCH_DELTA_CORRELATING_PREDICTION_TABLES_HH_ diff --git a/src/mem/cache/prefetch/indirect_memory.cc b/src/mem/cache/prefetch/indirect_memory.cc index 3eed8c98d..ac825fd54 100644 --- a/src/mem/cache/prefetch/indirect_memory.cc +++ b/src/mem/cache/prefetch/indirect_memory.cc @@ -32,8 +32,10 @@ #include "mem/cache/prefetch/associative_set_impl.hh" #include "params/IndirectMemoryPrefetcher.hh" -IndirectMemoryPrefetcher::IndirectMemoryPrefetcher( - const IndirectMemoryPrefetcherParams *p) : QueuedPrefetcher(p), +namespace Prefetcher { + +IndirectMemory::IndirectMemory(const IndirectMemoryPrefetcherParams *p) + : Queued(p), maxPrefetchDistance(p->max_prefetch_distance), shiftValues(p->shift_values), prefetchThreshold(p->prefetch_threshold), streamCounterThreshold(p->stream_counter_threshold), @@ -56,7 +58,7 @@ IndirectMemoryPrefetcher::IndirectMemoryPrefetcher( } void -IndirectMemoryPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, +IndirectMemory::calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) { // This prefetcher requires a PC @@ -164,7 +166,7 @@ IndirectMemoryPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, } void -IndirectMemoryPrefetcher::allocateOrUpdateIPDEntry( +IndirectMemory::allocateOrUpdateIPDEntry( const PrefetchTableEntry *pt_entry, int64_t index) { // The address of the pt_entry is used to index the IPD @@ -194,7 +196,7 @@ IndirectMemoryPrefetcher::allocateOrUpdateIPDEntry( } void -IndirectMemoryPrefetcher::trackMissIndex1(Addr miss_addr) +IndirectMemory::trackMissIndex1(Addr miss_addr) { IndirectPatternDetectorEntry *entry = ipdEntryTrackingMisses; // If the second index is not set, we are just filling the baseAddr @@ -213,7 +215,7 @@ IndirectMemoryPrefetcher::trackMissIndex1(Addr miss_addr) } } void -IndirectMemoryPrefetcher::trackMissIndex2(Addr miss_addr) +IndirectMemory::trackMissIndex2(Addr miss_addr) { IndirectPatternDetectorEntry *entry = ipdEntryTrackingMisses; // Second index is filled, compare the addresses generated during @@ -246,7 +248,7 @@ IndirectMemoryPrefetcher::trackMissIndex2(Addr miss_addr) } void -IndirectMemoryPrefetcher::checkAccessMatchOnActiveEntries(Addr addr) +IndirectMemory::checkAccessMatchOnActiveEntries(Addr addr) { for (auto &pt_entry : prefetchTable) { if (pt_entry.enabled) { @@ -259,8 +261,10 @@ IndirectMemoryPrefetcher::checkAccessMatchOnActiveEntries(Addr addr) } } -IndirectMemoryPrefetcher* +} // namespace Prefetcher + +Prefetcher::IndirectMemory* IndirectMemoryPrefetcherParams::create() { - return new IndirectMemoryPrefetcher(this); + return new Prefetcher::IndirectMemory(this); } diff --git a/src/mem/cache/prefetch/indirect_memory.hh b/src/mem/cache/prefetch/indirect_memory.hh index 40a3aa36b..e5bc1e778 100644 --- a/src/mem/cache/prefetch/indirect_memory.hh +++ b/src/mem/cache/prefetch/indirect_memory.hh @@ -47,7 +47,9 @@ struct IndirectMemoryPrefetcherParams; -class IndirectMemoryPrefetcher : public QueuedPrefetcher +namespace Prefetcher { + +class IndirectMemory : public Queued { /** Maximum number of prefetches generated per event */ const unsigned int maxPrefetchDistance; @@ -191,10 +193,13 @@ class IndirectMemoryPrefetcher : public QueuedPrefetcher void checkAccessMatchOnActiveEntries(Addr addr); public: - IndirectMemoryPrefetcher(const IndirectMemoryPrefetcherParams *p); - ~IndirectMemoryPrefetcher() {} + IndirectMemory(const IndirectMemoryPrefetcherParams *p); + ~IndirectMemory() = default; void calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) override; }; + +} // namespace Prefetcher + #endif//__MEM_CACHE_PREFETCH_INDIRECT_MEMORY_HH__ diff --git a/src/mem/cache/prefetch/irregular_stream_buffer.cc b/src/mem/cache/prefetch/irregular_stream_buffer.cc index 5ee05b621..9c83ec8dd 100644 --- a/src/mem/cache/prefetch/irregular_stream_buffer.cc +++ b/src/mem/cache/prefetch/irregular_stream_buffer.cc @@ -32,34 +32,36 @@ #include "mem/cache/prefetch/associative_set_impl.hh" #include "params/IrregularStreamBufferPrefetcher.hh" -IrregularStreamBufferPrefetcher::IrregularStreamBufferPrefetcher( +namespace Prefetcher { + +IrregularStreamBuffer::IrregularStreamBuffer( const IrregularStreamBufferPrefetcherParams *p) - : QueuedPrefetcher(p), - chunkSize(p->chunk_size), - prefetchCandidatesPerEntry(p->prefetch_candidates_per_entry), - degree(p->degree), - trainingUnit(p->training_unit_assoc, p->training_unit_entries, - p->training_unit_indexing_policy, - p->training_unit_replacement_policy), - psAddressMappingCache(p->address_map_cache_assoc, - p->address_map_cache_entries, - p->ps_address_map_cache_indexing_policy, - p->ps_address_map_cache_replacement_policy, - AddressMappingEntry(prefetchCandidatesPerEntry, - p->num_counter_bits)), - spAddressMappingCache(p->address_map_cache_assoc, - p->address_map_cache_entries, - p->sp_address_map_cache_indexing_policy, - p->sp_address_map_cache_replacement_policy, - AddressMappingEntry(prefetchCandidatesPerEntry, - p->num_counter_bits)), - structuralAddressCounter(0) + : Queued(p), + chunkSize(p->chunk_size), + prefetchCandidatesPerEntry(p->prefetch_candidates_per_entry), + degree(p->degree), + trainingUnit(p->training_unit_assoc, p->training_unit_entries, + p->training_unit_indexing_policy, + p->training_unit_replacement_policy), + psAddressMappingCache(p->address_map_cache_assoc, + p->address_map_cache_entries, + p->ps_address_map_cache_indexing_policy, + p->ps_address_map_cache_replacement_policy, + AddressMappingEntry(prefetchCandidatesPerEntry, + p->num_counter_bits)), + spAddressMappingCache(p->address_map_cache_assoc, + p->address_map_cache_entries, + p->sp_address_map_cache_indexing_policy, + p->sp_address_map_cache_replacement_policy, + AddressMappingEntry(prefetchCandidatesPerEntry, + p->num_counter_bits)), + structuralAddressCounter(0) { assert(isPowerOf2(prefetchCandidatesPerEntry)); } void -IrregularStreamBufferPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, +IrregularStreamBuffer::calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) { // This prefetcher requires a PC @@ -165,8 +167,8 @@ IrregularStreamBufferPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, } } -IrregularStreamBufferPrefetcher::AddressMapping& -IrregularStreamBufferPrefetcher::getPSMapping(Addr paddr, bool is_secure) +IrregularStreamBuffer::AddressMapping& +IrregularStreamBuffer::getPSMapping(Addr paddr, bool is_secure) { Addr amc_address = paddr / prefetchCandidatesPerEntry; Addr map_index = paddr % prefetchCandidatesPerEntry; @@ -185,7 +187,7 @@ IrregularStreamBufferPrefetcher::getPSMapping(Addr paddr, bool is_secure) } void -IrregularStreamBufferPrefetcher::addStructuralToPhysicalEntry( +IrregularStreamBuffer::addStructuralToPhysicalEntry( Addr structural_address, bool is_secure, Addr physical_address) { Addr amc_address = structural_address / prefetchCandidatesPerEntry; @@ -206,8 +208,10 @@ IrregularStreamBufferPrefetcher::addStructuralToPhysicalEntry( mapping.counter++; } -IrregularStreamBufferPrefetcher* +} // namespace Prefetcher + +Prefetcher::IrregularStreamBuffer* IrregularStreamBufferPrefetcherParams::create() { - return new IrregularStreamBufferPrefetcher(this); + return new Prefetcher::IrregularStreamBuffer(this); } diff --git a/src/mem/cache/prefetch/irregular_stream_buffer.hh b/src/mem/cache/prefetch/irregular_stream_buffer.hh index af626763c..47969027f 100644 --- a/src/mem/cache/prefetch/irregular_stream_buffer.hh +++ b/src/mem/cache/prefetch/irregular_stream_buffer.hh @@ -45,7 +45,9 @@ struct IrregularStreamBufferPrefetcherParams; -class IrregularStreamBufferPrefetcher : public QueuedPrefetcher +namespace Prefetcher { + +class IrregularStreamBuffer : public Queued { /** Size in bytes of a temporal stream */ const size_t chunkSize; @@ -125,10 +127,13 @@ class IrregularStreamBufferPrefetcher : public QueuedPrefetcher */ AddressMapping& getPSMapping(Addr paddr, bool is_secure); public: - IrregularStreamBufferPrefetcher( - const IrregularStreamBufferPrefetcherParams *p); - ~IrregularStreamBufferPrefetcher() {} + IrregularStreamBuffer(const IrregularStreamBufferPrefetcherParams *p); + ~IrregularStreamBuffer() = default; + void calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) override; }; + +} // namespace Prefetcher + #endif//__MEM_CACHE_PREFETCH_IRREGULAR_STREAM_BUFFER_HH__ diff --git a/src/mem/cache/prefetch/multi.cc b/src/mem/cache/prefetch/multi.cc index 94e6c9ce5..fd2263652 100644 --- a/src/mem/cache/prefetch/multi.cc +++ b/src/mem/cache/prefetch/multi.cc @@ -39,21 +39,23 @@ #include "params/MultiPrefetcher.hh" -MultiPrefetcher::MultiPrefetcher(const MultiPrefetcherParams *p) - : BasePrefetcher(p), - prefetchers(p->prefetchers.begin(), p->prefetchers.end()) +namespace Prefetcher { + +Multi::Multi(const MultiPrefetcherParams *p) + : Base(p), + prefetchers(p->prefetchers.begin(), p->prefetchers.end()) { } void -MultiPrefetcher::setCache(BaseCache *_cache) +Multi::setCache(BaseCache *_cache) { for (auto pf : prefetchers) pf->setCache(_cache); } Tick -MultiPrefetcher::nextPrefetchReadyTime() const +Multi::nextPrefetchReadyTime() const { Tick next_ready = MaxTick; @@ -64,7 +66,7 @@ MultiPrefetcher::nextPrefetchReadyTime() const } PacketPtr -MultiPrefetcher::getPacket() +Multi::getPacket() { for (auto pf : prefetchers) { if (pf->nextPrefetchReadyTime() <= curTick()) { @@ -77,9 +79,10 @@ MultiPrefetcher::getPacket() return nullptr; } +} // namespace Prefetcher -MultiPrefetcher* +Prefetcher::Multi* MultiPrefetcherParams::create() { - return new MultiPrefetcher(this); + return new Prefetcher::Multi(this); } diff --git a/src/mem/cache/prefetch/multi.hh b/src/mem/cache/prefetch/multi.hh index 0f72173d8..c01d0c2ef 100644 --- a/src/mem/cache/prefetch/multi.hh +++ b/src/mem/cache/prefetch/multi.hh @@ -42,12 +42,14 @@ struct MultiPrefetcherParams; -class MultiPrefetcher : public BasePrefetcher +namespace Prefetcher { + +class Multi : public Base { public: // SimObject - MultiPrefetcher(const MultiPrefetcherParams *p); + Multi(const MultiPrefetcherParams *p); - public: // BasePrefetcher + public: void setCache(BaseCache *_cache) override; PacketPtr getPacket() override; Tick nextPrefetchReadyTime() const override; @@ -63,7 +65,9 @@ class MultiPrefetcher : public BasePrefetcher protected: /** List of sub-prefetchers ordered by priority. */ - std::list prefetchers; + std::list prefetchers; }; +} // namespace Prefetcher + #endif //__MEM_CACHE_PREFETCH_MULTI_HH__ diff --git a/src/mem/cache/prefetch/pif.cc b/src/mem/cache/prefetch/pif.cc index fb974dd5b..849106288 100644 --- a/src/mem/cache/prefetch/pif.cc +++ b/src/mem/cache/prefetch/pif.cc @@ -34,8 +34,10 @@ #include "mem/cache/prefetch/associative_set_impl.hh" #include "params/PIFPrefetcher.hh" -PIFPrefetcher::PIFPrefetcher(const PIFPrefetcherParams *p) - : QueuedPrefetcher(p), +namespace Prefetcher { + +PIF::PIF(const PIFPrefetcherParams *p) + : Queued(p), precSize(p->prec_spatial_region_bits), succSize(p->succ_spatial_region_bits), maxCompactorEntries(p->compactor_entries), @@ -48,7 +50,7 @@ PIFPrefetcher::PIFPrefetcher(const PIFPrefetcherParams *p) { } -PIFPrefetcher::CompactorEntry::CompactorEntry(Addr addr, +PIF::CompactorEntry::CompactorEntry(Addr addr, unsigned int prec_size, unsigned int succ_size) { trigger = addr; @@ -57,7 +59,7 @@ PIFPrefetcher::CompactorEntry::CompactorEntry(Addr addr, } Addr -PIFPrefetcher::CompactorEntry::distanceFromTrigger(Addr target, +PIF::CompactorEntry::distanceFromTrigger(Addr target, unsigned int log_blk_size) const { const Addr target_blk = target >> log_blk_size; @@ -68,7 +70,7 @@ PIFPrefetcher::CompactorEntry::distanceFromTrigger(Addr target, } bool -PIFPrefetcher::CompactorEntry::inSameSpatialRegion(Addr pc, +PIF::CompactorEntry::inSameSpatialRegion(Addr pc, unsigned int log_blk_size, bool update) { Addr blk_distance = distanceFromTrigger(pc, log_blk_size); @@ -86,7 +88,7 @@ PIFPrefetcher::CompactorEntry::inSameSpatialRegion(Addr pc, } bool -PIFPrefetcher::CompactorEntry::hasAddress(Addr target, +PIF::CompactorEntry::hasAddress(Addr target, unsigned int log_blk_size) const { Addr blk_distance = distanceFromTrigger(target, log_blk_size); @@ -102,7 +104,7 @@ PIFPrefetcher::CompactorEntry::hasAddress(Addr target, } void -PIFPrefetcher::CompactorEntry::getPredictedAddresses(unsigned int log_blk_size, +PIF::CompactorEntry::getPredictedAddresses(unsigned int log_blk_size, std::vector &addresses) const { // Calculate the addresses of the instruction blocks that are encoded @@ -128,7 +130,7 @@ PIFPrefetcher::CompactorEntry::getPredictedAddresses(unsigned int log_blk_size, } void -PIFPrefetcher::notifyRetiredInst(const Addr pc) +PIF::notifyRetiredInst(const Addr pc) { // First access to the prefetcher if (temporalCompactor.size() == 0) { @@ -195,7 +197,7 @@ PIFPrefetcher::notifyRetiredInst(const Addr pc) } void -PIFPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, +PIF::calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) { const Addr addr = pfi.getAddr(); @@ -239,20 +241,22 @@ PIFPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, } void -PIFPrefetcher::PrefetchListenerPC::notify(const Addr& pc) +PIF::PrefetchListenerPC::notify(const Addr& pc) { parent.notifyRetiredInst(pc); } void -PIFPrefetcher::addEventProbeRetiredInsts(SimObject *obj, const char *name) +PIF::addEventProbeRetiredInsts(SimObject *obj, const char *name) { ProbeManager *pm(obj->getProbeManager()); listenersPC.push_back(new PrefetchListenerPC(*this, pm, name)); } -PIFPrefetcher* +} // namespace Prefetcher + +Prefetcher::PIF* PIFPrefetcherParams::create() { - return new PIFPrefetcher(this); + return new Prefetcher::PIF(this); } diff --git a/src/mem/cache/prefetch/pif.hh b/src/mem/cache/prefetch/pif.hh index 6d938305f..9fef2968c 100644 --- a/src/mem/cache/prefetch/pif.hh +++ b/src/mem/cache/prefetch/pif.hh @@ -45,7 +45,9 @@ struct PIFPrefetcherParams; -class PIFPrefetcher : public QueuedPrefetcher +namespace Prefetcher { + +class PIF : public Queued { private: /** Number of preceding and subsequent spatial addresses to compact */ @@ -158,13 +160,13 @@ class PIFPrefetcher : public QueuedPrefetcher class PrefetchListenerPC : public ProbeListenerArgBase { public: - PrefetchListenerPC(PIFPrefetcher &_parent, ProbeManager *pm, + PrefetchListenerPC(PIF &_parent, ProbeManager *pm, const std::string &name) : ProbeListenerArgBase(pm, name), parent(_parent) {} void notify(const Addr& pc) override; protected: - PIFPrefetcher &parent; + PIF &parent; }; /** Array of probe listeners */ @@ -172,8 +174,8 @@ class PIFPrefetcher : public QueuedPrefetcher public: - PIFPrefetcher(const PIFPrefetcherParams *p); - ~PIFPrefetcher() {} + PIF(const PIFPrefetcherParams *p); + ~PIF() = default; void calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses); @@ -186,4 +188,6 @@ class PIFPrefetcher : public QueuedPrefetcher void addEventProbeRetiredInsts(SimObject *obj, const char *name); }; +} // namespace Prefetcher + #endif // __MEM_CACHE_PREFETCH_PIF_HH__ diff --git a/src/mem/cache/prefetch/queued.cc b/src/mem/cache/prefetch/queued.cc index ceab7b3e2..e6d2b7cd8 100644 --- a/src/mem/cache/prefetch/queued.cc +++ b/src/mem/cache/prefetch/queued.cc @@ -47,8 +47,10 @@ #include "mem/request.hh" #include "params/QueuedPrefetcher.hh" +namespace Prefetcher { + void -QueuedPrefetcher::DeferredPacket::createPkt(Addr paddr, unsigned blk_size, +Queued::DeferredPacket::createPkt(Addr paddr, unsigned blk_size, MasterID mid, bool tag_prefetch, Tick t) { /* Create a prefetch memory request */ @@ -68,7 +70,7 @@ QueuedPrefetcher::DeferredPacket::createPkt(Addr paddr, unsigned blk_size, } void -QueuedPrefetcher::DeferredPacket::startTranslation(BaseTLB *tlb) +Queued::DeferredPacket::startTranslation(BaseTLB *tlb) { assert(translationRequest != nullptr); if (!ongoingTranslation) { @@ -79,7 +81,7 @@ QueuedPrefetcher::DeferredPacket::startTranslation(BaseTLB *tlb) } void -QueuedPrefetcher::DeferredPacket::finish(const Fault &fault, +Queued::DeferredPacket::finish(const Fault &fault, const RequestPtr &req, ThreadContext *tc, BaseTLB::Mode mode) { assert(ongoingTranslation); @@ -88,8 +90,8 @@ QueuedPrefetcher::DeferredPacket::finish(const Fault &fault, owner->translationComplete(this, failed); } -QueuedPrefetcher::QueuedPrefetcher(const QueuedPrefetcherParams *p) - : BasePrefetcher(p), queueSize(p->queue_size), +Queued::Queued(const QueuedPrefetcherParams *p) + : Base(p), queueSize(p->queue_size), missingTranslationQueueSize( p->max_prefetch_requests_with_pending_translation), latency(p->latency), queueSquash(p->queue_squash), @@ -99,7 +101,7 @@ QueuedPrefetcher::QueuedPrefetcher(const QueuedPrefetcherParams *p) { } -QueuedPrefetcher::~QueuedPrefetcher() +Queued::~Queued() { // Delete the queued prefetch packets for (DeferredPacket &p : pfq) { @@ -108,7 +110,7 @@ QueuedPrefetcher::~QueuedPrefetcher() } size_t -QueuedPrefetcher::getMaxPermittedPrefetches(size_t total) const +Queued::getMaxPermittedPrefetches(size_t total) const { /** * Throttle generated prefetches based in the accuracy of the prefetcher. @@ -138,7 +140,7 @@ QueuedPrefetcher::getMaxPermittedPrefetches(size_t total) const } void -QueuedPrefetcher::notify(const PacketPtr &pkt, const PrefetchInfo &pfi) +Queued::notify(const PacketPtr &pkt, const PrefetchInfo &pfi) { Addr blk_addr = blockAddress(pfi.getAddr()); bool is_secure = pfi.isSecure(); @@ -194,7 +196,7 @@ QueuedPrefetcher::notify(const PacketPtr &pkt, const PrefetchInfo &pfi) } PacketPtr -QueuedPrefetcher::getPacket() +Queued::getPacket() { DPRINTF(HWPrefetch, "Requesting a prefetch to issue.\n"); @@ -222,9 +224,9 @@ QueuedPrefetcher::getPacket() } void -QueuedPrefetcher::regStats() +Queued::regStats() { - BasePrefetcher::regStats(); + Base::regStats(); pfIdentified .name(name() + ".pfIdentified") @@ -249,7 +251,7 @@ QueuedPrefetcher::regStats() void -QueuedPrefetcher::processMissingTranslations(unsigned max) +Queued::processMissingTranslations(unsigned max) { unsigned count = 0; iterator it = pfqMissingTranslation.begin(); @@ -264,7 +266,7 @@ QueuedPrefetcher::processMissingTranslations(unsigned max) } void -QueuedPrefetcher::translationComplete(DeferredPacket *dp, bool failed) +Queued::translationComplete(DeferredPacket *dp, bool failed) { auto it = pfqMissingTranslation.begin(); while (it != pfqMissingTranslation.end()) { @@ -301,7 +303,7 @@ QueuedPrefetcher::translationComplete(DeferredPacket *dp, bool failed) } bool -QueuedPrefetcher::alreadyInQueue(std::list &queue, +Queued::alreadyInQueue(std::list &queue, const PrefetchInfo &pfi, int32_t priority) { bool found = false; @@ -336,7 +338,7 @@ QueuedPrefetcher::alreadyInQueue(std::list &queue, } RequestPtr -QueuedPrefetcher::createPrefetchRequest(Addr addr, PrefetchInfo const &pfi, +Queued::createPrefetchRequest(Addr addr, PrefetchInfo const &pfi, PacketPtr pkt) { RequestPtr translation_req = std::make_shared( @@ -347,7 +349,7 @@ QueuedPrefetcher::createPrefetchRequest(Addr addr, PrefetchInfo const &pfi, } void -QueuedPrefetcher::insert(const PacketPtr &pkt, PrefetchInfo &new_pfi, +Queued::insert(const PacketPtr &pkt, PrefetchInfo &new_pfi, int32_t priority) { if (queueFilter) { @@ -445,7 +447,7 @@ QueuedPrefetcher::insert(const PacketPtr &pkt, PrefetchInfo &new_pfi, } void -QueuedPrefetcher::addToQueue(std::list &queue, +Queued::addToQueue(std::list &queue, DeferredPacket &dpp) { /* Verify prefetch buffer space for request */ @@ -490,3 +492,5 @@ QueuedPrefetcher::addToQueue(std::list &queue, queue.insert(it, dpp); } } + +} // namespace Prefetcher diff --git a/src/mem/cache/prefetch/queued.hh b/src/mem/cache/prefetch/queued.hh index 24c9f4816..5af9093cd 100644 --- a/src/mem/cache/prefetch/queued.hh +++ b/src/mem/cache/prefetch/queued.hh @@ -49,12 +49,14 @@ struct QueuedPrefetcherParams; -class QueuedPrefetcher : public BasePrefetcher +namespace Prefetcher { + +class Queued : public Base { protected: struct DeferredPacket : public BaseTLB::Translation { /** Owner of the packet */ - QueuedPrefetcher *owner; + Queued *owner; /** Prefetch info corresponding to this packet */ PrefetchInfo pfInfo; /** Time when this prefetch becomes ready */ @@ -76,7 +78,7 @@ class QueuedPrefetcher : public BasePrefetcher * @param p PacketPtr with the memory request of the prefetch * @param prio This prefetch priority */ - DeferredPacket(QueuedPrefetcher *o, PrefetchInfo const &pfi, Tick t, + DeferredPacket(Queued *o, PrefetchInfo const &pfi, Tick t, int32_t prio) : owner(o), pfInfo(pfi), tick(t), pkt(nullptr), priority(prio), translationRequest(), tc(nullptr), ongoingTranslation(false) { @@ -175,8 +177,8 @@ class QueuedPrefetcher : public BasePrefetcher public: using AddrPriority = std::pair; - QueuedPrefetcher(const QueuedPrefetcherParams *p); - virtual ~QueuedPrefetcher(); + Queued(const QueuedPrefetcherParams *p); + virtual ~Queued(); void notify(const PacketPtr &pkt, const PrefetchInfo &pfi) override; @@ -245,5 +247,7 @@ class QueuedPrefetcher : public BasePrefetcher PacketPtr pkt); }; +} // namespace Prefetcher + #endif //__MEM_CACHE_PREFETCH_QUEUED_HH__ diff --git a/src/mem/cache/prefetch/sbooe.cc b/src/mem/cache/prefetch/sbooe.cc index 9486b0aa3..ecbab686d 100644 --- a/src/mem/cache/prefetch/sbooe.cc +++ b/src/mem/cache/prefetch/sbooe.cc @@ -31,8 +31,10 @@ #include "debug/HWPrefetch.hh" #include "params/SBOOEPrefetcher.hh" -SBOOEPrefetcher::SBOOEPrefetcher(const SBOOEPrefetcherParams *p) - : QueuedPrefetcher(p), +namespace Prefetcher { + +SBOOE::SBOOE(const SBOOEPrefetcherParams *p) + : Queued(p), latencyBufferSize(p->latency_buffer_size), sequentialPrefetchers(p->sequential_prefetchers), scoreThreshold((p->sandbox_entries*p->score_threshold_pct)/100), @@ -52,7 +54,7 @@ SBOOEPrefetcher::SBOOEPrefetcher(const SBOOEPrefetcherParams *p) } void -SBOOEPrefetcher::Sandbox::insert(Addr addr, Tick tick) +SBOOE::Sandbox::insert(Addr addr, Tick tick) { entries[index].valid = true; entries[index].line = addr + stride; @@ -66,7 +68,7 @@ SBOOEPrefetcher::Sandbox::insert(Addr addr, Tick tick) } bool -SBOOEPrefetcher::access(Addr access_line) +SBOOE::access(Addr access_line) { for (Sandbox &sb : sandboxes) { // Search for the address in the FIFO queue @@ -92,7 +94,7 @@ SBOOEPrefetcher::access(Addr access_line) } void -SBOOEPrefetcher::notifyFill(const PacketPtr& pkt) +SBOOE::notifyFill(const PacketPtr& pkt) { // (1) Look for the address in the demands list // (2) Calculate the elapsed cycles until it was filled (curTick) @@ -119,7 +121,7 @@ SBOOEPrefetcher::notifyFill(const PacketPtr& pkt) } void -SBOOEPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, +SBOOE::calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) { const Addr pfi_addr = pfi.getAddr(); @@ -139,8 +141,10 @@ SBOOEPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, } } -SBOOEPrefetcher* +} // namespace Prefetcher + +Prefetcher::SBOOE* SBOOEPrefetcherParams::create() { - return new SBOOEPrefetcher(this); + return new Prefetcher::SBOOE(this); } diff --git a/src/mem/cache/prefetch/sbooe.hh b/src/mem/cache/prefetch/sbooe.hh index 037029413..8076732b9 100644 --- a/src/mem/cache/prefetch/sbooe.hh +++ b/src/mem/cache/prefetch/sbooe.hh @@ -44,7 +44,9 @@ struct SBOOEPrefetcherParams; -class SBOOEPrefetcher : public QueuedPrefetcher +namespace Prefetcher { + +class SBOOE : public Queued { private: @@ -147,10 +149,12 @@ class SBOOEPrefetcher : public QueuedPrefetcher void notifyFill(const PacketPtr& pkt) override; public: - SBOOEPrefetcher(const SBOOEPrefetcherParams *p); + SBOOE(const SBOOEPrefetcherParams *p); void calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) override; }; +} // namespace Prefetcher + #endif // __MEM_CACHE_PREFETCH_SBOOE_HH__ diff --git a/src/mem/cache/prefetch/signature_path.cc b/src/mem/cache/prefetch/signature_path.cc index 8689b53f0..556a003a5 100644 --- a/src/mem/cache/prefetch/signature_path.cc +++ b/src/mem/cache/prefetch/signature_path.cc @@ -35,9 +35,10 @@ #include "mem/cache/prefetch/associative_set_impl.hh" #include "params/SignaturePathPrefetcher.hh" -SignaturePathPrefetcher::SignaturePathPrefetcher( - const SignaturePathPrefetcherParams *p) - : QueuedPrefetcher(p), +namespace Prefetcher { + +SignaturePath::SignaturePath(const SignaturePathPrefetcherParams *p) + : Queued(p), stridesPerPatternEntry(p->strides_per_pattern_entry), signatureShift(p->signature_shift), signatureBits(p->signature_bits), @@ -61,8 +62,8 @@ SignaturePathPrefetcher::SignaturePathPrefetcher( "The lookahead confidence threshold must be less than 1\n"); } -SignaturePathPrefetcher::PatternStrideEntry & -SignaturePathPrefetcher::PatternEntry::getStrideEntry(stride_t stride) +SignaturePath::PatternStrideEntry & +SignaturePath::PatternEntry::getStrideEntry(stride_t stride) { PatternStrideEntry *pstride_entry = findStride(stride); if (pstride_entry == nullptr) { @@ -89,7 +90,7 @@ SignaturePathPrefetcher::PatternEntry::getStrideEntry(stride_t stride) } void -SignaturePathPrefetcher::addPrefetch(Addr ppn, stride_t last_block, +SignaturePath::addPrefetch(Addr ppn, stride_t last_block, stride_t delta, double path_confidence, signature_t signature, bool is_secure, std::vector &addresses) { @@ -130,7 +131,7 @@ SignaturePathPrefetcher::addPrefetch(Addr ppn, stride_t last_block, } void -SignaturePathPrefetcher::handleSignatureTableMiss(stride_t current_block, +SignaturePath::handleSignatureTableMiss(stride_t current_block, signature_t &new_signature, double &new_conf, stride_t &new_stride) { new_signature = current_block; @@ -139,14 +140,14 @@ SignaturePathPrefetcher::handleSignatureTableMiss(stride_t current_block, } void -SignaturePathPrefetcher::increasePatternEntryCounter( +SignaturePath::increasePatternEntryCounter( PatternEntry &pattern_entry, PatternStrideEntry &pstride_entry) { pstride_entry.counter++; } void -SignaturePathPrefetcher::updatePatternTable(Addr signature, stride_t stride) +SignaturePath::updatePatternTable(Addr signature, stride_t stride) { assert(stride != 0); // The pattern table is indexed by signatures @@ -155,8 +156,8 @@ SignaturePathPrefetcher::updatePatternTable(Addr signature, stride_t stride) increasePatternEntryCounter(p_entry, ps_entry); } -SignaturePathPrefetcher::SignatureEntry & -SignaturePathPrefetcher::getSignatureEntry(Addr ppn, bool is_secure, +SignaturePath::SignatureEntry & +SignaturePath::getSignatureEntry(Addr ppn, bool is_secure, stride_t block, bool &miss, stride_t &stride, double &initial_confidence) { @@ -180,8 +181,8 @@ SignaturePathPrefetcher::getSignatureEntry(Addr ppn, bool is_secure, return *signature_entry; } -SignaturePathPrefetcher::PatternEntry & -SignaturePathPrefetcher::getPatternEntry(Addr signature) +SignaturePath::PatternEntry & +SignaturePath::getPatternEntry(Addr signature) { PatternEntry* pattern_entry = patternTable.findEntry(signature, false); if (pattern_entry != nullptr) { @@ -198,14 +199,14 @@ SignaturePathPrefetcher::getPatternEntry(Addr signature) } double -SignaturePathPrefetcher::calculatePrefetchConfidence(PatternEntry const &sig, +SignaturePath::calculatePrefetchConfidence(PatternEntry const &sig, PatternStrideEntry const &entry) const { return entry.counter.calcSaturation(); } double -SignaturePathPrefetcher::calculateLookaheadConfidence(PatternEntry const &sig, +SignaturePath::calculateLookaheadConfidence(PatternEntry const &sig, PatternStrideEntry const &lookahead) const { double lookahead_confidence = lookahead.counter.calcSaturation(); @@ -221,7 +222,7 @@ SignaturePathPrefetcher::calculateLookaheadConfidence(PatternEntry const &sig, } void -SignaturePathPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, +SignaturePath::calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) { Addr request_addr = pfi.getAddr(); @@ -305,7 +306,7 @@ SignaturePathPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, } void -SignaturePathPrefetcher::auxiliaryPrefetcher(Addr ppn, stride_t current_block, +SignaturePath::auxiliaryPrefetcher(Addr ppn, stride_t current_block, bool is_secure, std::vector &addresses) { if (addresses.empty()) { @@ -315,8 +316,10 @@ SignaturePathPrefetcher::auxiliaryPrefetcher(Addr ppn, stride_t current_block, } } -SignaturePathPrefetcher* +} // namespace Prefetcher + +Prefetcher::SignaturePath* SignaturePathPrefetcherParams::create() { - return new SignaturePathPrefetcher(this); + return new Prefetcher::SignaturePath(this); } diff --git a/src/mem/cache/prefetch/signature_path.hh b/src/mem/cache/prefetch/signature_path.hh index 0cbb2074b..1456d8e42 100644 --- a/src/mem/cache/prefetch/signature_path.hh +++ b/src/mem/cache/prefetch/signature_path.hh @@ -47,7 +47,9 @@ struct SignaturePathPrefetcherParams; -class SignaturePathPrefetcher : public QueuedPrefetcher +namespace Prefetcher { + +class SignaturePath : public Queued { protected: /** Signature type */ @@ -277,10 +279,13 @@ class SignaturePathPrefetcher : public QueuedPrefetcher } public: - SignaturePathPrefetcher(const SignaturePathPrefetcherParams* p); - ~SignaturePathPrefetcher() {} + SignaturePath(const SignaturePathPrefetcherParams* p); + ~SignaturePath() = default; + void calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) override; }; +} // namespace Prefetcher + #endif//__MEM_CACHE_PREFETCH_SIGNATURE_PATH_HH__ diff --git a/src/mem/cache/prefetch/signature_path_v2.cc b/src/mem/cache/prefetch/signature_path_v2.cc index 656ce6f55..588536c3c 100644 --- a/src/mem/cache/prefetch/signature_path_v2.cc +++ b/src/mem/cache/prefetch/signature_path_v2.cc @@ -34,9 +34,10 @@ #include "mem/cache/prefetch/associative_set_impl.hh" #include "params/SignaturePathPrefetcherV2.hh" -SignaturePathPrefetcherV2::SignaturePathPrefetcherV2( - const SignaturePathPrefetcherV2Params *p) - : SignaturePathPrefetcher(p), +namespace Prefetcher { + +SignaturePathV2::SignaturePathV2(const SignaturePathPrefetcherV2Params *p) + : SignaturePath(p), globalHistoryRegister(p->global_history_register_entries, p->global_history_register_entries, p->global_history_register_indexing_policy, @@ -46,7 +47,7 @@ SignaturePathPrefetcherV2::SignaturePathPrefetcherV2( } void -SignaturePathPrefetcherV2::handleSignatureTableMiss(stride_t current_block, +SignaturePathV2::handleSignatureTableMiss(stride_t current_block, signature_t &new_signature, double &new_conf, stride_t &new_stride) { bool found = false; @@ -74,7 +75,7 @@ SignaturePathPrefetcherV2::handleSignatureTableMiss(stride_t current_block, } double -SignaturePathPrefetcherV2::calculateLookaheadConfidence( +SignaturePathV2::calculateLookaheadConfidence( PatternEntry const &sig, PatternStrideEntry const &lookahead) const { if (sig.counter == 0) return 0.0; @@ -83,7 +84,7 @@ SignaturePathPrefetcherV2::calculateLookaheadConfidence( } double -SignaturePathPrefetcherV2::calculatePrefetchConfidence(PatternEntry const &sig, +SignaturePathV2::calculatePrefetchConfidence(PatternEntry const &sig, PatternStrideEntry const &entry) const { if (sig.counter == 0) return 0.0; @@ -91,7 +92,7 @@ SignaturePathPrefetcherV2::calculatePrefetchConfidence(PatternEntry const &sig, } void -SignaturePathPrefetcherV2::increasePatternEntryCounter( +SignaturePathV2::increasePatternEntryCounter( PatternEntry &pattern_entry, PatternStrideEntry &pstride_entry) { if (pattern_entry.counter.isSaturated()) { @@ -111,7 +112,7 @@ SignaturePathPrefetcherV2::increasePatternEntryCounter( } void -SignaturePathPrefetcherV2::handlePageCrossingLookahead(signature_t signature, +SignaturePathV2::handlePageCrossingLookahead(signature_t signature, stride_t last_offset, stride_t delta, double path_confidence) { // Always use the replacement policy to assign new entries, as all @@ -127,8 +128,10 @@ SignaturePathPrefetcherV2::handlePageCrossingLookahead(signature_t signature, gh_entry->confidence = path_confidence; } -SignaturePathPrefetcherV2* +} // namespace Prefetcher + +Prefetcher::SignaturePathV2* SignaturePathPrefetcherV2Params::create() { - return new SignaturePathPrefetcherV2(this); + return new Prefetcher::SignaturePathV2(this); } diff --git a/src/mem/cache/prefetch/signature_path_v2.hh b/src/mem/cache/prefetch/signature_path_v2.hh index 215b18873..583c57a45 100644 --- a/src/mem/cache/prefetch/signature_path_v2.hh +++ b/src/mem/cache/prefetch/signature_path_v2.hh @@ -47,7 +47,9 @@ struct SignaturePathPrefetcherV2Params; -class SignaturePathPrefetcherV2 : public SignaturePathPrefetcher +namespace Prefetcher { + +class SignaturePathV2 : public SignaturePath { /** Global History Register entry datatype */ struct GlobalHistoryEntry : public TaggedEntry @@ -88,8 +90,10 @@ class SignaturePathPrefetcherV2 : public SignaturePathPrefetcher override; public: - SignaturePathPrefetcherV2(const SignaturePathPrefetcherV2Params* p); - ~SignaturePathPrefetcherV2() {} + SignaturePathV2(const SignaturePathPrefetcherV2Params* p); + ~SignaturePathV2() = default; }; +} // namespace Prefetcher + #endif//__MEM_CACHE_PREFETCH_SIGNATURE_PATH_V2_HH__ diff --git a/src/mem/cache/prefetch/slim_ampm.cc b/src/mem/cache/prefetch/slim_ampm.cc index b886a7759..0da18505a 100644 --- a/src/mem/cache/prefetch/slim_ampm.cc +++ b/src/mem/cache/prefetch/slim_ampm.cc @@ -30,13 +30,15 @@ #include "params/SlimAMPMPrefetcher.hh" -SlimAMPMPrefetcher::SlimAMPMPrefetcher(const SlimAMPMPrefetcherParams* p) - : QueuedPrefetcher(p), ampm(*p->ampm), dcpt(*p->dcpt) +namespace Prefetcher { + +SlimAMPM::SlimAMPM(const SlimAMPMPrefetcherParams* p) + : Queued(p), ampm(*p->ampm), dcpt(*p->dcpt) { } void -SlimAMPMPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, +SlimAMPM::calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) { dcpt.calculatePrefetch(pfi, addresses); @@ -45,8 +47,10 @@ SlimAMPMPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, } } -SlimAMPMPrefetcher* +} // namespace Prefetcher + +Prefetcher::SlimAMPM* SlimAMPMPrefetcherParams::create() { - return new SlimAMPMPrefetcher(this); + return new Prefetcher::SlimAMPM(this); } diff --git a/src/mem/cache/prefetch/slim_ampm.hh b/src/mem/cache/prefetch/slim_ampm.hh index 37071d7cf..cbcc7c77f 100644 --- a/src/mem/cache/prefetch/slim_ampm.hh +++ b/src/mem/cache/prefetch/slim_ampm.hh @@ -45,18 +45,22 @@ struct SlimAMPMPrefetcherParams; -class SlimAMPMPrefetcher : public QueuedPrefetcher +namespace Prefetcher { + +class SlimAMPM : public Queued { /** AMPM prefetcher object */ AccessMapPatternMatching &m; /** DCPT prefetcher object */ DeltaCorrelatingPredictionTables &dcpt; public: - SlimAMPMPrefetcher(const SlimAMPMPrefetcherParams *p); - ~SlimAMPMPrefetcher() - {} + SlimAMPM(const SlimAMPMPrefetcherParams *p); + ~SlimAMPM() = default; void calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) override; }; + +} // namespace Prefetcher + #endif//__MEM_CACHE_PREFETCH_SLIM_AMPM_HH__ diff --git a/src/mem/cache/prefetch/spatio_temporal_memory_streaming.cc b/src/mem/cache/prefetch/spatio_temporal_memory_streaming.cc index 98a2147a4..932c7f607 100644 --- a/src/mem/cache/prefetch/spatio_temporal_memory_streaming.cc +++ b/src/mem/cache/prefetch/spatio_temporal_memory_streaming.cc @@ -32,8 +32,10 @@ #include "mem/cache/prefetch/associative_set_impl.hh" #include "params/STeMSPrefetcher.hh" -STeMSPrefetcher::STeMSPrefetcher(const STeMSPrefetcherParams *p) - : QueuedPrefetcher(p), spatialRegionSize(p->spatial_region_size), +namespace Prefetcher { + +STeMS::STeMS(const STeMSPrefetcherParams *p) + : Queued(p), spatialRegionSize(p->spatial_region_size), spatialRegionSizeBits(floorLog2(p->spatial_region_size)), reconstructionEntries(p->reconstruction_entries), activeGenerationTable(p->active_generation_table_assoc, @@ -55,7 +57,8 @@ STeMSPrefetcher::STeMSPrefetcher(const STeMSPrefetcherParams *p) } void -STeMSPrefetcher::checkForActiveGenerationsEnd() { +STeMS::checkForActiveGenerationsEnd() +{ // This prefetcher operates attached to the L1 and it observes all // accesses, this guarantees that no evictions are missed @@ -101,7 +104,7 @@ STeMSPrefetcher::checkForActiveGenerationsEnd() { } void -STeMSPrefetcher::addToRMOB(Addr sr_addr, Addr pst_addr, unsigned int delta) +STeMS::addToRMOB(Addr sr_addr, Addr pst_addr, unsigned int delta) { RegionMissOrderBufferEntry &rmob_entry = rmob[rmobHead]; rmobHead = (rmobHead + 1) % rmob.size(); @@ -113,7 +116,7 @@ STeMSPrefetcher::addToRMOB(Addr sr_addr, Addr pst_addr, unsigned int delta) } void -STeMSPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, +STeMS::calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) { if (!pfi.hasPC()) { @@ -182,7 +185,7 @@ STeMSPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, } void -STeMSPrefetcher::reconstructSequence(unsigned int rmob_idx, +STeMS::reconstructSequence(unsigned int rmob_idx, std::vector &addresses) { std::vector reconstruction(reconstructionEntries, MaxAddr); @@ -248,8 +251,10 @@ STeMSPrefetcher::reconstructSequence(unsigned int rmob_idx, } } -STeMSPrefetcher * +} // namespace Prefetcher + +Prefetcher::STeMS* STeMSPrefetcherParams::create() { - return new STeMSPrefetcher(this); + return new Prefetcher::STeMS(this); } diff --git a/src/mem/cache/prefetch/spatio_temporal_memory_streaming.hh b/src/mem/cache/prefetch/spatio_temporal_memory_streaming.hh index 98b8bb614..8f8704ade 100644 --- a/src/mem/cache/prefetch/spatio_temporal_memory_streaming.hh +++ b/src/mem/cache/prefetch/spatio_temporal_memory_streaming.hh @@ -49,7 +49,9 @@ struct STeMSPrefetcherParams; -class STeMSPrefetcher : public QueuedPrefetcher +namespace Prefetcher { + +class STeMS : public Queued { /** Size of each spatial region */ const size_t spatialRegionSize; @@ -190,10 +192,13 @@ class STeMSPrefetcher : public QueuedPrefetcher void reconstructSequence(unsigned int rmob_idx, std::vector &addresses); public: - STeMSPrefetcher(const STeMSPrefetcherParams* p); - ~STeMSPrefetcher() {} + STeMS(const STeMSPrefetcherParams* p); + ~STeMS() = default; + void calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) override; }; +} // namespace Prefetcher + #endif//__MEM_CACHE_PREFETCH_SPATIO_TEMPORAL_MEMORY_STREAMING_HH__ diff --git a/src/mem/cache/prefetch/stride.cc b/src/mem/cache/prefetch/stride.cc index 1d1a2a90e..8e47d9b55 100644 --- a/src/mem/cache/prefetch/stride.cc +++ b/src/mem/cache/prefetch/stride.cc @@ -56,13 +56,15 @@ #include "mem/cache/replacement_policies/base.hh" #include "params/StridePrefetcher.hh" -StridePrefetcher::StrideEntry::StrideEntry() +namespace Prefetcher { + +Stride::StrideEntry::StrideEntry() { invalidate(); } void -StridePrefetcher::StrideEntry::invalidate() +Stride::StrideEntry::invalidate() { instAddr = 0; lastAddr = 0; @@ -71,8 +73,8 @@ StridePrefetcher::StrideEntry::invalidate() confidence = 0; } -StridePrefetcher::StridePrefetcher(const StridePrefetcherParams *p) - : QueuedPrefetcher(p), +Stride::Stride(const StridePrefetcherParams *p) + : Queued(p), maxConf(p->max_conf), threshConf(p->thresh_conf), minConf(p->min_conf), @@ -86,8 +88,8 @@ StridePrefetcher::StridePrefetcher(const StridePrefetcherParams *p) assert(isPowerOf2(pcTableSets)); } -StridePrefetcher::PCTable* -StridePrefetcher::findTable(int context) +Stride::PCTable* +Stride::findTable(int context) { // Check if table for given context exists auto it = pcTables.find(context); @@ -98,8 +100,8 @@ StridePrefetcher::findTable(int context) return allocateNewContext(context); } -StridePrefetcher::PCTable* -StridePrefetcher::allocateNewContext(int context) +Stride::PCTable* +Stride::allocateNewContext(int context) { // Create new table auto insertion_result = pcTables.insert(std::make_pair(context, @@ -111,7 +113,7 @@ StridePrefetcher::allocateNewContext(int context) return &(insertion_result.first->second); } -StridePrefetcher::PCTable::PCTable(int assoc, int sets, const std::string name, +Stride::PCTable::PCTable(int assoc, int sets, const std::string name, BaseReplacementPolicy* replacementPolicy) : pcTableSets(sets), _name(name), entries(pcTableSets), replacementPolicy(replacementPolicy) @@ -129,12 +131,12 @@ StridePrefetcher::PCTable::PCTable(int assoc, int sets, const std::string name, } } -StridePrefetcher::PCTable::~PCTable() +Stride::PCTable::~PCTable() { } void -StridePrefetcher::calculatePrefetch(const PrefetchInfo &pfi, +Stride::calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) { if (!pfi.hasPC()) { @@ -214,15 +216,15 @@ StridePrefetcher::calculatePrefetch(const PrefetchInfo &pfi, } inline Addr -StridePrefetcher::PCTable::pcHash(Addr pc) const +Stride::PCTable::pcHash(Addr pc) const { Addr hash1 = pc >> 1; Addr hash2 = hash1 >> floorLog2(pcTableSets); return (hash1 ^ hash2) & (Addr)(pcTableSets - 1); } -inline StridePrefetcher::StrideEntry* -StridePrefetcher::PCTable::findVictim(Addr pc) +inline Stride::StrideEntry* +Stride::PCTable::findVictim(Addr pc) { // Rand replacement for now int set = pcHash(pc); @@ -243,8 +245,8 @@ StridePrefetcher::PCTable::findVictim(Addr pc) return victim; } -inline StridePrefetcher::StrideEntry* -StridePrefetcher::PCTable::findEntry(Addr pc, bool is_secure) +inline Stride::StrideEntry* +Stride::PCTable::findEntry(Addr pc, bool is_secure) { int set = pcHash(pc); for (auto& entry : entries[set]) { @@ -259,8 +261,10 @@ StridePrefetcher::PCTable::findEntry(Addr pc, bool is_secure) return nullptr; } -StridePrefetcher* +} // namespace Prefetcher + +Prefetcher::Stride* StridePrefetcherParams::create() { - return new StridePrefetcher(this); + return new Prefetcher::Stride(this); } diff --git a/src/mem/cache/prefetch/stride.hh b/src/mem/cache/prefetch/stride.hh index 1526f0474..f48352754 100644 --- a/src/mem/cache/prefetch/stride.hh +++ b/src/mem/cache/prefetch/stride.hh @@ -59,7 +59,9 @@ class BaseReplacementPolicy; struct StridePrefetcherParams; -class StridePrefetcher : public QueuedPrefetcher +namespace Prefetcher { + +class Stride : public Queued { protected: const int maxConf; @@ -167,10 +169,12 @@ class StridePrefetcher : public QueuedPrefetcher PCTable* allocateNewContext(int context); public: - StridePrefetcher(const StridePrefetcherParams *p); + Stride(const StridePrefetcherParams *p); void calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) override; }; +} // namespace Prefetcher + #endif // __MEM_CACHE_PREFETCH_STRIDE_HH__ diff --git a/src/mem/cache/prefetch/tagged.cc b/src/mem/cache/prefetch/tagged.cc index eaf35ee22..55b8710d2 100644 --- a/src/mem/cache/prefetch/tagged.cc +++ b/src/mem/cache/prefetch/tagged.cc @@ -35,15 +35,17 @@ #include "params/TaggedPrefetcher.hh" -TaggedPrefetcher::TaggedPrefetcher(const TaggedPrefetcherParams *p) - : QueuedPrefetcher(p), degree(p->degree) +namespace Prefetcher { + +Tagged::Tagged(const TaggedPrefetcherParams *p) + : Queued(p), degree(p->degree) { } void -TaggedPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, - std::vector &addresses) +Tagged::calculatePrefetch(const PrefetchInfo &pfi, + std::vector &addresses) { Addr blkAddr = blockAddress(pfi.getAddr()); @@ -53,8 +55,10 @@ TaggedPrefetcher::calculatePrefetch(const PrefetchInfo &pfi, } } -TaggedPrefetcher* +} // namespace Prefetcher + +Prefetcher::Tagged* TaggedPrefetcherParams::create() { - return new TaggedPrefetcher(this); + return new Prefetcher::Tagged(this); } diff --git a/src/mem/cache/prefetch/tagged.hh b/src/mem/cache/prefetch/tagged.hh index 5fbce36a2..e8b750542 100644 --- a/src/mem/cache/prefetch/tagged.hh +++ b/src/mem/cache/prefetch/tagged.hh @@ -39,18 +39,21 @@ struct TaggedPrefetcherParams; -class TaggedPrefetcher : public QueuedPrefetcher +namespace Prefetcher { + +class Tagged : public Queued { protected: const int degree; public: - TaggedPrefetcher(const TaggedPrefetcherParams *p); - - ~TaggedPrefetcher() {} + Tagged(const TaggedPrefetcherParams *p); + ~Tagged() = default; void calculatePrefetch(const PrefetchInfo &pfi, std::vector &addresses) override; }; +} // namespace Prefetcher + #endif // __MEM_CACHE_PREFETCH_TAGGED_HH__ -- 2.30.2