48 #include "debug/CommMonitor.hh" 53 masterPort(
name() +
"-master", *this),
54 slavePort(
name() +
"-slave", *this),
61 "Created monitor %s with sample period %d ticks (%f ms)\n",
66 CommMonitorParams::create()
76 fatal(
"Communication monitor is not connected on both sides.\n");
89 if (if_name ==
"master") {
91 }
else if (if_name ==
"slave") {
111 const CommMonitorParams *
params)
114 disableBurstLengthHists(params->disable_burst_length_hists),
116 "Histogram of burst lengths of transmitted packets"),
118 "Histogram of burst lengths of transmitted packets"),
120 disableBandwidthHists(params->disable_bandwidth_hists),
123 "Histogram of read bandwidth per sample period (bytes/s)"),
124 ADD_STAT(totalReadBytes,
"Number of bytes read"),
125 ADD_STAT(averageReadBandwidth,
"Average read bandwidth (bytes/s)",
129 ADD_STAT(writeBandwidthHist,
"Histogram of write bandwidth (bytes/s)"),
130 ADD_STAT(totalWrittenBytes,
"Number of bytes written"),
131 ADD_STAT(averageWriteBandwidth,
"Average write bandwidth (bytes/s)",
134 disableLatencyHists(params->disable_latency_hists),
135 ADD_STAT(readLatencyHist,
"Read request-response latency"),
136 ADD_STAT(writeLatencyHist,
"Write request-response latency"),
138 disableITTDists(params->disable_itt_dists),
139 ADD_STAT(ittReadRead,
"Read-to-read inter transaction time"),
140 ADD_STAT(ittWriteWrite ,
"Write-to-write inter transaction time"),
141 ADD_STAT(ittReqReq,
"Request-to-request inter transaction time"),
142 timeOfLastRead(0), timeOfLastWrite(0), timeOfLastReq(0),
144 disableOutstandingHists(params->disable_outstanding_hists),
145 ADD_STAT(outstandingReadsHist,
"Outstanding read transactions"),
146 outstandingReadReqs(0),
147 ADD_STAT(outstandingWritesHist,
"Outstanding write transactions"),
148 outstandingWriteReqs(0),
150 disableTransactionHists(params->disable_transaction_hists),
152 "Histogram of read transactions per sample period"),
155 "Histogram of write transactions per sample period"),
158 disableAddrDists(params->disable_addr_dists),
159 readAddrMask(params->read_addr_mask),
160 writeAddrMask(params->write_addr_mask),
161 ADD_STAT(readAddrDist,
"Read address distribution"),
162 ADD_STAT(writeAddrDist,
"Write address distribution")
164 using namespace Stats;
167 .
init(params->burst_length_bins)
171 .
init(params->burst_length_bins)
176 .
init(params->bandwidth_bins)
187 .
init(params->bandwidth_bins)
198 .
init(params->latency_bins)
202 .
init(params->latency_bins)
206 .
init(1, params->itt_max_bin, params->itt_max_bin /
211 .
init(1, params->itt_max_bin, params->itt_max_bin /
216 .
init(1, params->itt_max_bin, params->itt_max_bin /
221 .
init(params->outstanding_bins)
225 .
init(params->outstanding_bins)
229 .
init(params->transaction_bins)
233 .
init(params->transaction_bins)
248 bool expects_response)
354 stats.updateReqStats(req_pkt_info,
true, expects_response);
355 if (expects_response)
356 stats.updateRespStats(req_pkt_info, delay,
true);
359 assert(pkt->
isResponse() || !expects_response);
388 if (expects_response && !
stats.disableLatencyHists) {
396 if (!successful && expects_response && !
stats.disableLatencyHists) {
406 pkt->
isWrite() ?
"write" :
"non read/write");
407 stats.updateReqStats(pkt_info,
false, expects_response);
426 if (!
stats.disableLatencyHists) {
428 if (received_state == NULL)
429 panic(
"Monitor got a response without monitor sender state\n");
438 if (!
stats.disableLatencyHists) {
444 delete received_state;
455 pkt->
isWrite() ?
"write" :
"non read/write");
456 stats.updateRespStats(pkt_info, latency,
false);
529 if (!
stats.disableTransactionHists) {
531 stats.writeTransHist.sample(
stats.writeTrans);
534 if (!
stats.disableBandwidthHists) {
539 if (!
stats.disableOutstandingHists) {
540 stats.outstandingReadsHist.sample(
stats.outstandingReadReqs);
541 stats.outstandingWritesHist.sample(
stats.outstandingWriteReqs);
547 stats.writeTrans = 0;
550 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)
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
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.
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.
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
virtual const std::string name() const
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.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
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
ProbeManager * getProbeManager()
Get the probe manager for this object.
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 schedule(Event &event, Tick when)
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)