summaryrefslogtreecommitdiff
path: root/src/mem/cache/tags/base.cc
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.cc
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.cc')
-rw-r--r--src/mem/cache/tags/base.cc73
1 files changed, 72 insertions, 1 deletions
diff --git a/src/mem/cache/tags/base.cc b/src/mem/cache/tags/base.cc
index c7ea17bd1..13e1245c6 100644
--- a/src/mem/cache/tags/base.cc
+++ b/src/mem/cache/tags/base.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013,2016 ARM Limited
+ * Copyright (c) 2013,2016,2018 ARM Limited
* All rights reserved.
*
* The license below extends only to copyright in the software and shall
@@ -111,6 +111,77 @@ BaseTags::insertBlock(PacketPtr pkt, CacheBlk *blk)
}
void
+BaseTags::cleanupRefsVisitor(CacheBlk &blk)
+{
+ if (blk.isValid()) {
+ totalRefs += blk.refCount;
+ ++sampledRefs;
+ }
+}
+
+void
+BaseTags::cleanupRefs()
+{
+ forEachBlk([this](CacheBlk &blk) { cleanupRefsVisitor(blk); });
+}
+
+void
+BaseTags::computeStatsVisitor(CacheBlk &blk)
+{
+ if (blk.isValid()) {
+ assert(blk.task_id < ContextSwitchTaskId::NumTaskId);
+ occupanciesTaskId[blk.task_id]++;
+ assert(blk.tickInserted <= curTick());
+ Tick age = curTick() - blk.tickInserted;
+
+ int age_index;
+ if (age / SimClock::Int::us < 10) { // <10us
+ age_index = 0;
+ } else if (age / SimClock::Int::us < 100) { // <100us
+ age_index = 1;
+ } else if (age / SimClock::Int::ms < 1) { // <1ms
+ age_index = 2;
+ } else if (age / SimClock::Int::ms < 10) { // <10ms
+ age_index = 3;
+ } else
+ age_index = 4; // >10ms
+
+ ageTaskId[blk.task_id][age_index]++;
+ }
+}
+
+void
+BaseTags::computeStats()
+{
+ for (unsigned i = 0; i < ContextSwitchTaskId::NumTaskId; ++i) {
+ occupanciesTaskId[i] = 0;
+ for (unsigned j = 0; j < 5; ++j) {
+ ageTaskId[i][j] = 0;
+ }
+ }
+
+ forEachBlk([this](CacheBlk &blk) { computeStatsVisitor(blk); });
+}
+
+std::string
+BaseTags::print()
+{
+ std::string str;
+
+ auto print_blk = [&str](CacheBlk &blk) {
+ if (blk.isValid())
+ str += csprintf("\tset: %d way: %d %s\n", blk.set, blk.way,
+ blk.print());
+ };
+ forEachBlk(print_blk);
+
+ if (str.empty())
+ str = "no valid tags\n";
+
+ return str;
+}
+
+void
BaseTags::regStats()
{
ClockedObject::regStats();