mem,stats: Update stats style for mem/probes and mem/qos
Change-Id: I47a094eb8fc56ef998ec3c971dab68ba39b092e3 Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/36476 Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -51,7 +51,8 @@ MemFootprintProbe::MemFootprintProbe(const MemFootprintProbeParams &p)
|
||||
cacheLinesAll(),
|
||||
pages(),
|
||||
pagesAll(),
|
||||
system(p.system)
|
||||
system(p.system),
|
||||
stats(this)
|
||||
{
|
||||
fatal_if(!isPowerOf2(system->cacheLineSize()),
|
||||
"MemFootprintProbe expects cache line size is power of 2.");
|
||||
@@ -59,30 +60,24 @@ MemFootprintProbe::MemFootprintProbe(const MemFootprintProbeParams &p)
|
||||
"MemFootprintProbe expects page size parameter is power of 2");
|
||||
}
|
||||
|
||||
void
|
||||
MemFootprintProbe::regStats()
|
||||
MemFootprintProbe::
|
||||
MemFootprintProbeStats::MemFootprintProbeStats(MemFootprintProbe *parent)
|
||||
: Stats::Group(parent),
|
||||
ADD_STAT(cacheLine, "Memory footprint at cache line granularity"),
|
||||
ADD_STAT(cacheLineTotal, "Total memory footprint at cache line "
|
||||
"granularity since simulation begin"),
|
||||
ADD_STAT(page, "Memory footprint at page granularity"),
|
||||
ADD_STAT(pageTotal, "Total memory footprint at page granularity since "
|
||||
"simulation begin")
|
||||
{
|
||||
BaseMemProbe::regStats();
|
||||
|
||||
using namespace Stats;
|
||||
// clang-format off
|
||||
fpCacheLine.name(name() + ".cacheline")
|
||||
.desc("Memory footprint at cache line granularity")
|
||||
.flags(nozero | nonan);
|
||||
fpCacheLineTotal.name(name() + ".cacheline_total")
|
||||
.desc("Total memory footprint at cache line granularity since "
|
||||
"simulation begin")
|
||||
.flags(nozero | nonan);
|
||||
fpPage.name(name() + ".page")
|
||||
.desc("Memory footprint at page granularity")
|
||||
.flags(nozero | nonan);
|
||||
fpPageTotal.name(name() + ".page_total")
|
||||
.desc("Total memory footprint at page granularity since simulation "
|
||||
"begin")
|
||||
.flags(nozero | nonan);
|
||||
cacheLine.flags(nozero | nonan);
|
||||
cacheLineTotal.flags(nozero | nonan);
|
||||
page.flags(nozero | nonan);
|
||||
pageTotal.flags(nozero | nonan);
|
||||
// clang-format on
|
||||
|
||||
registerResetCallback([this]() { statReset(); });
|
||||
registerResetCallback([parent]() { parent->statReset(); });
|
||||
}
|
||||
|
||||
void
|
||||
@@ -108,10 +103,10 @@ MemFootprintProbe::handleRequest(const ProbePoints::PacketInfo &pi)
|
||||
assert(cacheLines.size() <= cacheLinesAll.size());
|
||||
assert(pages.size() <= pagesAll.size());
|
||||
|
||||
fpCacheLine = cacheLines.size() << cacheLineSizeLg2;
|
||||
fpCacheLineTotal = cacheLinesAll.size() << cacheLineSizeLg2;
|
||||
fpPage = pages.size() << pageSizeLg2;
|
||||
fpPageTotal = pagesAll.size() << pageSizeLg2;
|
||||
stats.cacheLine = cacheLines.size() << cacheLineSizeLg2;
|
||||
stats.cacheLineTotal = cacheLinesAll.size() << cacheLineSizeLg2;
|
||||
stats.page = pages.size() << pageSizeLg2;
|
||||
stats.pageTotal = pagesAll.size() << pageSizeLg2;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -57,7 +57,6 @@ class MemFootprintProbe : public BaseMemProbe
|
||||
typedef std::unordered_set<Addr> AddrSet;
|
||||
|
||||
MemFootprintProbe(const MemFootprintProbeParams &p);
|
||||
void regStats() override;
|
||||
// Fix footprint tracking state on stat reset
|
||||
void statReset();
|
||||
|
||||
@@ -72,14 +71,19 @@ class MemFootprintProbe : public BaseMemProbe
|
||||
void insertAddr(Addr addr, AddrSet *set, uint64_t limit);
|
||||
void handleRequest(const ProbePoints::PacketInfo &pkt_info) override;
|
||||
|
||||
/// Footprint at cache line size granularity
|
||||
Stats::Scalar fpCacheLine;
|
||||
/// Footprint at cache line size granularity, since simulation begin
|
||||
Stats::Scalar fpCacheLineTotal;
|
||||
/// Footprint at page granularity
|
||||
Stats::Scalar fpPage;
|
||||
/// Footprint at page granularity, since simulation begin
|
||||
Stats::Scalar fpPageTotal;
|
||||
struct MemFootprintProbeStats : public Stats::Group
|
||||
{
|
||||
MemFootprintProbeStats(MemFootprintProbe *parent);
|
||||
|
||||
/// Footprint at cache line size granularity
|
||||
Stats::Scalar cacheLine;
|
||||
/// Footprint at cache line size granularity, since simulation begin
|
||||
Stats::Scalar cacheLineTotal;
|
||||
/// Footprint at page granularity
|
||||
Stats::Scalar page;
|
||||
/// Footprint at page granularity, since simulation begin
|
||||
Stats::Scalar pageTotal;
|
||||
};
|
||||
|
||||
// Addr set to track unique cache lines accessed
|
||||
AddrSet cacheLines;
|
||||
@@ -90,6 +94,8 @@ class MemFootprintProbe : public BaseMemProbe
|
||||
// Addr set to track unique pages accessed since simulation begin
|
||||
AddrSet pagesAll;
|
||||
System *system;
|
||||
|
||||
MemFootprintProbeStats stats;
|
||||
};
|
||||
|
||||
#endif //__MEM_PROBES_MEM_FOOTPRINT_HH__
|
||||
|
||||
@@ -45,50 +45,45 @@ StackDistProbe::StackDistProbe(const StackDistProbeParams &p)
|
||||
lineSize(p.line_size),
|
||||
disableLinearHists(p.disable_linear_hists),
|
||||
disableLogHists(p.disable_log_hists),
|
||||
calc(p.verify)
|
||||
calc(p.verify),
|
||||
stats(this)
|
||||
{
|
||||
fatal_if(p.system->cacheLineSize() > p.line_size,
|
||||
"The stack distance probe must use a cache line size that is "
|
||||
"larger or equal to the system's cahce line size.");
|
||||
}
|
||||
|
||||
void
|
||||
StackDistProbe::regStats()
|
||||
StackDistProbe::
|
||||
StackDistProbeStats::StackDistProbeStats(StackDistProbe *parent)
|
||||
: Stats::Group(parent),
|
||||
ADD_STAT(readLinearHist, "Reads linear distribution"),
|
||||
ADD_STAT(readLogHist, "Reads logarithmic distribution"),
|
||||
ADD_STAT(writeLinearHist, "Writes linear distribution"),
|
||||
ADD_STAT(writeLogHist, "Writes logarithmic distribution"),
|
||||
ADD_STAT(infiniteSD, "Number of requests with infinite stack distance")
|
||||
{
|
||||
BaseMemProbe::regStats();
|
||||
using namespace Stats;
|
||||
|
||||
const StackDistProbeParams &p =
|
||||
dynamic_cast<const StackDistProbeParams &>(params());
|
||||
|
||||
using namespace Stats;
|
||||
dynamic_cast<const StackDistProbeParams &>(parent->params());
|
||||
|
||||
readLinearHist
|
||||
.init(p.linear_hist_bins)
|
||||
.name(name() + ".readLinearHist")
|
||||
.desc("Reads linear distribution")
|
||||
.flags(disableLinearHists ? nozero : pdf);
|
||||
.flags(parent->disableLinearHists ? nozero : pdf);
|
||||
|
||||
readLogHist
|
||||
.init(p.log_hist_bins)
|
||||
.name(name() + ".readLogHist")
|
||||
.desc("Reads logarithmic distribution")
|
||||
.flags(disableLogHists ? nozero : pdf);
|
||||
.flags(parent->disableLogHists ? nozero : pdf);
|
||||
|
||||
writeLinearHist
|
||||
.init(p.linear_hist_bins)
|
||||
.name(name() + ".writeLinearHist")
|
||||
.desc("Writes linear distribution")
|
||||
.flags(disableLinearHists ? nozero : pdf);
|
||||
.flags(parent->disableLinearHists ? nozero : pdf);
|
||||
|
||||
writeLogHist
|
||||
.init(p.log_hist_bins)
|
||||
.name(name() + ".writeLogHist")
|
||||
.desc("Writes logarithmic distribution")
|
||||
.flags(disableLogHists ? nozero : pdf);
|
||||
.flags(parent->disableLogHists ? nozero : pdf);
|
||||
|
||||
infiniteSD
|
||||
.name(name() + ".infinity")
|
||||
.desc("Number of requests with infinite stack distance")
|
||||
.flags(nozero);
|
||||
}
|
||||
|
||||
@@ -106,16 +101,16 @@ StackDistProbe::handleRequest(const ProbePoints::PacketInfo &pkt_info)
|
||||
// Calculate the stack distance
|
||||
const uint64_t sd(calc.calcStackDistAndUpdate(aligned_addr).first);
|
||||
if (sd == StackDistCalc::Infinity) {
|
||||
infiniteSD++;
|
||||
stats.infiniteSD++;
|
||||
return;
|
||||
}
|
||||
|
||||
// Sample the stack distance of the address in linear bins
|
||||
if (!disableLinearHists) {
|
||||
if (pkt_info.cmd.isRead())
|
||||
readLinearHist.sample(sd);
|
||||
stats.readLinearHist.sample(sd);
|
||||
else
|
||||
writeLinearHist.sample(sd);
|
||||
stats.writeLinearHist.sample(sd);
|
||||
}
|
||||
|
||||
if (!disableLogHists) {
|
||||
@@ -123,8 +118,8 @@ StackDistProbe::handleRequest(const ProbePoints::PacketInfo &pkt_info)
|
||||
|
||||
// Sample the stack distance of the address in log bins
|
||||
if (pkt_info.cmd.isRead())
|
||||
readLogHist.sample(sd_lg2);
|
||||
stats.readLogHist.sample(sd_lg2);
|
||||
else
|
||||
writeLogHist.sample(sd_lg2);
|
||||
stats.writeLogHist.sample(sd_lg2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,6 @@ class StackDistProbe : public BaseMemProbe
|
||||
public:
|
||||
StackDistProbe(const StackDistProbeParams ¶ms);
|
||||
|
||||
void regStats() override;
|
||||
|
||||
protected:
|
||||
void handleRequest(const ProbePoints::PacketInfo &pkt_info) override;
|
||||
|
||||
@@ -65,24 +63,28 @@ class StackDistProbe : public BaseMemProbe
|
||||
// Disable the logarithmic histograms
|
||||
const bool disableLogHists;
|
||||
|
||||
protected:
|
||||
// Reads linear histogram
|
||||
Stats::Histogram readLinearHist;
|
||||
|
||||
// Reads logarithmic histogram
|
||||
Stats::SparseHistogram readLogHist;
|
||||
|
||||
// Writes linear histogram
|
||||
Stats::Histogram writeLinearHist;
|
||||
|
||||
// Writes logarithmic histogram
|
||||
Stats::SparseHistogram writeLogHist;
|
||||
|
||||
// Writes logarithmic histogram
|
||||
Stats::Scalar infiniteSD;
|
||||
|
||||
protected:
|
||||
StackDistCalc calc;
|
||||
|
||||
struct StackDistProbeStats : public Stats::Group
|
||||
{
|
||||
StackDistProbeStats(StackDistProbe* parent);
|
||||
|
||||
// Reads linear histogram
|
||||
Stats::Histogram readLinearHist;
|
||||
|
||||
// Reads logarithmic histogram
|
||||
Stats::SparseHistogram readLogHist;
|
||||
|
||||
// Writes linear histogram
|
||||
Stats::Histogram writeLinearHist;
|
||||
|
||||
// Writes logarithmic histogram
|
||||
Stats::SparseHistogram writeLogHist;
|
||||
|
||||
// Writes logarithmic histogram
|
||||
Stats::Scalar infiniteSD;
|
||||
} stats;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,8 @@ MemSinkCtrl::MemSinkCtrl(const QoSMemSinkCtrlParams &p)
|
||||
readBufferSize(p.read_buffer_size),
|
||||
writeBufferSize(p.write_buffer_size), port(name() + ".port", *this),
|
||||
interface(p.interface),
|
||||
retryRdReq(false), retryWrReq(false), nextRequest(0), nextReqEvent(this)
|
||||
retryRdReq(false), retryWrReq(false), nextRequest(0), nextReqEvent(this),
|
||||
stats(this)
|
||||
{
|
||||
// Resize read and write queue to allocate space
|
||||
// for configured QoS priorities
|
||||
@@ -155,7 +156,7 @@ MemSinkCtrl::recvTimingReq(PacketPtr pkt)
|
||||
"%s Read queue full, not accepting\n", __func__);
|
||||
// Remember that we have to retry this port
|
||||
retryRdReq = true;
|
||||
numReadRetries++;
|
||||
stats.numReadRetries++;
|
||||
req_accepted = false;
|
||||
} else {
|
||||
// Enqueue the incoming packet into corresponding
|
||||
@@ -169,7 +170,7 @@ MemSinkCtrl::recvTimingReq(PacketPtr pkt)
|
||||
"%s Write queue full, not accepting\n", __func__);
|
||||
// Remember that we have to retry this port
|
||||
retryWrReq = true;
|
||||
numWriteRetries++;
|
||||
stats.numWriteRetries++;
|
||||
req_accepted = false;
|
||||
} else {
|
||||
// Enqueue the incoming packet into corresponding QoS
|
||||
@@ -332,18 +333,11 @@ MemSinkCtrl::drain()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MemSinkCtrl::regStats()
|
||||
MemSinkCtrl::MemSinkCtrlStats::MemSinkCtrlStats(Stats::Group *parent)
|
||||
: Stats::Group(parent),
|
||||
ADD_STAT(numReadRetries, "Number of read retries"),
|
||||
ADD_STAT(numWriteRetries, "Number of write retries")
|
||||
{
|
||||
MemCtrl::regStats();
|
||||
|
||||
// Initialize all the stats
|
||||
using namespace Stats;
|
||||
|
||||
numReadRetries.name(name() + ".numReadRetries")
|
||||
.desc("Number of read retries");
|
||||
numWriteRetries.name(name() + ".numWriteRetries")
|
||||
.desc("Number of write retries");
|
||||
}
|
||||
|
||||
MemSinkCtrl::MemoryPort::MemoryPort(const std::string& n,
|
||||
|
||||
@@ -181,11 +181,16 @@ class MemSinkCtrl : public MemCtrl
|
||||
/** Next request service time */
|
||||
Tick nextRequest;
|
||||
|
||||
/** Count the number of read retries */
|
||||
Stats::Scalar numReadRetries;
|
||||
struct MemSinkCtrlStats : public Stats::Group
|
||||
{
|
||||
MemSinkCtrlStats(Stats::Group *parent);
|
||||
|
||||
/** Count the number of write retries */
|
||||
Stats::Scalar numWriteRetries;
|
||||
/** Count the number of read retries */
|
||||
Stats::Scalar numReadRetries;
|
||||
|
||||
/** Count the number of write retries */
|
||||
Stats::Scalar numWriteRetries;
|
||||
};
|
||||
|
||||
/**
|
||||
* QoS-aware (per priority) incoming read requests packets queue
|
||||
@@ -247,8 +252,7 @@ class MemSinkCtrl : public MemCtrl
|
||||
*/
|
||||
bool recvTimingReq(PacketPtr pkt);
|
||||
|
||||
/** Registers statistics */
|
||||
void regStats() override;
|
||||
MemSinkCtrlStats stats;
|
||||
};
|
||||
|
||||
} // namespace QoS
|
||||
|
||||
Reference in New Issue
Block a user