summaryrefslogtreecommitdiff
path: root/src/mem/cache/tags/base.cc
diff options
context:
space:
mode:
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();