43#include "debug/CommMonitor.hh"
53 memSidePort(
name() +
"-mem_side_port", *this),
54 cpuSidePort(
name() +
"-cpu_side_port", *this),
56 samplePeriodTicks(params.sample_period),
61 "Created monitor %s with sample period %d ticks (%f ms)\n",
62 name(), samplePeriodTicks, samplePeriod * 1E3);
70 fatal(
"Communication monitor is not connected on both sides.\n");
83 if (if_name ==
"mem_side_port") {
85 }
else if (if_name ==
"cpu_side_port") {
105 const CommMonitorParams ¶ms)
106 : statistics::
Group(parent),
108 disableBurstLengthHists(params.disable_burst_length_hists),
109 ADD_STAT(readBurstLengthHist, statistics::units::Byte::get(),
110 "Histogram of burst lengths of transmitted packets"),
111 ADD_STAT(writeBurstLengthHist, statistics::units::Byte::get(),
112 "Histogram of burst lengths of transmitted packets"),
114 disableBandwidthHists(params.disable_bandwidth_hists),
116 ADD_STAT(readBandwidthHist, statistics::units::Rate<
117 statistics::units::Byte, statistics::units::Second>::get(),
118 "Histogram of read bandwidth per sample period"),
119 ADD_STAT(totalReadBytes, statistics::units::Byte::get(),
120 "Number of bytes read"),
121 ADD_STAT(averageReadBandwidth, statistics::units::Rate<
122 statistics::units::Byte, statistics::units::Second>::get(),
123 "Average read bandwidth",
127 ADD_STAT(writeBandwidthHist, statistics::units::Rate<
128 statistics::units::Byte, statistics::units::Second>::get(),
129 "Histogram of write bandwidth"),
130 ADD_STAT(totalWrittenBytes, statistics::units::Rate<
131 statistics::units::Byte, statistics::units::Second>::get(),
132 "Number of bytes written"),
133 ADD_STAT(averageWriteBandwidth, statistics::units::Rate<
134 statistics::units::Byte, statistics::units::Second>::get(),
135 "Average write bandwidth",
138 disableLatencyHists(params.disable_latency_hists),
139 ADD_STAT(readLatencyHist, statistics::units::
Tick::get(),
140 "Read request-response latency"),
141 ADD_STAT(writeLatencyHist, statistics::units::
Tick::get(),
142 "Write request-response latency"),
144 disableITTDists(params.disable_itt_dists),
146 "Read-to-read inter transaction time"),
148 "Write-to-write inter transaction time"),
150 "Request-to-request inter transaction time"),
151 timeOfLastRead(0), timeOfLastWrite(0), timeOfLastReq(0),
153 disableOutstandingHists(params.disable_outstanding_hists),
154 ADD_STAT(outstandingReadsHist, statistics::units::Count::get(),
155 "Outstanding read transactions"),
156 outstandingReadReqs(0),
157 ADD_STAT(outstandingWritesHist, statistics::units::Count::get(),
158 "Outstanding write transactions"),
159 outstandingWriteReqs(0),
161 disableTransactionHists(params.disable_transaction_hists),
162 ADD_STAT(readTransHist, statistics::units::Count::get(),
163 "Histogram of read transactions per sample period"),
165 ADD_STAT(writeTransHist, statistics::units::Count::get(),
166 "Histogram of write transactions per sample period"),
169 disableAddrDists(params.disable_addr_dists),
170 readAddrMask(params.read_addr_mask),
171 writeAddrMask(params.write_addr_mask),
172 ADD_STAT(readAddrDist, statistics::units::Count::get(),
173 "Read address distribution"),
174 ADD_STAT(writeAddrDist, statistics::units::Count::get(),
175 "Write address distribution")
177 using namespace statistics;
261 bool expects_response)
265 if (!disableTransactionHists)
269 if (!disableBurstLengthHists)
273 if (!disableAddrDists)
274 readAddrDist.sample(pkt_info.
addr & readAddrMask);
276 if (!disableITTDists) {
278 if (timeOfLastRead != 0)
279 ittReadRead.sample(
curTick() - timeOfLastRead);
283 if (timeOfLastReq != 0)
284 ittReqReq.sample(
curTick() - timeOfLastReq);
287 if (!is_atomic && !disableOutstandingHists && expects_response)
288 ++outstandingReadReqs;
292 if (!disableTransactionHists)
295 if (!disableBurstLengthHists)
296 writeBurstLengthHist.sample(pkt_info.
size);
299 if (!disableBandwidthHists) {
300 writtenBytes += pkt_info.
size;
301 totalWrittenBytes += pkt_info.
size;
305 if (!disableAddrDists)
306 writeAddrDist.sample(pkt_info.
addr & writeAddrMask);
308 if (!disableITTDists) {
310 if (timeOfLastWrite != 0)
311 ittWriteWrite.sample(
curTick() - timeOfLastWrite);
315 if (timeOfLastReq != 0)
316 ittReqReq.sample(
curTick() - timeOfLastReq);
320 if (!is_atomic && !disableOutstandingHists && expects_response)
321 ++outstandingWriteReqs;
331 if (!is_atomic && !disableOutstandingHists) {
332 assert(outstandingReadReqs != 0);
333 --outstandingReadReqs;
336 if (!disableLatencyHists)
337 readLatencyHist.sample(latency);
340 if (!disableBandwidthHists) {
341 readBytes += pkt_info.
size;
342 totalReadBytes += pkt_info.
size;
347 if (!is_atomic && !disableOutstandingHists) {
348 assert(outstandingWriteReqs != 0);
349 --outstandingWriteReqs;
352 if (!disableLatencyHists)
353 writeLatencyHist.sample(latency);
368 if (expects_response)
372 assert(pkt->
isResponse() || !expects_response);
419 pkt->
isWrite() ?
"write" :
"non read/write");
441 if (received_state == NULL)
442 panic(
"Monitor got a response without monitor sender state\n");
457 delete received_state;
468 pkt->
isWrite() ?
"write" :
"non read/write");
Sender state class for the monitor so that we can annotate packets with a transmit time and receive t...
Tick transmitTime
Tick when request is transmitted.
The communication monitor is a SimObject which can monitor statistics of the communication happening ...
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
const Tick samplePeriodTicks
Length of simulation time bin.
probing::PacketUPtr ppPktReq
Successfully forwarded request packet.
void recvTimingSnoopReq(PacketPtr pkt)
EventFunctionWrapper samplePeriodicEvent
Periodic event called at the end of each simulation time bin.
void recvFunctionalSnoop(PacketPtr pkt)
void recvFunctional(PacketPtr pkt)
CommMonitorParams Params
Parameters of communication monitor.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Tick recvAtomic(PacketPtr pkt)
void startup() override
startup() is the final initialization call before simulation.
bool recvTimingSnoopResp(PacketPtr pkt)
MonitorResponsePort cpuSidePort
Instance of response port, i.e.
Tick recvAtomicSnoop(PacketPtr pkt)
void regProbePoints() override
Register probe points for this object.
MonitorStats stats
Instantiate stats.
const double samplePeriod
Sample period in seconds.
void recvRetrySnoopResp()
bool tryTiming(PacketPtr pkt)
bool recvTimingReq(PacketPtr pkt)
AddrRangeList getAddrRanges() const
probing::PacketUPtr ppPktResp
Successfully forwarded response packet.
void samplePeriodic()
This function is called periodically at the end of each time bin.
CommMonitor(const Params ¶ms)
Constructor based on the Python params.
bool recvTimingResp(PacketPtr pkt)
MonitorRequestPort memSidePort
Instance of request port, facing the memory side.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
bool needsResponse() const
SenderState * senderState
This packet's sender state.
void pushSenderState(SenderState *sender_state)
Push a new sender state to the packet and make the current sender state the predecessor of the new on...
SenderState * popSenderState()
Pop the top of the state stack and return a pointer to it.
bool cacheResponding() const
Ports are used to interface objects to each other.
bool isConnected() const
Is this port currently connected to a peer?
ProbePointArg generates a point for the class of Arg.
virtual void sendRetryResp()
Send a retry to the response port that previously attempted a sendTimingResp to this request port and...
bool tryTiming(PacketPtr pkt) const
Check if the responder can handle a timing request.
Tick sendAtomic(PacketPtr pkt)
Send an atomic request packet, where the data is moved and the state is updated in zero time,...
AddrRangeList getAddrRanges() const
Get the address ranges of the connected responder port.
bool sendTimingReq(PacketPtr pkt)
Attempt to send a timing request to the responder port by calling its corresponding receive function.
bool sendTimingSnoopResp(PacketPtr pkt)
Attempt to send a timing snoop response packet to the response port by calling its corresponding rece...
void sendFunctional(PacketPtr pkt) const
Send a functional request packet, where the data is instantly updated everywhere in the memory system...
bool sendTimingResp(PacketPtr pkt)
Attempt to send a timing response to the request port by calling its corresponding receive function.
void sendFunctionalSnoop(PacketPtr pkt) const
Send a functional snoop request packet, where the data is instantly updated everywhere in the memory ...
void sendRetrySnoopResp()
Send a retry to the request port that previously attempted a sendTimingSnoopResp to this response por...
Tick sendAtomicSnoop(PacketPtr pkt)
Send an atomic snoop request packet, where the data is moved and the state is updated in zero time,...
void sendTimingSnoopReq(PacketPtr pkt)
Attempt to send a timing snoop request packet to the request port by calling its corresponding receiv...
bool isSnooping() const
Find out if the peer request port is snooping or not.
void sendRangeChange() const
Called by the owner to send a range change.
void sendRetryReq()
Send a retry to the request port that previously attempted a sendTimingReq to this response port and ...
Abstract superclass for simulation objects.
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
Distribution & init(Counter min, Counter max, Counter bkt)
Set the parameters of this distribution.
Histogram & init(size_type size)
Set the parameters of this histogram.
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
SparseHistogram & init(size_type size)
Set the parameters of this histogram.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
void schedule(Event &event, Tick when)
#define panic(...)
This implements a cprintf based panic() function.
#define fatal(...)
This implements a cprintf based fatal() function.
const Params & params() const
ProbeManager * getProbeManager()
Get the probe manager for this object.
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
double s
These variables equal the number of ticks in the unit of time they're named after in a double.
const FlagsType pdf
Print the percent of the total that this entry represents.
const FlagsType nozero
Don't print if this is zero.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Tick curTick()
The universal simulation clock.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
uint64_t Tick
Tick count type.
statistics::Value & simTicks
statistics::Formula & simSeconds
statistics::SparseHistogram writeAddrDist
Histogram of number of write accesses to addresses over time.
unsigned int outstandingWriteReqs
unsigned int outstandingReadReqs
statistics::Distribution ittReqReq
statistics::Histogram writeBandwidthHist
void updateRespStats(const probing::PacketInfo &pkt, Tick latency, bool is_atomic)
unsigned int writtenBytes
Histogram for write bandwidth per sample window.
statistics::Scalar totalWrittenBytes
bool disableBurstLengthHists
Disable flag for burst length histograms.
bool disableAddrDists
Disable flag for address distributions.
statistics::Histogram writeLatencyHist
Histogram of write request-to-response latencies.
statistics::Histogram outstandingWritesHist
Histogram of outstanding write requests.
statistics::Histogram writeBurstLengthHist
Histogram of write burst lengths.
bool disableTransactionHists
Disable flag for transaction histograms.
statistics::Histogram readLatencyHist
Histogram of read request-to-response latencies.
statistics::Histogram readTransHist
Histogram of number of read transactions per time bin.
bool disableLatencyHists
Disable flag for latency histograms.
bool disableBandwidthHists
Disable flag for the bandwidth histograms.
statistics::SparseHistogram readAddrDist
Histogram of number of read accesses to addresses over time.
statistics::Formula averageWriteBandwidth
statistics::Scalar totalReadBytes
unsigned int readBytes
Histogram for read bandwidth per sample window.
statistics::Histogram readBurstLengthHist
Histogram of read burst lengths.
bool disableITTDists
Disable flag for ITT distributions.
statistics::Histogram writeTransHist
Histogram of number of timing write transactions per time bin.
MonitorStats(statistics::Group *parent, const CommMonitorParams ¶ms)
Create the monitor stats and initialise all the members that are not statistics themselves,...
statistics::Histogram outstandingReadsHist
Histogram of outstanding read requests.
statistics::Distribution ittWriteWrite
void updateReqStats(const probing::PacketInfo &pkt, bool is_atomic, bool expects_response)
statistics::Histogram readBandwidthHist
statistics::Formula averageReadBandwidth
bool disableOutstandingHists
Disable flag for outstanding histograms.
statistics::Distribution ittReadRead
Inter transaction time (ITT) distributions.
SenderState * predecessor
A struct to hold on to the essential fields from a packet, so that the packet and underlying request ...
const std::string & name()