summaryrefslogtreecommitdiff
path: root/src/mem/cache/tags/base.hh
diff options
context:
space:
mode:
authorNikos Nikoleris <nikos.nikoleris@arm.com>2018-05-30 11:54:57 +0100
committerNikos Nikoleris <nikos.nikoleris@arm.com>2018-05-31 17:45:23 +0000
commit51f83a3cffa9f068afb3ca35327420c72713900a (patch)
tree017ea6bb77e05424c2f0a4050dbfade4dbd0c74a /src/mem/cache/tags/base.hh
parent56865ad1154c7c3fde2ae6b7329d0c888390f781 (diff)
downloadgem5-51f83a3cffa9f068afb3ca35327420c72713900a.tar.xz
mem-cache: Replace block visitor with std::function
This change modifies forEachBlk tags function to accept std::function as parameter. It also adds an anyBlk tags function that given a condition, it iterates through the blocks and returns whether the condition is met. Finally, it uses forEachBlk to implement the print, computeStats and cleanupRefs functions that also work for the FALRU class. Change-Id: I2f75f4baa1fdd5a1d343a63ecace3eb9458fbf03 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/10621 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
Diffstat (limited to 'src/mem/cache/tags/base.hh')
-rw-r--r--src/mem/cache/tags/base.hh46
1 files changed, 41 insertions, 5 deletions
diff --git a/src/mem/cache/tags/base.hh b/src/mem/cache/tags/base.hh
index 806f63aae..90469cd8e 100644
--- a/src/mem/cache/tags/base.hh
+++ b/src/mem/cache/tags/base.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2014,2016-2017 ARM Limited
+ * Copyright (c) 2012-2014,2016-2018 ARM Limited
* All rights reserved.
*
* The license below extends only to copyright in the software and shall
@@ -50,6 +50,7 @@
#define __MEM_CACHE_TAGS_BASE_HH__
#include <cassert>
+#include <functional>
#include <string>
#include "base/callback.hh"
@@ -177,17 +178,17 @@ class BaseTags : public ClockedObject
* Average in the reference count for valid blocks when the simulation
* exits.
*/
- virtual void cleanupRefs() {}
+ void cleanupRefs();
/**
* Computes stats just prior to dump event
*/
- virtual void computeStats() {}
+ void computeStats();
/**
* Print all tags used
*/
- virtual std::string print() const = 0;
+ std::string print();
/**
* Find a block using the memory address
@@ -289,7 +290,42 @@ class BaseTags : public ClockedObject
virtual int extractSet(Addr addr) const = 0;
- virtual void forEachBlk(CacheBlkVisitor &visitor) = 0;
+
+ /**
+ * Visit each block in the tags and apply a visitor
+ *
+ * The visitor should be a std::function that takes a cache block
+ * reference as its parameter.
+ *
+ * @param visitor Visitor to call on each block.
+ */
+ virtual void forEachBlk(std::function<void(CacheBlk &)> visitor) = 0;
+
+ /**
+ * Find if any of the blocks satisfies a condition
+ *
+ * The visitor should be a std::function that takes a cache block
+ * reference as its parameter. The visitor will terminate the
+ * traversal early if the condition is satisfied.
+ *
+ * @param visitor Visitor to call on each block.
+ */
+ virtual bool anyBlk(std::function<bool(CacheBlk &)> visitor) = 0;
+
+ private:
+ /**
+ * Update the reference stats using data from the input block
+ *
+ * @param blk The input block
+ */
+ void cleanupRefsVisitor(CacheBlk &blk);
+
+ /**
+ * Update the occupancy and age stats using data from the input block
+ *
+ * @param blk The input block
+ */
+ void computeStatsVisitor(CacheBlk &blk);
};
class BaseTagsCallback : public Callback