summaryrefslogtreecommitdiff
path: root/src/mem/ruby/structures/CacheMemory.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem/ruby/structures/CacheMemory.hh')
-rw-r--r--src/mem/ruby/structures/CacheMemory.hh35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/mem/ruby/structures/CacheMemory.hh b/src/mem/ruby/structures/CacheMemory.hh
index 16339ee55..ce5d81d04 100644
--- a/src/mem/ruby/structures/CacheMemory.hh
+++ b/src/mem/ruby/structures/CacheMemory.hh
@@ -35,13 +35,14 @@
#include <vector>
#include "base/statistics.hh"
+#include "mem/cache/replacement_policies/base.hh"
+#include "mem/cache/replacement_policies/replaceable_entry.hh"
#include "mem/ruby/common/DataBlock.hh"
#include "mem/ruby/protocol/CacheRequestType.hh"
#include "mem/ruby/protocol/CacheResourceType.hh"
#include "mem/ruby/protocol/RubyRequest.hh"
#include "mem/ruby/slicc_interface/AbstractCacheEntry.hh"
#include "mem/ruby/slicc_interface/RubySlicc_ComponentMapping.hh"
-#include "mem/ruby/structures/AbstractReplacementPolicy.hh"
#include "mem/ruby/structures/BankedArray.hh"
#include "mem/ruby/system/CacheRecorder.hh"
#include "params/RubyCache.hh"
@@ -51,6 +52,7 @@ class CacheMemory : public SimObject
{
public:
typedef RubyCacheParams Params;
+ typedef std::shared_ptr<ReplacementData> ReplData;
CacheMemory(const Params *p);
~CacheMemory();
@@ -74,15 +76,10 @@ class CacheMemory : public SimObject
bool cacheAvail(Addr address) const;
// find an unused entry and sets the tag appropriate for the address
- AbstractCacheEntry* allocate(Addr address,
- AbstractCacheEntry* new_entry, bool touch);
- AbstractCacheEntry* allocate(Addr address, AbstractCacheEntry* new_entry)
- {
- return allocate(address, new_entry, true);
- }
+ AbstractCacheEntry* allocate(Addr address, AbstractCacheEntry* new_entry);
void allocateVoid(Addr address, AbstractCacheEntry* new_entry)
{
- allocate(address, new_entry, true);
+ allocate(address, new_entry);
}
// Explicitly free up this address
@@ -173,7 +170,11 @@ class CacheMemory : public SimObject
std::unordered_map<Addr, int> m_tag_index;
std::vector<std::vector<AbstractCacheEntry*> > m_cache;
- AbstractReplacementPolicy *m_replacementPolicy_ptr;
+ /**
+ * We use BaseReplacementPolicy from Classic system here, hence we can use
+ * different replacement policies from Classic system in Ruby system.
+ */
+ BaseReplacementPolicy *m_replacementPolicy_ptr;
BankedArray dataArray;
BankedArray tagArray;
@@ -185,6 +186,22 @@ class CacheMemory : public SimObject
int m_start_index_bit;
bool m_resource_stalls;
int m_block_size;
+
+ /**
+ * We store all the ReplacementData in a 2-dimensional array. By doing
+ * this, we can use all replacement policies from Classic system. Ruby
+ * cache will deallocate cache entry every time we evict the cache block
+ * so we cannot store the ReplacementData inside the cache entry.
+ * Instantiate ReplacementData for multiple times will break replacement
+ * policy like TreePLRU.
+ */
+ std::vector<std::vector<ReplData> > replacement_data;
+
+ /**
+ * Set to true when using WeightedLRU replacement policy, otherwise, set to
+ * false.
+ */
+ bool m_use_occupancy;
};
std::ostream& operator<<(std::ostream& out, const CacheMemory& obj);