mem-cache: Virtualize block print
Encapsulate and virtualize block print, so that relevant information can be easily printed anywhere. Change-Id: I91109c29c126755183a0fd2b4446f5335e64076b Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br> Reviewed-on: https://gem5-review.googlesource.com/c/13415 Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
This commit is contained in:
committed by
Daniel Carvalho
parent
160bcba0d6
commit
1b44e883a2
4
src/mem/cache/base.cc
vendored
4
src/mem/cache/base.cc
vendored
@@ -52,6 +52,7 @@
|
||||
#include "base/logging.hh"
|
||||
#include "debug/Cache.hh"
|
||||
#include "debug/CachePort.hh"
|
||||
#include "debug/CacheRepl.hh"
|
||||
#include "debug/CacheVerbose.hh"
|
||||
#include "mem/cache/mshr.hh"
|
||||
#include "mem/cache/prefetch/base.hh"
|
||||
@@ -1237,6 +1238,9 @@ BaseCache::allocateBlock(const PacketPtr pkt, PacketList &writebacks)
|
||||
if (!victim)
|
||||
return nullptr;
|
||||
|
||||
// Print victim block's information
|
||||
DPRINTF(CacheRepl, "Replacement victim: %s\n", victim->print());
|
||||
|
||||
// Check for transient state allocations. If any of the entries listed
|
||||
// for eviction has a transient state, the allocation fails
|
||||
for (const auto& blk : evict_blks) {
|
||||
|
||||
9
src/mem/cache/blk.hh
vendored
9
src/mem/cache/blk.hh
vendored
@@ -292,12 +292,12 @@ class CacheBlk : public ReplaceableEntry
|
||||
}
|
||||
|
||||
/**
|
||||
* Pretty-print a tag, and interpret state bits to readable form
|
||||
* Pretty-print tag, set and way, and interpret state bits to readable form
|
||||
* including mapping to a MOESI state.
|
||||
*
|
||||
* @return string with basic state information
|
||||
*/
|
||||
std::string print() const
|
||||
virtual std::string print() const
|
||||
{
|
||||
/**
|
||||
* state M O E S I
|
||||
@@ -334,8 +334,9 @@ class CacheBlk : public ReplaceableEntry
|
||||
default: s = 'T'; break; // @TODO add other types
|
||||
}
|
||||
return csprintf("state: %x (%c) valid: %d writable: %d readable: %d "
|
||||
"dirty: %d tag: %x", status, s, isValid(),
|
||||
isWritable(), isReadable(), isDirty(), tag);
|
||||
"dirty: %d | tag: %#x set: %#x way: %#x", status, s,
|
||||
isValid(), isWritable(), isReadable(), isDirty(), tag,
|
||||
getSet(), getWay());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
8
src/mem/cache/sector_blk.cc
vendored
8
src/mem/cache/sector_blk.cc
vendored
@@ -37,6 +37,7 @@
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "base/cprintf.hh"
|
||||
#include "base/logging.hh"
|
||||
|
||||
void
|
||||
@@ -86,6 +87,13 @@ SectorSubBlk::insert(const Addr tag, const bool is_secure,
|
||||
_sectorBlk->setTag(tag);
|
||||
}
|
||||
|
||||
std::string
|
||||
SectorSubBlk::print() const
|
||||
{
|
||||
return csprintf("%s sector offset: %#x", CacheBlk::print(),
|
||||
getSectorOffset());
|
||||
}
|
||||
|
||||
bool
|
||||
SectorBlk::isValid() const
|
||||
{
|
||||
|
||||
7
src/mem/cache/sector_blk.hh
vendored
7
src/mem/cache/sector_blk.hh
vendored
@@ -114,6 +114,13 @@ class SectorSubBlk : public CacheBlk
|
||||
*/
|
||||
void insert(const Addr tag, const bool is_secure, const int src_master_ID,
|
||||
const uint32_t task_ID) override;
|
||||
|
||||
/**
|
||||
* Pretty-print sector offset and other CacheBlk information.
|
||||
*
|
||||
* @return string with basic state information
|
||||
*/
|
||||
std::string print() const override;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
3
src/mem/cache/tags/base.cc
vendored
3
src/mem/cache/tags/base.cc
vendored
@@ -201,8 +201,7 @@ BaseTags::print()
|
||||
|
||||
auto print_blk = [&str](CacheBlk &blk) {
|
||||
if (blk.isValid())
|
||||
str += csprintf("\tset: %x, way: %x %s\n", blk.getSet(),
|
||||
blk.getWay(), blk.print());
|
||||
str += csprintf("\tBlock: %s\n", blk.print());
|
||||
};
|
||||
forEachBlk(print_blk);
|
||||
|
||||
|
||||
4
src/mem/cache/tags/base_set_assoc.hh
vendored
4
src/mem/cache/tags/base_set_assoc.hh
vendored
@@ -54,7 +54,6 @@
|
||||
|
||||
#include "base/logging.hh"
|
||||
#include "base/types.hh"
|
||||
#include "debug/CacheRepl.hh"
|
||||
#include "mem/cache/base.hh"
|
||||
#include "mem/cache/blk.hh"
|
||||
#include "mem/cache/replacement_policies/base.hh"
|
||||
@@ -187,9 +186,6 @@ class BaseSetAssoc : public BaseTags
|
||||
// There is only one eviction for this replacement
|
||||
evict_blks.push_back(victim);
|
||||
|
||||
DPRINTF(CacheRepl, "set %x, way %x: selecting blk for replacement\n",
|
||||
victim->getSet(), victim->getWay());
|
||||
|
||||
return victim;
|
||||
}
|
||||
|
||||
|
||||
6
src/mem/cache/tags/fa_lru.cc
vendored
6
src/mem/cache/tags/fa_lru.cc
vendored
@@ -57,6 +57,12 @@
|
||||
#include "base/logging.hh"
|
||||
#include "mem/cache/base.hh"
|
||||
|
||||
std::string
|
||||
FALRUBlk::print() const
|
||||
{
|
||||
return csprintf("%s inCachesMask: %#x", CacheBlk::print(), inCachesMask);
|
||||
}
|
||||
|
||||
FALRU::FALRU(const Params *p)
|
||||
: BaseTags(p),
|
||||
|
||||
|
||||
7
src/mem/cache/tags/fa_lru.hh
vendored
7
src/mem/cache/tags/fa_lru.hh
vendored
@@ -92,6 +92,13 @@ class FALRUBlk : public CacheBlk
|
||||
|
||||
/** A bit mask of the caches that fit this block. */
|
||||
CachesMask inCachesMask;
|
||||
|
||||
/**
|
||||
* Pretty-print inCachesMask and other CacheBlk information.
|
||||
*
|
||||
* @return string with basic state information
|
||||
*/
|
||||
std::string print() const override;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
5
src/mem/cache/tags/sector_tags.cc
vendored
5
src/mem/cache/tags/sector_tags.cc
vendored
@@ -42,7 +42,6 @@
|
||||
#include "base/intmath.hh"
|
||||
#include "base/logging.hh"
|
||||
#include "base/types.hh"
|
||||
#include "debug/CacheRepl.hh"
|
||||
#include "mem/cache/base.hh"
|
||||
#include "mem/cache/replacement_policies/base.hh"
|
||||
#include "mem/cache/tags/indexing_policies/base.hh"
|
||||
@@ -277,10 +276,6 @@ SectorTags::findVictim(Addr addr, const bool is_secure,
|
||||
}
|
||||
}
|
||||
|
||||
DPRINTF(CacheRepl, "set %x, way %x, sector offset %x: selecting blk " \
|
||||
"for replacement\n", victim->getSet(), victim->getWay(),
|
||||
victim->getSectorOffset());
|
||||
|
||||
return victim;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user