43 #include "debug/CommMonitor.hh" 48 masterPort(
name() +
"-master", *this),
49 slavePort(
name() +
"-slave", *this),
56 "Created monitor %s with sample period %d ticks (%f ms)\n",
61 CommMonitorParams::create()
71 fatal(
"Communication monitor is not connected on both sides.\n");
84 if (if_name ==
"master") {
86 }
else if (if_name ==
"slave") {
106 const CommMonitorParams *
params)
109 disableBurstLengthHists(params->disable_burst_length_hists),
111 "Histogram of burst lengths of transmitted packets"),
113 "Histogram of burst lengths of transmitted packets"),
115 disableBandwidthHists(params->disable_bandwidth_hists),
118 "Histogram of read bandwidth per sample period (bytes/s)"),
119 ADD_STAT(totalReadBytes,
"Number of bytes read"),
120 ADD_STAT(averageReadBandwidth,
"Average read bandwidth (bytes/s)",
124 ADD_STAT(writeBandwidthHist,
"Histogram of write bandwidth (bytes/s)"),
125 ADD_STAT(totalWrittenBytes,
"Number of bytes written"),
126 ADD_STAT(averageWriteBandwidth,
"Average write bandwidth (bytes/s)",
129 disableLatencyHists(params->disable_latency_hists),
130 ADD_STAT(readLatencyHist,
"Read request-response latency"),
131 ADD_STAT(writeLatencyHist,
"Write request-response latency"),
133 disableITTDists(params->disable_itt_dists),
134 ADD_STAT(ittReadRead,
"Read-to-read inter transaction time"),
135 ADD_STAT(ittWriteWrite ,
"Write-to-write inter transaction time"),
136 ADD_STAT(ittReqReq,
"Request-to-request inter transaction time"),
137 timeOfLastRead(0), timeOfLastWrite(0), timeOfLastReq(0),
139 disableOutstandingHists(params->disable_outstanding_hists),
140 ADD_STAT(outstandingReadsHist,
"Outstanding read transactions"),
141 outstandingReadReqs(0),
142 ADD_STAT(outstandingWritesHist,
"Outstanding write transactions"),
143 outstandingWriteReqs(0),
145 disableTransactionHists(params->disable_transaction_hists),
147 "Histogram of read transactions per sample period"),
150 "Histogram of write transactions per sample period"),
153 disableAddrDists(params->disable_addr_dists),
154 readAddrMask(params->read_addr_mask),
155 writeAddrMask(params->write_addr_mask),
156 ADD_STAT(readAddrDist,
"Read address distribution"),
157 ADD_STAT(writeAddrDist,
"Write address distribution")
159 using namespace Stats;
162 .
init(params->burst_length_bins)
166 .
init(params->burst_length_bins)
171 .
init(params->bandwidth_bins)
182 .
init(params->bandwidth_bins)
193 .
init(params->latency_bins)
197 .
init(params->latency_bins)
201 .
init(1, params->itt_max_bin, params->itt_max_bin /
206 .
init(1, params->itt_max_bin, params->itt_max_bin /
211 .
init(1, params->itt_max_bin, params->itt_max_bin /
216 .
init(params->outstanding_bins)
220 .
init(params->outstanding_bins)
224 .
init(params->transaction_bins)
228 .
init(params->transaction_bins)
243 bool expects_response)
349 stats.updateReqStats(req_pkt_info,
true, expects_response);
350 if (expects_response)
351 stats.updateRespStats(req_pkt_info, delay,
true);
354 assert(pkt->
isResponse() || !expects_response);
383 if (expects_response && !
stats.disableLatencyHists) {
391 if (!successful && expects_response && !
stats.disableLatencyHists) {
401 pkt->
isWrite() ?
"write" :
"non read/write");
402 stats.updateReqStats(pkt_info,
false, expects_response);
421 if (!
stats.disableLatencyHists) {
423 if (received_state == NULL)
424 panic(
"Monitor got a response without monitor sender state\n");
433 if (!
stats.disableLatencyHists) {
439 delete received_state;
450 pkt->
isWrite() ?
"write" :
"non read/write");
451 stats.updateRespStats(pkt_info, latency,
false);
524 if (!
stats.disableTransactionHists) {
526 stats.writeTransHist.sample(
stats.writeTrans);
529 if (!
stats.disableBandwidthHists) {
534 if (!
stats.disableOutstandingHists) {
535 stats.outstandingReadsHist.sample(
stats.outstandingReadReqs);
536 stats.outstandingWritesHist.sample(
stats.outstandingWriteReqs);
542 stats.writeTrans = 0;
545 stats.writtenBytes = 0;
unsigned int writtenBytes
Histogram for write bandwidth per sample window.
#define panic(...)
This implements a cprintf based panic() function.
void startup() override
startup() is the final initialization call before simulation.
const FlagsType pdf
Print the percent of the total that this entry represents.
Ports are used to interface objects to each other.
Tick recvAtomic(PacketPtr pkt)
bool disableBurstLengthHists
Disable flag for burst length histograms.
EventFunctionWrapper samplePeriodicEvent
Periodic event called at the end of each simulation time bin.
void sendRangeChange() const
Called by the owner to send a range change.
#define fatal(...)
This implements a cprintf based fatal() function.
AddrRangeList getAddrRanges() const
const std::string & name()
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.
unsigned int readBytes
Histogram for read bandwidth per sample window.
Sender state class for the monitor so that we can annotate packets with a transmit time and receive t...
bool sendTimingSnoopResp(PacketPtr pkt)
Attempt to send a timing snoop response packet to the slave port by calling its corresponding receive...
void updateRespStats(const ProbePoints::PacketInfo &pkt, Tick latency, bool is_atomic)
const Params * params() const
bool tryTiming(PacketPtr pkt) const
Check if the slave can handle a timing request.
Tick sendAtomicSnoop(PacketPtr pkt)
Send an atomic snoop request packet, where the data is moved and the state is updated in zero time...
bool cacheResponding() const
bool recvTimingReq(PacketPtr pkt)
Histogram & init(size_type size)
Set the parameters of this histogram.
double s
These variables equal the number of ticks in the unit of time they're named after in a double...
bool sendTimingReq(PacketPtr pkt)
Attempt to send a timing request to the slave port by calling its corresponding receive function...
bool isConnected() const
Is this port currently connected to a peer?
virtual void sendRetryResp()
Send a retry to the slave port that previously attempted a sendTimingResp to this master port and fai...
CommMonitor(Params *params)
Constructor based on the Python params.
unsigned int outstandingWriteReqs
bool disableITTDists
Disable flag for ITT distributions.
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
void sendRetrySnoopResp()
Send a retry to the master port that previously attempted a sendTimingSnoopResp to this slave port an...
Stats::Formula simSeconds
void recvFunctionalSnoop(PacketPtr pkt)
void sendFunctionalSnoop(PacketPtr pkt) const
Send a functional snoop request packet, where the data is instantly updated everywhere in the memory ...
Stats::Histogram readTransHist
Histogram of number of read transactions per time bin.
Stats::Histogram writeBurstLengthHist
Histogram of write burst lengths.
void recvRetrySnoopResp()
Stats::Scalar totalReadBytes
ProbePoints::PacketUPtr ppPktReq
Successfully forwarded request packet.
Stats::Histogram outstandingWritesHist
Histogram of outstanding write requests.
bool sendTimingResp(PacketPtr pkt)
Attempt to send a timing response to the master port by calling its corresponding receive function...
const Addr writeAddrMask
Address mask for sources of write accesses to be captured.
Tick curTick()
The current simulated tick.
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
bool needsResponse() const
CommMonitorParams Params
Parameters of communication monitor.
SenderState * predecessor
bool recvTimingResp(PacketPtr pkt)
Stats::Histogram writeLatencyHist
Histogram of write request-to-response latencies.
bool disableLatencyHists
Disable flag for latency histograms.
bool disableAddrDists
Disable flag for address distributions.
void recvFunctional(PacketPtr pkt)
uint64_t Tick
Tick count type.
Stats::Histogram writeTransHist
Histogram of number of timing write transactions per time bin.
void regProbePoints() override
Register probe points for this object.
Tick transmitTime
Tick when request is transmitted.
void schedule(Event &event, Tick when)
Distribution & init(Counter min, Counter max, Counter bkt)
Set the parameters of this distribution.
MonitorSlavePort slavePort
Instance of slave port, i.e.
Stats::Formula averageReadBandwidth
bool isSnooping() const
Find out if the peer master port is snooping or not.
The communication monitor is a SimObject which can monitor statistics of the communication happening ...
Stats::Distribution ittWriteWrite
bool disableTransactionHists
Disable flag for transaction histograms.
bool disableOutstandingHists
Disable flag for outstanding histograms.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Stats::Distribution ittReadRead
Inter transaction time (ITT) distributions.
MonitorStats(Stats::Group *parent, const CommMonitorParams *params)
Create the monitor stats and initialise all the members that are not statistics themselves, but used to control the stats or track values during a sample period.
const Addr readAddrMask
Address mask for sources of read accesses to be captured.
MonitorMasterPort masterPort
Instance of master port, facing the memory side.
ProbeManager * getProbeManager()
Get the probe manager for this object.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
virtual const std::string name() const
ProbePointArg generates a point for the class of Arg.
Stats::Scalar totalWrittenBytes
AddrRangeList getAddrRanges() const
Get the address ranges of the connected slave port.
bool tryTiming(PacketPtr pkt)
void sendRetryReq()
Send a retry to the master port that previously attempted a sendTimingReq to this slave port and fail...
SenderState * senderState
This packet's sender state.
Stats::Histogram readBandwidthHist
bool disableBandwidthHists
Disable flag for the bandwidth histograms.
void sendTimingSnoopReq(PacketPtr pkt)
Attempt to send a timing snoop request packet to the master port by calling its corresponding receive...
Stats::Histogram readBurstLengthHist
Histogram of read burst lengths.
SparseHistogram & init(size_type size)
Set the parameters of this histogram.
void recvTimingSnoopReq(PacketPtr pkt)
ProbePoints::PacketUPtr ppPktResp
Successfully forwarded response packet.
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.
void sendFunctional(PacketPtr pkt) const
Send a functional request packet, where the data is instantly updated everywhere in the memory system...
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
void samplePeriodic()
This function is called periodically at the end of each time bin.
const double samplePeriod
Sample period in seconds.
unsigned int outstandingReadReqs
Tick recvAtomicSnoop(PacketPtr pkt)
Stats::Histogram outstandingReadsHist
Histogram of outstanding read requests.
Tick sendAtomic(PacketPtr pkt)
Send an atomic request packet, where the data is moved and the state is updated in zero time...
const FlagsType nozero
Don't print if this is zero.
Stats::SparseHistogram readAddrDist
Histogram of number of read accesses to addresses over time.
std::vector< Info * > stats
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Stats::Histogram writeBandwidthHist
Abstract superclass for simulation objects.
Stats::Distribution ittReqReq
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
Stats::SparseHistogram writeAddrDist
Histogram of number of write accesses to addresses over time.
bool recvTimingSnoopResp(PacketPtr pkt)
MonitorStats stats
Instantiate stats.
Stats::Formula averageWriteBandwidth
A struct to hold on to the essential fields from a packet, so that the packet and underlying request ...
Stats::Histogram readLatencyHist
Histogram of read request-to-response latencies.
void updateReqStats(const ProbePoints::PacketInfo &pkt, bool is_atomic, bool expects_response)