From: eavivi Date: Fri, 4 Sep 2020 21:54:14 +0000 (-0700) Subject: cpu: convert memtest to new style stats X-Git-Tag: v20.1.0.0~70 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5bce6dc526e6508d754df73b3a19ea1c7d502284;p=gem5.git cpu: convert memtest to new style stats Change-Id: I91b17dd46fd0f70816159ea14c1c8f498048c696 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34137 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- diff --git a/src/cpu/testers/memtest/memtest.cc b/src/cpu/testers/memtest/memtest.cc index 720b2739e..026a3258e 100644 --- a/src/cpu/testers/memtest/memtest.cc +++ b/src/cpu/testers/memtest/memtest.cc @@ -99,7 +99,7 @@ MemTest::MemTest(const Params *p) nextProgressMessage(p->progress_interval), maxLoads(p->max_loads), atomic(p->system->isAtomicMode()), - suppressFuncErrors(p->suppress_func_errors) + suppressFuncErrors(p->suppress_func_errors), stats(this) { id = TESTER_ALLOCATOR++; fatal_if(id >= blockSize, "Too many testers, only %d allowed\n", @@ -160,7 +160,7 @@ MemTest::completeRequest(PacketPtr pkt, bool functional) } numReads++; - numReadsStat++; + stats.numReads++; if (numReads == (uint64_t)nextProgressMessage) { ccprintf(cerr, "%s: completed %d read, %d write accesses @%d\n", @@ -176,7 +176,7 @@ MemTest::completeRequest(PacketPtr pkt, bool functional) // update the reference data referenceData[req->getPaddr()] = pkt_data[0]; numWrites++; - numWritesStat++; + stats.numWrites++; } } @@ -190,23 +190,12 @@ MemTest::completeRequest(PacketPtr pkt, bool functional) else if (noResponseEvent.scheduled()) deschedule(noResponseEvent); } - -void -MemTest::regStats() +MemTest::MemTestStats::MemTestStats(Stats::Group *parent) + : Stats::Group(parent), + ADD_STAT(numReads, "number of read accesses completed"), + ADD_STAT(numWrites, "number of write accesses completed") { - ClockedObject::regStats(); - - using namespace Stats; - - numReadsStat - .name(name() + ".num_reads") - .desc("number of read accesses completed") - ; - numWritesStat - .name(name() + ".num_writes") - .desc("number of write accesses completed") - ; } void diff --git a/src/cpu/testers/memtest/memtest.hh b/src/cpu/testers/memtest/memtest.hh index 86b27a4ac..5eb4e3575 100644 --- a/src/cpu/testers/memtest/memtest.hh +++ b/src/cpu/testers/memtest/memtest.hh @@ -72,7 +72,6 @@ class MemTest : public ClockedObject typedef MemTestParams Params; MemTest(const Params *p); - void regStats() override; Port &getPort(const std::string &if_name, PortID idx=InvalidPortID) override; @@ -166,9 +165,13 @@ class MemTest : public ClockedObject const bool atomic; const bool suppressFuncErrors; - - Stats::Scalar numReadsStat; - Stats::Scalar numWritesStat; + protected: + struct MemTestStats : public Stats::Group + { + MemTestStats(Stats::Group *parent); + Stats::Scalar numReads; + Stats::Scalar numWrites; + } stats; /** * Complete a request by checking the response.