From: Daniel R. Carvalho Date: Sat, 28 Dec 2019 22:38:21 +0000 (+0100) Subject: mem-cache: Create ReplacementPolicy namespace X-Git-Tag: develop-gem5-snapshot~639 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=523d42d1ceb331bdfcf5def04f56652959f0bf97;p=gem5.git mem-cache: Create ReplacementPolicy namespace Encapsulate the replacement policy classes in their own namespace. As a side effect these classes have been renamed to drop the RP suffix in the C++ code. Change-Id: Ibb65dfb584a1413492fcf11833cf91a859cbff4e Signed-off-by: Daniel R. Carvalho Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/35795 Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris Tested-by: kokoro --- diff --git a/src/mem/cache/prefetch/associative_set.hh b/src/mem/cache/prefetch/associative_set.hh index 32bfb8373..9fc7b9876 100644 --- a/src/mem/cache/prefetch/associative_set.hh +++ b/src/mem/cache/prefetch/associative_set.hh @@ -54,7 +54,7 @@ class AssociativeSet { /** Pointer to the indexing policy */ BaseIndexingPolicy* const indexingPolicy; /** Pointer to the replacement policy */ - BaseReplacementPolicy* const replacementPolicy; + ReplacementPolicy::Base* const replacementPolicy; /** Vector containing the entries of the container */ std::vector entries; @@ -66,11 +66,10 @@ class AssociativeSet { * of sets can be calculated dividing this balue by the 'assoc' value * @param idx_policy indexing policy * @param rpl_policy replacement policy - * @param initial value of the elements of the set + * @param init_val initial value of the elements of the set */ AssociativeSet(int assoc, int num_entries, BaseIndexingPolicy *idx_policy, - BaseReplacementPolicy *rpl_policy, Entry const &init_value = - Entry()); + ReplacementPolicy::Base *rpl_policy, Entry const &init_val = Entry()); /** * Find an entry within the set diff --git a/src/mem/cache/prefetch/associative_set_impl.hh b/src/mem/cache/prefetch/associative_set_impl.hh index f8316add2..4b16dbb33 100644 --- a/src/mem/cache/prefetch/associative_set_impl.hh +++ b/src/mem/cache/prefetch/associative_set_impl.hh @@ -34,7 +34,7 @@ template AssociativeSet::AssociativeSet(int assoc, int num_entries, - BaseIndexingPolicy *idx_policy, BaseReplacementPolicy *rpl_policy, + BaseIndexingPolicy *idx_policy, ReplacementPolicy::Base *rpl_policy, Entry const &init_value) : associativity(assoc), numEntries(num_entries), indexingPolicy(idx_policy), replacementPolicy(rpl_policy), entries(numEntries, init_value) diff --git a/src/mem/cache/prefetch/stride.hh b/src/mem/cache/prefetch/stride.hh index 13215c340..57179fdb5 100644 --- a/src/mem/cache/prefetch/stride.hh +++ b/src/mem/cache/prefetch/stride.hh @@ -61,7 +61,9 @@ #include "params/StridePrefetcherHashedSetAssociative.hh" class BaseIndexingPolicy; -class BaseReplacementPolicy; +namespace ReplacementPolicy { + class Base; +} struct StridePrefetcherParams; namespace Prefetcher { @@ -107,11 +109,11 @@ class Stride : public Queued const int numEntries; BaseIndexingPolicy* const indexingPolicy; - BaseReplacementPolicy* const replacementPolicy; + ReplacementPolicy::Base* const replacementPolicy; PCTableInfo(int assoc, int num_entries, BaseIndexingPolicy* indexing_policy, - BaseReplacementPolicy* replacement_policy) + ReplacementPolicy::Base* replacement_policy) : assoc(assoc), numEntries(num_entries), indexingPolicy(indexing_policy), replacementPolicy(replacement_policy) diff --git a/src/mem/cache/replacement_policies/ReplacementPolicies.py b/src/mem/cache/replacement_policies/ReplacementPolicies.py index 53ee589ad..06a49095a 100644 --- a/src/mem/cache/replacement_policies/ReplacementPolicies.py +++ b/src/mem/cache/replacement_policies/ReplacementPolicies.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 Inria +# Copyright (c) 2018-2020 Inria # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -31,31 +31,32 @@ from m5.SimObject import SimObject class BaseReplacementPolicy(SimObject): type = 'BaseReplacementPolicy' abstract = True + cxx_class = 'ReplacementPolicy::Base' cxx_header = "mem/cache/replacement_policies/base.hh" class FIFORP(BaseReplacementPolicy): type = 'FIFORP' - cxx_class = 'FIFORP' + cxx_class = 'ReplacementPolicy::FIFO' cxx_header = "mem/cache/replacement_policies/fifo_rp.hh" class SecondChanceRP(FIFORP): type = 'SecondChanceRP' - cxx_class = 'SecondChanceRP' + cxx_class = 'ReplacementPolicy::SecondChance' cxx_header = "mem/cache/replacement_policies/second_chance_rp.hh" class LFURP(BaseReplacementPolicy): type = 'LFURP' - cxx_class = 'LFURP' + cxx_class = 'ReplacementPolicy::LFU' cxx_header = "mem/cache/replacement_policies/lfu_rp.hh" class LRURP(BaseReplacementPolicy): type = 'LRURP' - cxx_class = 'LRURP' + cxx_class = 'ReplacementPolicy::LRU' cxx_header = "mem/cache/replacement_policies/lru_rp.hh" class BIPRP(LRURP): type = 'BIPRP' - cxx_class = 'BIPRP' + cxx_class = 'ReplacementPolicy::BIP' cxx_header = "mem/cache/replacement_policies/bip_rp.hh" btp = Param.Percent(3, "Percentage of blocks to be inserted as MRU") @@ -64,17 +65,17 @@ class LIPRP(BIPRP): class MRURP(BaseReplacementPolicy): type = 'MRURP' - cxx_class = 'MRURP' + cxx_class = 'ReplacementPolicy::MRU' cxx_header = "mem/cache/replacement_policies/mru_rp.hh" class RandomRP(BaseReplacementPolicy): type = 'RandomRP' - cxx_class = 'RandomRP' + cxx_class = 'ReplacementPolicy::Random' cxx_header = "mem/cache/replacement_policies/random_rp.hh" class BRRIPRP(BaseReplacementPolicy): type = 'BRRIPRP' - cxx_class = 'BRRIPRP' + cxx_class = 'ReplacementPolicy::BRRIP' cxx_header = "mem/cache/replacement_policies/brrip_rp.hh" num_bits = Param.Int(2, "Number of bits per RRPV") hit_priority = Param.Bool(False, @@ -91,11 +92,11 @@ class NRURP(BRRIPRP): class TreePLRURP(BaseReplacementPolicy): type = 'TreePLRURP' - cxx_class = 'TreePLRURP' + cxx_class = 'ReplacementPolicy::TreePLRU' cxx_header = "mem/cache/replacement_policies/tree_plru_rp.hh" num_leaves = Param.Int(Parent.assoc, "Number of leaves in each tree") class WeightedLRURP(BaseReplacementPolicy): type = "WeightedLRURP" - cxx_class = "WeightedLRUPolicy" + cxx_class = "ReplacementPolicy::WeightedLRU" cxx_header = "mem/cache/replacement_policies/weighted_lru_rp.hh" diff --git a/src/mem/cache/replacement_policies/base.hh b/src/mem/cache/replacement_policies/base.hh index 001961f6a..f00ab67d5 100644 --- a/src/mem/cache/replacement_policies/base.hh +++ b/src/mem/cache/replacement_policies/base.hh @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -40,26 +40,17 @@ */ typedef std::vector ReplacementCandidates; +namespace ReplacementPolicy { + /** * A common base class of cache replacement policy objects. */ -class BaseReplacementPolicy : public SimObject +class Base : public SimObject { public: - /** - * Convenience typedef. - */ typedef BaseReplacementPolicyParams Params; - - /** - * Construct and initiliaze this replacement policy. - */ - BaseReplacementPolicy(const Params *p) : SimObject(p) {} - - /** - * Destructor. - */ - virtual ~BaseReplacementPolicy() {} + Base(const Params *p) : SimObject(p) {} + virtual ~Base() = default; /** * Invalidate replacement data to set it as the next probable victim. @@ -102,4 +93,6 @@ class BaseReplacementPolicy : public SimObject virtual std::shared_ptr instantiateEntry() = 0; }; +} // namespace ReplacementPolicy + #endif // __MEM_CACHE_REPLACEMENT_POLICIES_BASE_HH__ diff --git a/src/mem/cache/replacement_policies/bip_rp.cc b/src/mem/cache/replacement_policies/bip_rp.cc index d65d21427..0086136d5 100644 --- a/src/mem/cache/replacement_policies/bip_rp.cc +++ b/src/mem/cache/replacement_policies/bip_rp.cc @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,13 +34,15 @@ #include "params/BIPRP.hh" #include "sim/core.hh" -BIPRP::BIPRP(const Params *p) - : LRURP(p), btp(p->btp) +namespace ReplacementPolicy { + +BIP::BIP(const Params *p) + : LRU(p), btp(p->btp) { } void -BIPRP::reset(const std::shared_ptr& replacement_data) const +BIP::reset(const std::shared_ptr& replacement_data) const { std::shared_ptr casted_replacement_data = std::static_pointer_cast(replacement_data); @@ -54,8 +56,10 @@ BIPRP::reset(const std::shared_ptr& replacement_data) const } } -BIPRP* +} // namespace ReplacementPolicy + +ReplacementPolicy::BIP* BIPRPParams::create() { - return new BIPRP(this); + return new ReplacementPolicy::BIP(this); } diff --git a/src/mem/cache/replacement_policies/bip_rp.hh b/src/mem/cache/replacement_policies/bip_rp.hh index af26ba5a2..9d91f8fc8 100644 --- a/src/mem/cache/replacement_policies/bip_rp.hh +++ b/src/mem/cache/replacement_policies/bip_rp.hh @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,7 +46,9 @@ struct BIPRPParams; -class BIPRP : public LRURP +namespace ReplacementPolicy { + +class BIP : public LRU { protected: /** @@ -56,18 +58,9 @@ class BIPRP : public LRURP const unsigned btp; public: - /** Convenience typedef. */ typedef BIPRPParams Params; - - /** - * Construct and initiliaze this replacement policy. - */ - BIPRP(const Params *p); - - /** - * Destructor. - */ - ~BIPRP() {} + BIP(const Params *p); + ~BIP() = default; /** * Reset replacement data for an entry. Used when an entry is inserted. @@ -80,4 +73,6 @@ class BIPRP : public LRURP override; }; +} // namespace ReplacementPolicy + #endif // __MEM_CACHE_REPLACEMENT_POLICIES_BIP_RP_HH__ diff --git a/src/mem/cache/replacement_policies/brrip_rp.cc b/src/mem/cache/replacement_policies/brrip_rp.cc index 897b19e12..fca1cc190 100644 --- a/src/mem/cache/replacement_policies/brrip_rp.cc +++ b/src/mem/cache/replacement_policies/brrip_rp.cc @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,15 +35,17 @@ #include "base/random.hh" #include "params/BRRIPRP.hh" -BRRIPRP::BRRIPRP(const Params *p) - : BaseReplacementPolicy(p), - numRRPVBits(p->num_bits), hitPriority(p->hit_priority), btp(p->btp) +namespace ReplacementPolicy { + +BRRIP::BRRIP(const Params *p) + : Base(p), numRRPVBits(p->num_bits), hitPriority(p->hit_priority), + btp(p->btp) { fatal_if(numRRPVBits <= 0, "There should be at least one bit per RRPV.\n"); } void -BRRIPRP::invalidate(const std::shared_ptr& replacement_data) +BRRIP::invalidate(const std::shared_ptr& replacement_data) const { std::shared_ptr casted_replacement_data = @@ -54,7 +56,7 @@ const } void -BRRIPRP::touch(const std::shared_ptr& replacement_data) const +BRRIP::touch(const std::shared_ptr& replacement_data) const { std::shared_ptr casted_replacement_data = std::static_pointer_cast(replacement_data); @@ -70,7 +72,7 @@ BRRIPRP::touch(const std::shared_ptr& replacement_data) const } void -BRRIPRP::reset(const std::shared_ptr& replacement_data) const +BRRIP::reset(const std::shared_ptr& replacement_data) const { std::shared_ptr casted_replacement_data = std::static_pointer_cast(replacement_data); @@ -88,7 +90,7 @@ BRRIPRP::reset(const std::shared_ptr& replacement_data) const } ReplaceableEntry* -BRRIPRP::getVictim(const ReplacementCandidates& candidates) const +BRRIP::getVictim(const ReplacementCandidates& candidates) const { // There must be at least one replacement candidate assert(candidates.size() > 0); @@ -137,13 +139,15 @@ BRRIPRP::getVictim(const ReplacementCandidates& candidates) const } std::shared_ptr -BRRIPRP::instantiateEntry() +BRRIP::instantiateEntry() { return std::shared_ptr(new BRRIPReplData(numRRPVBits)); } -BRRIPRP* +} // namespace ReplacementPolicy + +ReplacementPolicy::BRRIP* BRRIPRPParams::create() { - return new BRRIPRP(this); + return new ReplacementPolicy::BRRIP(this); } diff --git a/src/mem/cache/replacement_policies/brrip_rp.hh b/src/mem/cache/replacement_policies/brrip_rp.hh index 6510978ee..c84e9d596 100644 --- a/src/mem/cache/replacement_policies/brrip_rp.hh +++ b/src/mem/cache/replacement_policies/brrip_rp.hh @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -57,7 +57,9 @@ struct BRRIPRPParams; -class BRRIPRP : public BaseReplacementPolicy +namespace ReplacementPolicy { + +class BRRIP : public Base { protected: /** BRRIP-specific implementation of replacement data. */ @@ -106,18 +108,9 @@ class BRRIPRP : public BaseReplacementPolicy const unsigned btp; public: - /** Convenience typedef. */ typedef BRRIPRPParams Params; - - /** - * Construct and initiliaze this replacement policy. - */ - BRRIPRP(const Params *p); - - /** - * Destructor. - */ - ~BRRIPRP() {} + BRRIP(const Params *p); + ~BRRIP() = default; /** * Invalidate replacement data to set it as the next probable victim. @@ -162,4 +155,6 @@ class BRRIPRP : public BaseReplacementPolicy std::shared_ptr instantiateEntry() override; }; +} // namespace ReplacementPolicy + #endif // __MEM_CACHE_REPLACEMENT_POLICIES_BRRIP_RP_HH__ diff --git a/src/mem/cache/replacement_policies/fifo_rp.cc b/src/mem/cache/replacement_policies/fifo_rp.cc index 0998a82e6..2371d7659 100644 --- a/src/mem/cache/replacement_policies/fifo_rp.cc +++ b/src/mem/cache/replacement_policies/fifo_rp.cc @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,13 +34,15 @@ #include "params/FIFORP.hh" #include "sim/core.hh" -FIFORP::FIFORP(const Params *p) - : BaseReplacementPolicy(p) +namespace ReplacementPolicy { + +FIFO::FIFO(const Params *p) + : Base(p) { } void -FIFORP::invalidate(const std::shared_ptr& replacement_data) +FIFO::invalidate(const std::shared_ptr& replacement_data) const { // Reset insertion tick @@ -49,13 +51,13 @@ const } void -FIFORP::touch(const std::shared_ptr& replacement_data) const +FIFO::touch(const std::shared_ptr& replacement_data) const { // A touch does not modify the insertion tick } void -FIFORP::reset(const std::shared_ptr& replacement_data) const +FIFO::reset(const std::shared_ptr& replacement_data) const { // Set insertion tick std::static_pointer_cast( @@ -63,7 +65,7 @@ FIFORP::reset(const std::shared_ptr& replacement_data) const } ReplaceableEntry* -FIFORP::getVictim(const ReplacementCandidates& candidates) const +FIFO::getVictim(const ReplacementCandidates& candidates) const { // There must be at least one replacement candidate assert(candidates.size() > 0); @@ -84,13 +86,15 @@ FIFORP::getVictim(const ReplacementCandidates& candidates) const } std::shared_ptr -FIFORP::instantiateEntry() +FIFO::instantiateEntry() { return std::shared_ptr(new FIFOReplData()); } -FIFORP* +} // namespace ReplacementPolicy + +ReplacementPolicy::FIFO* FIFORPParams::create() { - return new FIFORP(this); + return new ReplacementPolicy::FIFO(this); } diff --git a/src/mem/cache/replacement_policies/fifo_rp.hh b/src/mem/cache/replacement_policies/fifo_rp.hh index a3478e2fd..03a4aec10 100644 --- a/src/mem/cache/replacement_policies/fifo_rp.hh +++ b/src/mem/cache/replacement_policies/fifo_rp.hh @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,9 @@ struct FIFORPParams; -class FIFORP : public BaseReplacementPolicy +namespace ReplacementPolicy { + +class FIFO : public Base { protected: /** FIFO-specific implementation of replacement data. */ @@ -57,18 +59,9 @@ class FIFORP : public BaseReplacementPolicy }; public: - /** Convenience typedef. */ typedef FIFORPParams Params; - - /** - * Construct and initiliaze this replacement policy. - */ - FIFORP(const Params *p); - - /** - * Destructor. - */ - ~FIFORP() {} + FIFO(const Params *p); + ~FIFO() = default; /** * Invalidate replacement data to set it as the next probable victim. @@ -114,4 +107,6 @@ class FIFORP : public BaseReplacementPolicy std::shared_ptr instantiateEntry() override; }; +} // namespace ReplacementPolicy + #endif // __MEM_CACHE_REPLACEMENT_POLICIES_FIFO_RP_HH__ diff --git a/src/mem/cache/replacement_policies/lfu_rp.cc b/src/mem/cache/replacement_policies/lfu_rp.cc index 734994e1b..0f3b24249 100644 --- a/src/mem/cache/replacement_policies/lfu_rp.cc +++ b/src/mem/cache/replacement_policies/lfu_rp.cc @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,13 +33,15 @@ #include "params/LFURP.hh" -LFURP::LFURP(const Params *p) - : BaseReplacementPolicy(p) +namespace ReplacementPolicy { + +LFU::LFU(const Params *p) + : Base(p) { } void -LFURP::invalidate(const std::shared_ptr& replacement_data) +LFU::invalidate(const std::shared_ptr& replacement_data) const { // Reset reference count @@ -47,21 +49,21 @@ const } void -LFURP::touch(const std::shared_ptr& replacement_data) const +LFU::touch(const std::shared_ptr& replacement_data) const { // Update reference count std::static_pointer_cast(replacement_data)->refCount++; } void -LFURP::reset(const std::shared_ptr& replacement_data) const +LFU::reset(const std::shared_ptr& replacement_data) const { // Reset reference count std::static_pointer_cast(replacement_data)->refCount = 1; } ReplaceableEntry* -LFURP::getVictim(const ReplacementCandidates& candidates) const +LFU::getVictim(const ReplacementCandidates& candidates) const { // There must be at least one replacement candidate assert(candidates.size() > 0); @@ -82,13 +84,15 @@ LFURP::getVictim(const ReplacementCandidates& candidates) const } std::shared_ptr -LFURP::instantiateEntry() +LFU::instantiateEntry() { return std::shared_ptr(new LFUReplData()); } -LFURP* +} // namespace ReplacementPolicy + +ReplacementPolicy::LFU* LFURPParams::create() { - return new LFURP(this); + return new ReplacementPolicy::LFU(this); } diff --git a/src/mem/cache/replacement_policies/lfu_rp.hh b/src/mem/cache/replacement_policies/lfu_rp.hh index dee133065..36640e7de 100644 --- a/src/mem/cache/replacement_policies/lfu_rp.hh +++ b/src/mem/cache/replacement_policies/lfu_rp.hh @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,9 @@ struct LFURPParams; -class LFURP : public BaseReplacementPolicy +namespace ReplacementPolicy { + +class LFU : public Base { protected: /** LFU-specific implementation of replacement data. */ @@ -57,18 +59,9 @@ class LFURP : public BaseReplacementPolicy }; public: - /** Convenience typedef. */ typedef LFURPParams Params; - - /** - * Construct and initiliaze this replacement policy. - */ - LFURP(const Params *p); - - /** - * Destructor. - */ - ~LFURP() {} + LFU(const Params *p); + ~LFU() = default; /** * Invalidate replacement data to set it as the next probable victim. @@ -114,4 +107,6 @@ class LFURP : public BaseReplacementPolicy std::shared_ptr instantiateEntry() override; }; +} // namespace ReplacementPolicy + #endif // __MEM_CACHE_REPLACEMENT_POLICIES_LFU_RP_HH__ diff --git a/src/mem/cache/replacement_policies/lru_rp.cc b/src/mem/cache/replacement_policies/lru_rp.cc index f7d1f1d28..9775c154c 100644 --- a/src/mem/cache/replacement_policies/lru_rp.cc +++ b/src/mem/cache/replacement_policies/lru_rp.cc @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,13 +34,15 @@ #include "params/LRURP.hh" #include "sim/core.hh" -LRURP::LRURP(const Params *p) - : BaseReplacementPolicy(p) +namespace ReplacementPolicy { + +LRU::LRU(const Params *p) + : Base(p) { } void -LRURP::invalidate(const std::shared_ptr& replacement_data) +LRU::invalidate(const std::shared_ptr& replacement_data) const { // Reset last touch timestamp @@ -49,7 +51,7 @@ const } void -LRURP::touch(const std::shared_ptr& replacement_data) const +LRU::touch(const std::shared_ptr& replacement_data) const { // Update last touch timestamp std::static_pointer_cast( @@ -57,7 +59,7 @@ LRURP::touch(const std::shared_ptr& replacement_data) const } void -LRURP::reset(const std::shared_ptr& replacement_data) const +LRU::reset(const std::shared_ptr& replacement_data) const { // Set last touch timestamp std::static_pointer_cast( @@ -65,7 +67,7 @@ LRURP::reset(const std::shared_ptr& replacement_data) const } ReplaceableEntry* -LRURP::getVictim(const ReplacementCandidates& candidates) const +LRU::getVictim(const ReplacementCandidates& candidates) const { // There must be at least one replacement candidate assert(candidates.size() > 0); @@ -86,13 +88,15 @@ LRURP::getVictim(const ReplacementCandidates& candidates) const } std::shared_ptr -LRURP::instantiateEntry() +LRU::instantiateEntry() { return std::shared_ptr(new LRUReplData()); } -LRURP* +} // namespace ReplacementPolicy + +ReplacementPolicy::LRU* LRURPParams::create() { - return new LRURP(this); + return new ReplacementPolicy::LRU(this); } diff --git a/src/mem/cache/replacement_policies/lru_rp.hh b/src/mem/cache/replacement_policies/lru_rp.hh index 284178b67..bb1b314c5 100644 --- a/src/mem/cache/replacement_policies/lru_rp.hh +++ b/src/mem/cache/replacement_policies/lru_rp.hh @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,7 +39,9 @@ struct LRURPParams; -class LRURP : public BaseReplacementPolicy +namespace ReplacementPolicy { + +class LRU : public Base { protected: /** LRU-specific implementation of replacement data. */ @@ -55,18 +57,9 @@ class LRURP : public BaseReplacementPolicy }; public: - /** Convenience typedef. */ typedef LRURPParams Params; - - /** - * Construct and initiliaze this replacement policy. - */ - LRURP(const Params *p); - - /** - * Destructor. - */ - ~LRURP() {} + LRU(const Params *p); + ~LRU() = default; /** * Invalidate replacement data to set it as the next probable victim. @@ -112,4 +105,6 @@ class LRURP : public BaseReplacementPolicy std::shared_ptr instantiateEntry() override; }; +} // namespace ReplacementPolicy + #endif // __MEM_CACHE_REPLACEMENT_POLICIES_LRU_RP_HH__ diff --git a/src/mem/cache/replacement_policies/mru_rp.cc b/src/mem/cache/replacement_policies/mru_rp.cc index 892f9a000..04a777073 100644 --- a/src/mem/cache/replacement_policies/mru_rp.cc +++ b/src/mem/cache/replacement_policies/mru_rp.cc @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,13 +34,15 @@ #include "params/MRURP.hh" #include "sim/core.hh" -MRURP::MRURP(const Params *p) - : BaseReplacementPolicy(p) +namespace ReplacementPolicy { + +MRU::MRU(const Params *p) + : Base(p) { } void -MRURP::invalidate(const std::shared_ptr& replacement_data) +MRU::invalidate(const std::shared_ptr& replacement_data) const { // Reset last touch timestamp @@ -49,7 +51,7 @@ const } void -MRURP::touch(const std::shared_ptr& replacement_data) const +MRU::touch(const std::shared_ptr& replacement_data) const { // Update last touch timestamp std::static_pointer_cast( @@ -57,7 +59,7 @@ MRURP::touch(const std::shared_ptr& replacement_data) const } void -MRURP::reset(const std::shared_ptr& replacement_data) const +MRU::reset(const std::shared_ptr& replacement_data) const { // Set last touch timestamp std::static_pointer_cast( @@ -65,7 +67,7 @@ MRURP::reset(const std::shared_ptr& replacement_data) const } ReplaceableEntry* -MRURP::getVictim(const ReplacementCandidates& candidates) const +MRU::getVictim(const ReplacementCandidates& candidates) const { // There must be at least one replacement candidate assert(candidates.size() > 0); @@ -91,13 +93,15 @@ MRURP::getVictim(const ReplacementCandidates& candidates) const } std::shared_ptr -MRURP::instantiateEntry() +MRU::instantiateEntry() { return std::shared_ptr(new MRUReplData()); } -MRURP* +} // namespace ReplacementPolicy + +ReplacementPolicy::MRU* MRURPParams::create() { - return new MRURP(this); + return new ReplacementPolicy::MRU(this); } diff --git a/src/mem/cache/replacement_policies/mru_rp.hh b/src/mem/cache/replacement_policies/mru_rp.hh index 7ca6e6607..2561556eb 100644 --- a/src/mem/cache/replacement_policies/mru_rp.hh +++ b/src/mem/cache/replacement_policies/mru_rp.hh @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,9 @@ struct MRURPParams; -class MRURP : public BaseReplacementPolicy +namespace ReplacementPolicy { + +class MRU : public Base { protected: /** MRU-specific implementation of replacement data. */ @@ -57,18 +59,9 @@ class MRURP : public BaseReplacementPolicy }; public: - /** Convenience typedef. */ typedef MRURPParams Params; - - /** - * Construct and initiliaze this replacement policy. - */ - MRURP(const Params *p); - - /** - * Destructor. - */ - ~MRURP() {} + MRU(const Params *p); + ~MRU() = default; /** * Invalidate replacement data to set it as the next probable victim. @@ -114,4 +107,6 @@ class MRURP : public BaseReplacementPolicy std::shared_ptr instantiateEntry() override; }; +} // namespace ReplacementPolicy + #endif // __MEM_CACHE_REPLACEMENT_POLICIES_MRU_RP_HH__ diff --git a/src/mem/cache/replacement_policies/random_rp.cc b/src/mem/cache/replacement_policies/random_rp.cc index 31910937c..314e861d4 100644 --- a/src/mem/cache/replacement_policies/random_rp.cc +++ b/src/mem/cache/replacement_policies/random_rp.cc @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,13 +34,15 @@ #include "base/random.hh" #include "params/RandomRP.hh" -RandomRP::RandomRP(const Params *p) - : BaseReplacementPolicy(p) +namespace ReplacementPolicy { + +Random::Random(const Params *p) + : Base(p) { } void -RandomRP::invalidate(const std::shared_ptr& replacement_data) +Random::invalidate(const std::shared_ptr& replacement_data) const { // Unprioritize replacement data victimization @@ -49,12 +51,12 @@ const } void -RandomRP::touch(const std::shared_ptr& replacement_data) const +Random::touch(const std::shared_ptr& replacement_data) const { } void -RandomRP::reset(const std::shared_ptr& replacement_data) const +Random::reset(const std::shared_ptr& replacement_data) const { // Unprioritize replacement data victimization std::static_pointer_cast( @@ -62,7 +64,7 @@ RandomRP::reset(const std::shared_ptr& replacement_data) const } ReplaceableEntry* -RandomRP::getVictim(const ReplacementCandidates& candidates) const +Random::getVictim(const ReplacementCandidates& candidates) const { // There must be at least one replacement candidate assert(candidates.size() > 0); @@ -85,13 +87,15 @@ RandomRP::getVictim(const ReplacementCandidates& candidates) const } std::shared_ptr -RandomRP::instantiateEntry() +Random::instantiateEntry() { return std::shared_ptr(new RandomReplData()); } -RandomRP* +} // namespace ReplacementPolicy + +ReplacementPolicy::Random* RandomRPParams::create() { - return new RandomRP(this); + return new ReplacementPolicy::Random(this); } diff --git a/src/mem/cache/replacement_policies/random_rp.hh b/src/mem/cache/replacement_policies/random_rp.hh index c2a6d2518..a49921160 100644 --- a/src/mem/cache/replacement_policies/random_rp.hh +++ b/src/mem/cache/replacement_policies/random_rp.hh @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,10 +39,12 @@ struct RandomRPParams; -class RandomRP : public BaseReplacementPolicy +namespace ReplacementPolicy { + +class Random : public Base { protected: - /** MRU-specific implementation of replacement data. */ + /** Random-specific implementation of replacement data. */ struct RandomReplData : ReplacementData { /** @@ -58,18 +60,9 @@ class RandomRP : public BaseReplacementPolicy }; public: - /** Convenience typedef. */ typedef RandomRPParams Params; - - /** - * Construct and initiliaze this replacement policy. - */ - RandomRP(const Params *p); - - /** - * Destructor. - */ - ~RandomRP() {} + Random(const Params *p); + ~Random() = default; /** * Invalidate replacement data to set it as the next probable victim. @@ -115,4 +108,6 @@ class RandomRP : public BaseReplacementPolicy std::shared_ptr instantiateEntry() override; }; +} // namespace ReplacementPolicy + #endif // __MEM_CACHE_REPLACEMENT_POLICIES_RANDOM_RP_HH__ diff --git a/src/mem/cache/replacement_policies/replaceable_entry.hh b/src/mem/cache/replacement_policies/replaceable_entry.hh index 505cc1986..85de6d185 100644 --- a/src/mem/cache/replacement_policies/replaceable_entry.hh +++ b/src/mem/cache/replacement_policies/replaceable_entry.hh @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,12 +34,16 @@ #include "base/cprintf.hh" +namespace ReplacementPolicy { + /** * The replacement data needed by replacement policies. Each replacement policy * should have its own implementation of replacement data. */ struct ReplacementData {}; +} // namespace ReplacementPolicy + /** * A replaceable entry is a basic entry in a 2d table-like structure that needs * to have replacement functionality. This entry is located in a specific row @@ -71,7 +75,7 @@ class ReplaceableEntry * Replacement data associated to this entry. * It must be instantiated by the replacement policy before being used. */ - std::shared_ptr replacementData; + std::shared_ptr replacementData; /** * Set both the set and way. Should be called only once. diff --git a/src/mem/cache/replacement_policies/second_chance_rp.cc b/src/mem/cache/replacement_policies/second_chance_rp.cc index 14402293a..ddc68d76e 100644 --- a/src/mem/cache/replacement_policies/second_chance_rp.cc +++ b/src/mem/cache/replacement_policies/second_chance_rp.cc @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,27 +32,29 @@ #include "params/SecondChanceRP.hh" -SecondChanceRP::SecondChanceRP(const Params *p) - : FIFORP(p) +namespace ReplacementPolicy { + +SecondChance::SecondChance(const Params *p) + : FIFO(p) { } void -SecondChanceRP::useSecondChance( +SecondChance::useSecondChance( const std::shared_ptr& replacement_data) const { // Reset FIFO data - FIFORP::reset(replacement_data); + FIFO::reset(replacement_data); // Use second chance replacement_data->hasSecondChance = false; } void -SecondChanceRP::invalidate( +SecondChance::invalidate( const std::shared_ptr& replacement_data) const { - FIFORP::invalidate(replacement_data); + FIFO::invalidate(replacement_data); // Do not give a second chance to invalid entries std::static_pointer_cast( @@ -60,10 +62,10 @@ SecondChanceRP::invalidate( } void -SecondChanceRP::touch(const std::shared_ptr& - replacement_data) const +SecondChance::touch( + const std::shared_ptr& replacement_data) const { - FIFORP::touch(replacement_data); + FIFO::touch(replacement_data); // Whenever an entry is touched, it is given a second chance std::static_pointer_cast( @@ -71,10 +73,10 @@ SecondChanceRP::touch(const std::shared_ptr& } void -SecondChanceRP::reset(const std::shared_ptr& - replacement_data) const +SecondChance::reset( + const std::shared_ptr& replacement_data) const { - FIFORP::reset(replacement_data); + FIFO::reset(replacement_data); // Entries are inserted with a second chance std::static_pointer_cast( @@ -82,7 +84,7 @@ SecondChanceRP::reset(const std::shared_ptr& } ReplaceableEntry* -SecondChanceRP::getVictim(const ReplacementCandidates& candidates) const +SecondChance::getVictim(const ReplacementCandidates& candidates) const { // There must be at least one replacement candidate assert(candidates.size() > 0); @@ -106,7 +108,7 @@ SecondChanceRP::getVictim(const ReplacementCandidates& candidates) const bool search_victim = true; while (search_victim) { // Do a FIFO victim search - victim = FIFORP::getVictim(candidates); + victim = FIFO::getVictim(candidates); // Cast victim's replacement data for code readability std::shared_ptr victim_replacement_data = @@ -126,13 +128,15 @@ SecondChanceRP::getVictim(const ReplacementCandidates& candidates) const } std::shared_ptr -SecondChanceRP::instantiateEntry() +SecondChance::instantiateEntry() { return std::shared_ptr(new SecondChanceReplData()); } -SecondChanceRP* +} // namespace ReplacementPolicy + +ReplacementPolicy::SecondChance* SecondChanceRPParams::create() { - return new SecondChanceRP(this); + return new ReplacementPolicy::SecondChance(this); } diff --git a/src/mem/cache/replacement_policies/second_chance_rp.hh b/src/mem/cache/replacement_policies/second_chance_rp.hh index 83815d720..d13ea7bc7 100644 --- a/src/mem/cache/replacement_policies/second_chance_rp.hh +++ b/src/mem/cache/replacement_policies/second_chance_rp.hh @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,7 +43,9 @@ struct SecondChanceRPParams; -class SecondChanceRP : public FIFORP +namespace ReplacementPolicy { + +class SecondChance : public FIFO { protected: /** Second-Chance-specific implementation of replacement data. */ @@ -52,7 +54,7 @@ class SecondChanceRP : public FIFORP /** * This is different from isTouched because isTouched accounts only * for insertion, while this bit is reset every new re-insertion. - * @sa SecondChanceRP. + * @sa SecondChance. */ bool hasSecondChance; @@ -71,18 +73,9 @@ class SecondChanceRP : public FIFORP const std::shared_ptr& replacement_data) const; public: - /** Convenience typedef. */ typedef SecondChanceRPParams Params; - - /** - * Construct and initiliaze this replacement policy. - */ - SecondChanceRP(const Params *p); - - /** - * Destructor. - */ - ~SecondChanceRP() {} + SecondChance(const Params *p); + ~SecondChance() = default; /** * Invalidate replacement data to set it as the next probable victim. @@ -130,4 +123,6 @@ class SecondChanceRP : public FIFORP std::shared_ptr instantiateEntry() override; }; +} // namespace ReplacementPolicy + #endif // __MEM_CACHE_REPLACEMENT_POLICIES_SECOND_CHANCE_RP_HH__ diff --git a/src/mem/cache/replacement_policies/tree_plru_rp.cc b/src/mem/cache/replacement_policies/tree_plru_rp.cc index eb2d0392b..eaf5cb488 100644 --- a/src/mem/cache/replacement_policies/tree_plru_rp.cc +++ b/src/mem/cache/replacement_policies/tree_plru_rp.cc @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -40,6 +40,8 @@ #include "base/logging.hh" #include "params/TreePLRURP.hh" +namespace ReplacementPolicy { + /** * Get the index of the parent of the given indexed subtree. * @@ -89,22 +91,21 @@ isRightSubtree(const uint64_t index) return index%2 == 0; } -TreePLRURP::TreePLRUReplData::TreePLRUReplData( +TreePLRU::TreePLRUReplData::TreePLRUReplData( const uint64_t index, std::shared_ptr tree) - : index(index), tree(tree) + : index(index), tree(tree) { } -TreePLRURP::TreePLRURP(const Params *p) - : BaseReplacementPolicy(p), numLeaves(p->num_leaves), count(0), - treeInstance(nullptr) +TreePLRU::TreePLRU(const Params *p) + : Base(p), numLeaves(p->num_leaves), count(0), treeInstance(nullptr) { fatal_if(!isPowerOf2(numLeaves), "Number of leaves must be non-zero and a power of 2"); } void -TreePLRURP::invalidate( +TreePLRU::invalidate( const std::shared_ptr& replacement_data) const { // Cast replacement data @@ -130,7 +131,7 @@ TreePLRURP::invalidate( } void -TreePLRURP::touch(const std::shared_ptr& replacement_data) +TreePLRU::touch(const std::shared_ptr& replacement_data) const { // Cast replacement data @@ -156,7 +157,7 @@ const } void -TreePLRURP::reset(const std::shared_ptr& replacement_data) +TreePLRU::reset(const std::shared_ptr& replacement_data) const { // A reset has the same functionality of a touch @@ -164,7 +165,7 @@ const } ReplaceableEntry* -TreePLRURP::getVictim(const ReplacementCandidates& candidates) const +TreePLRU::getVictim(const ReplacementCandidates& candidates) const { // There must be at least one replacement candidate assert(candidates.size() > 0); @@ -192,7 +193,7 @@ TreePLRURP::getVictim(const ReplacementCandidates& candidates) const } std::shared_ptr -TreePLRURP::instantiateEntry() +TreePLRU::instantiateEntry() { // Generate a tree instance every numLeaves created if (count % numLeaves == 0) { @@ -210,8 +211,10 @@ TreePLRURP::instantiateEntry() return std::shared_ptr(treePLRUReplData); } -TreePLRURP* +} // namespace ReplacementPolicy + +ReplacementPolicy::TreePLRU* TreePLRURPParams::create() { - return new TreePLRURP(this); + return new ReplacementPolicy::TreePLRU(this); } diff --git a/src/mem/cache/replacement_policies/tree_plru_rp.hh b/src/mem/cache/replacement_policies/tree_plru_rp.hh index 2fcd632df..709f0a202 100644 --- a/src/mem/cache/replacement_policies/tree_plru_rp.hh +++ b/src/mem/cache/replacement_policies/tree_plru_rp.hh @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Inria + * Copyright (c) 2018-2020 Inria * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -77,7 +77,9 @@ struct TreePLRURPParams; -class TreePLRURP : public BaseReplacementPolicy +namespace ReplacementPolicy { + +class TreePLRU : public Base { private: /** @@ -149,18 +151,9 @@ class TreePLRURP : public BaseReplacementPolicy }; public: - /** Convenience typedef. */ typedef TreePLRURPParams Params; - - /** - * Construct and initiliaze this replacement policy. - */ - TreePLRURP(const Params *p); - - /** - * Destructor. - */ - ~TreePLRURP() {} + TreePLRU(const Params *p); + ~TreePLRU() = default; /** * Invalidate replacement data to set it as the next probable victim. @@ -212,4 +205,6 @@ class TreePLRURP : public BaseReplacementPolicy std::shared_ptr instantiateEntry() override; }; +} // namespace ReplacementPolicy + #endif // __MEM_CACHE_REPLACEMENT_POLICIES_TREE_PLRU_RP_HH__ diff --git a/src/mem/cache/replacement_policies/weighted_lru_rp.cc b/src/mem/cache/replacement_policies/weighted_lru_rp.cc index eeaf2a62d..3044ce701 100644 --- a/src/mem/cache/replacement_policies/weighted_lru_rp.cc +++ b/src/mem/cache/replacement_policies/weighted_lru_rp.cc @@ -38,19 +38,15 @@ #include "params/WeightedLRURP.hh" #include "sim/core.hh" -WeightedLRUPolicy::WeightedLRUPolicy(const Params* p) - : BaseReplacementPolicy(p) -{ -} +namespace ReplacementPolicy { -WeightedLRUPolicy * -WeightedLRURPParams::create() +WeightedLRU::WeightedLRU(const Params* p) + : Base(p) { - return new WeightedLRUPolicy(this); } void -WeightedLRUPolicy::touch(const std::shared_ptr& +WeightedLRU::touch(const std::shared_ptr& replacement_data) const { std::static_pointer_cast(replacement_data)-> @@ -58,7 +54,7 @@ WeightedLRUPolicy::touch(const std::shared_ptr& } void -WeightedLRUPolicy::touch(const std::shared_ptr& +WeightedLRU::touch(const std::shared_ptr& replacement_data, int occupancy) const { std::static_pointer_cast(replacement_data)-> @@ -68,7 +64,7 @@ WeightedLRUPolicy::touch(const std::shared_ptr& } ReplaceableEntry* -WeightedLRUPolicy::getVictim(const ReplacementCandidates& candidates) const +WeightedLRU::getVictim(const ReplacementCandidates& candidates) const { assert(candidates.size() > 0); @@ -102,13 +98,13 @@ WeightedLRUPolicy::getVictim(const ReplacementCandidates& candidates) const } std::shared_ptr -WeightedLRUPolicy::instantiateEntry() +WeightedLRU::instantiateEntry() { return std::shared_ptr(new WeightedLRUReplData); } void -WeightedLRUPolicy::reset(const std::shared_ptr& +WeightedLRU::reset(const std::shared_ptr& replacement_data) const { // Set last touch timestamp @@ -117,10 +113,18 @@ WeightedLRUPolicy::reset(const std::shared_ptr& } void -WeightedLRUPolicy::invalidate(const std::shared_ptr& +WeightedLRU::invalidate(const std::shared_ptr& replacement_data) const { // Reset last touch timestamp std::static_pointer_cast( replacement_data)->last_touch_tick = Tick(0); } + +} // namespace ReplacementPolicy + +ReplacementPolicy::WeightedLRU* +WeightedLRURPParams::create() +{ + return new ReplacementPolicy::WeightedLRU(this); +} diff --git a/src/mem/cache/replacement_policies/weighted_lru_rp.hh b/src/mem/cache/replacement_policies/weighted_lru_rp.hh index eea2fb512..74e926eaf 100644 --- a/src/mem/cache/replacement_policies/weighted_lru_rp.hh +++ b/src/mem/cache/replacement_policies/weighted_lru_rp.hh @@ -41,7 +41,9 @@ struct WeightedLRURPParams; -class WeightedLRUPolicy : public BaseReplacementPolicy +namespace ReplacementPolicy { + +class WeightedLRU : public Base { protected: /** Weighted LRU implementation of replacement data. */ @@ -61,8 +63,8 @@ class WeightedLRUPolicy : public BaseReplacementPolicy }; public: typedef WeightedLRURPParams Params; - WeightedLRUPolicy(const Params* p); - ~WeightedLRUPolicy() {} + WeightedLRU(const Params* p); + ~WeightedLRU() = default; /** * Invalidate replacement data to set it as the next probable victim. @@ -109,4 +111,6 @@ class WeightedLRUPolicy : public BaseReplacementPolicy candidates) const override; }; +} // namespace ReplacementPolicy + #endif // __MEM_CACHE_REPLACEMENT_POLICIES_WEIGHTED_LRU_RP_HH__ diff --git a/src/mem/cache/tags/base_set_assoc.hh b/src/mem/cache/tags/base_set_assoc.hh index 211bc1fdb..b48428b6e 100644 --- a/src/mem/cache/tags/base_set_assoc.hh +++ b/src/mem/cache/tags/base_set_assoc.hh @@ -82,7 +82,7 @@ class BaseSetAssoc : public BaseTags const bool sequentialAccess; /** Replacement policy */ - BaseReplacementPolicy *replacementPolicy; + ReplacementPolicy::Base *replacementPolicy; public: /** Convenience typedef. */ diff --git a/src/mem/cache/tags/sector_tags.hh b/src/mem/cache/tags/sector_tags.hh index b651bd600..380b3c1c8 100644 --- a/src/mem/cache/tags/sector_tags.hh +++ b/src/mem/cache/tags/sector_tags.hh @@ -44,7 +44,9 @@ #include "mem/packet.hh" #include "params/SectorTags.hh" -class BaseReplacementPolicy; +namespace ReplacementPolicy { + class Base; +} class ReplaceableEntry; /** @@ -71,7 +73,7 @@ class SectorTags : public BaseTags const bool sequentialAccess; /** Replacement policy */ - BaseReplacementPolicy *replacementPolicy; + ReplacementPolicy::Base *replacementPolicy; /** Number of data blocks per sector. */ const unsigned numBlocksPerSector; diff --git a/src/mem/ruby/structures/CacheMemory.cc b/src/mem/ruby/structures/CacheMemory.cc index dc4600220..0024d8a3b 100644 --- a/src/mem/ruby/structures/CacheMemory.cc +++ b/src/mem/ruby/structures/CacheMemory.cc @@ -82,7 +82,7 @@ CacheMemory::CacheMemory(const Params *p) m_is_instruction_only_cache = p->is_icache; m_resource_stalls = p->resourceStalls; m_block_size = p->block_size; // may be 0 at this point. Updated in init() - m_use_occupancy = dynamic_cast( + m_use_occupancy = dynamic_cast( m_replacementPolicy_ptr) ? true : false; } @@ -387,7 +387,8 @@ CacheMemory::setMRU(Addr address, int occupancy) // replacement policy. Depending on different replacement policies, // use different touch() function. if (m_use_occupancy) { - static_cast(m_replacementPolicy_ptr)->touch( + static_cast( + m_replacementPolicy_ptr)->touch( entry->replacementData, occupancy); } else { m_replacementPolicy_ptr->touch(entry->replacementData); diff --git a/src/mem/ruby/structures/CacheMemory.hh b/src/mem/ruby/structures/CacheMemory.hh index 0899e681f..245cfa94a 100644 --- a/src/mem/ruby/structures/CacheMemory.hh +++ b/src/mem/ruby/structures/CacheMemory.hh @@ -64,7 +64,7 @@ class CacheMemory : public SimObject { public: typedef RubyCacheParams Params; - typedef std::shared_ptr ReplData; + typedef std::shared_ptr ReplData; CacheMemory(const Params *p); ~CacheMemory(); @@ -200,11 +200,8 @@ class CacheMemory : public SimObject std::unordered_map m_tag_index; std::vector > m_cache; - /** - * We use BaseReplacementPolicy from Classic system here, hence we can use - * different replacement policies from Classic system in Ruby system. - */ - BaseReplacementPolicy *m_replacementPolicy_ptr; + /** We use the replacement policies from the Classic memory system. */ + ReplacementPolicy::Base *m_replacementPolicy_ptr; BankedArray dataArray; BankedArray tagArray;