cpu: convert memtest to new style stats
authoreavivi <eavivi@ucdavis.edu>
Fri, 4 Sep 2020 21:54:14 +0000 (14:54 -0700)
committerJason Lowe-Power <power.jg@gmail.com>
Tue, 8 Sep 2020 16:47:52 +0000 (16:47 +0000)
Change-Id: I91b17dd46fd0f70816159ea14c1c8f498048c696
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34137
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/cpu/testers/memtest/memtest.cc
src/cpu/testers/memtest/memtest.hh

index 720b2739ef05988ca9750eab891d399d4b0363e8..026a3258e54b33ea09af1ffcacbaf8e92b86cd87 100644 (file)
@@ -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
index 86b27a4ac9643df6e1fd0100d410b86aea166d8f..5eb4e3575959ee63c98418c1312992aaed22c616 100644 (file)
@@ -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.