summaryrefslogtreecommitdiff
path: root/src/cpu
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2019-06-26 18:59:06 +0100
committerAndreas Sandberg <andreas.sandberg@arm.com>2019-08-29 09:01:38 +0000
commit7e5bdd07e4753c030e0072652a0219d6410c74c5 (patch)
tree2083f13cf459e9d3ef666ca3141580eddcd3f14b /src/cpu
parentc8f06b862c773f03a252b52380799168695b8713 (diff)
downloadgem5-7e5bdd07e4753c030e0072652a0219d6410c74c5.tar.xz
cpu: Convert traffic gen to use new stats
Change-Id: Ife690a137c2dcfb6bcc8b22df996c84f0d231618 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19370 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com>
Diffstat (limited to 'src/cpu')
-rw-r--r--src/cpu/testers/traffic_gen/base.cc113
-rw-r--r--src/cpu/testers/traffic_gen/base.hh69
2 files changed, 69 insertions, 113 deletions
diff --git a/src/cpu/testers/traffic_gen/base.cc b/src/cpu/testers/traffic_gen/base.cc
index 154b1bded..266f46155 100644
--- a/src/cpu/testers/traffic_gen/base.cc
+++ b/src/cpu/testers/traffic_gen/base.cc
@@ -80,6 +80,7 @@ BaseTrafficGen::BaseTrafficGen(const BaseTrafficGenParams* p)
retryPkt(NULL),
retryPktTick(0), blockedWaitingResp(false),
updateEvent([this]{ update(); }, name()),
+ stats(this),
masterID(system->getMasterId(this)),
streamGenerator(StreamGen::create(p))
{
@@ -195,7 +196,7 @@ BaseTrafficGen::update()
// suppress packets that are not destined for a memory, such as
// device accesses that could be part of a trace
if (pkt && system->isMemAddr(pkt->getAddr())) {
- numPackets++;
+ stats.numPackets++;
// Only attempts to send if not blocked by pending responses
blockedWaitingResp = allocateWaitingRespSlot(pkt);
if (blockedWaitingResp || !port.sendTimingReq(pkt)) {
@@ -206,10 +207,10 @@ BaseTrafficGen::update()
DPRINTF(TrafficGen, "Suppressed packet %s 0x%x\n",
pkt->cmdString(), pkt->getAddr());
- ++numSuppressed;
- if (!(static_cast<int>(numSuppressed.value()) % 10000))
+ ++stats.numSuppressed;
+ if (!(static_cast<int>(stats.numSuppressed.value()) % 10000))
warn("%s suppressed %d packets with non-memory addresses\n",
- name(), numSuppressed.value());
+ name(), stats.numSuppressed.value());
delete pkt;
pkt = nullptr;
@@ -288,7 +289,7 @@ void
BaseTrafficGen::recvReqRetry()
{
DPRINTF(TrafficGen, "Received retry\n");
- numRetries++;
+ stats.numRetries++;
retryReq();
}
@@ -308,7 +309,7 @@ BaseTrafficGen::retryReq()
// the tick for the next packet
Tick delay = curTick() - retryPktTick;
retryPktTick = 0;
- retryTicks += delay;
+ stats.retryTicks += delay;
if (drainState() != DrainState::Draining) {
// packet is sent, so find out when the next one is due
@@ -331,74 +332,28 @@ BaseTrafficGen::noProgress()
name(), progressCheck);
}
-void
-BaseTrafficGen::regStats()
+BaseTrafficGen::StatGroup::StatGroup(Stats::Group *parent)
+ : Stats::Group(parent),
+ ADD_STAT(numSuppressed,
+ "Number of suppressed packets to non-memory space"),
+ ADD_STAT(numPackets, "Number of packets generated"),
+ ADD_STAT(numRetries, "Number of retries"),
+ ADD_STAT(retryTicks, "Time spent waiting due to back-pressure (ticks)"),
+ ADD_STAT(bytesRead, "Number of bytes read"),
+ ADD_STAT(bytesWritten, "Number of bytes written"),
+ ADD_STAT(totalReadLatency, "Total latency of read requests"),
+ ADD_STAT(totalWriteLatency, "Total latency of write requests"),
+ ADD_STAT(totalReads, "Total num of reads"),
+ ADD_STAT(totalWrites, "Total num of writes"),
+ ADD_STAT(avgReadLatency, "Avg latency of read requests",
+ totalReadLatency / totalReads),
+ ADD_STAT(avgWriteLatency, "Avg latency of write requests",
+ totalWriteLatency / totalWrites),
+ ADD_STAT(readBW, "Read bandwidth in bytes/s",
+ bytesRead / simSeconds),
+ ADD_STAT(writeBW, "Write bandwidth in bytes/s",
+ bytesWritten / simSeconds)
{
- ClockedObject::regStats();
-
- // Initialise all the stats
- using namespace Stats;
-
- numPackets
- .name(name() + ".numPackets")
- .desc("Number of packets generated");
-
- numSuppressed
- .name(name() + ".numSuppressed")
- .desc("Number of suppressed packets to non-memory space");
-
- numRetries
- .name(name() + ".numRetries")
- .desc("Number of retries");
-
- retryTicks
- .name(name() + ".retryTicks")
- .desc("Time spent waiting due to back-pressure (ticks)");
-
- bytesRead
- .name(name() + ".bytesRead")
- .desc("Number of bytes read");
-
- bytesWritten
- .name(name() + ".bytesWritten")
- .desc("Number of bytes written");
-
- totalReadLatency
- .name(name() + ".totalReadLatency")
- .desc("Total latency of read requests");
-
- totalWriteLatency
- .name(name() + ".totalWriteLatency")
- .desc("Total latency of write requests");
-
- totalReads
- .name(name() + ".totalReads")
- .desc("Total num of reads");
-
- totalWrites
- .name(name() + ".totalWrites")
- .desc("Total num of writes");
-
- avgReadLatency
- .name(name() + ".avgReadLatency")
- .desc("Avg latency of read requests");
- avgReadLatency = totalReadLatency / totalReads;
-
- avgWriteLatency
- .name(name() + ".avgWriteLatency")
- .desc("Avg latency of write requests");
- avgWriteLatency = totalWriteLatency / totalWrites;
-
- readBW
- .name(name() + ".readBW")
- .desc("Read bandwidth in bytes/s");
- readBW = bytesRead / simSeconds;
-
- writeBW
- .name(name() + ".writeBW")
- .desc("Write bandwidth in bytes/s");
- writeBW = bytesWritten / simSeconds;
-
}
std::shared_ptr<BaseGen>
@@ -516,13 +471,13 @@ BaseTrafficGen::recvTimingResp(PacketPtr pkt)
assert(iter->second <= curTick());
if (pkt->isWrite()) {
- ++totalWrites;
- bytesWritten += pkt->req->getSize();
- totalWriteLatency += curTick() - iter->second;
+ ++stats.totalWrites;
+ stats.bytesWritten += pkt->req->getSize();
+ stats.totalWriteLatency += curTick() - iter->second;
} else {
- ++totalReads;
- bytesRead += pkt->req->getSize();
- totalReadLatency += curTick() - iter->second;
+ ++stats.totalReads;
+ stats.bytesRead += pkt->req->getSize();
+ stats.totalReadLatency += curTick() - iter->second;
}
waitingResp.erase(iter);
diff --git a/src/cpu/testers/traffic_gen/base.hh b/src/cpu/testers/traffic_gen/base.hh
index 985ab5d4c..0d6784e40 100644
--- a/src/cpu/testers/traffic_gen/base.hh
+++ b/src/cpu/testers/traffic_gen/base.hh
@@ -190,51 +190,55 @@ class BaseTrafficGen : public ClockedObject
/** Event for scheduling updates */
EventFunctionWrapper updateEvent;
- /** Count the number of dropped requests. */
- Stats::Scalar numSuppressed;
+ protected: // Stats
+ /** Reqs waiting for response **/
+ std::unordered_map<RequestPtr,Tick> waitingResp;
- private: // Stats
- /** Count the number of generated packets. */
- Stats::Scalar numPackets;
+ struct StatGroup : public Stats::Group {
+ StatGroup(Stats::Group *parent);
- /** Count the number of retries. */
- Stats::Scalar numRetries;
+ /** Count the number of dropped requests. */
+ Stats::Scalar numSuppressed;
- /** Count the time incurred from back-pressure. */
- Stats::Scalar retryTicks;
+ /** Count the number of generated packets. */
+ Stats::Scalar numPackets;
- /** Reqs waiting for response **/
- std::unordered_map<RequestPtr,Tick> waitingResp;
+ /** Count the number of retries. */
+ Stats::Scalar numRetries;
+
+ /** Count the time incurred from back-pressure. */
+ Stats::Scalar retryTicks;
- /** Count the number of bytes read. */
- Stats::Scalar bytesRead;
+ /** Count the number of bytes read. */
+ Stats::Scalar bytesRead;
- /** Count the number of bytes written. */
- Stats::Scalar bytesWritten;
+ /** Count the number of bytes written. */
+ Stats::Scalar bytesWritten;
- /** Total num of ticks read reqs took to complete */
- Stats::Scalar totalReadLatency;
+ /** Total num of ticks read reqs took to complete */
+ Stats::Scalar totalReadLatency;
- /** Total num of ticks write reqs took to complete */
- Stats::Scalar totalWriteLatency;
+ /** Total num of ticks write reqs took to complete */
+ Stats::Scalar totalWriteLatency;
- /** Count the number reads. */
- Stats::Scalar totalReads;
+ /** Count the number reads. */
+ Stats::Scalar totalReads;
- /** Count the number writes. */
- Stats::Scalar totalWrites;
+ /** Count the number writes. */
+ Stats::Scalar totalWrites;
- /** Avg num of ticks each read req took to complete */
- Stats::Formula avgReadLatency;
+ /** Avg num of ticks each read req took to complete */
+ Stats::Formula avgReadLatency;
- /** Avg num of ticks each write reqs took to complete */
- Stats::Formula avgWriteLatency;
+ /** Avg num of ticks each write reqs took to complete */
+ Stats::Formula avgWriteLatency;
- /** Read bandwidth in bytes/s */
- Stats::Formula readBW;
+ /** Read bandwidth in bytes/s */
+ Stats::Formula readBW;
- /** Write bandwidth in bytes/s */
- Stats::Formula writeBW;
+ /** Write bandwidth in bytes/s */
+ Stats::Formula writeBW;
+ } stats;
public:
BaseTrafficGen(const BaseTrafficGenParams* p);
@@ -251,9 +255,6 @@ class BaseTrafficGen : public ClockedObject
void serialize(CheckpointOut &cp) const override;
void unserialize(CheckpointIn &cp) override;
- /** Register statistics */
- void regStats() override;
-
public: // Generator factory methods
std::shared_ptr<BaseGen> createIdle(Tick duration);
std::shared_ptr<BaseGen> createExit(Tick duration);