retryPkt(NULL),
retryPktTick(0), blockedWaitingResp(false),
updateEvent([this]{ update(); }, name()),
+ stats(this),
masterID(system->getMasterId(this)),
streamGenerator(StreamGen::create(p))
{
// 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)) {
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;
BaseTrafficGen::recvReqRetry()
{
DPRINTF(TrafficGen, "Received retry\n");
- numRetries++;
+ stats.numRetries++;
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
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>
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);
/** 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);
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);