gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
comm_monitor.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013, 2015 ARM Limited
3  * Copyright (c) 2016 Google Inc.
4  * Copyright (c) 2017, Centre National de la Recherche Scientifique
5  * All rights reserved.
6  *
7  * The license below extends only to copyright in the software and shall
8  * not be construed as granting a license to any other intellectual
9  * property including but not limited to intellectual property relating
10  * to a hardware implementation of the functionality of the software
11  * licensed hereunder. You may use the software subject to the license
12  * terms below provided that you ensure that this notice is replicated
13  * unmodified and in its entirety in all distributions of the software,
14  * modified or unmodified, in source code or in binary form.
15  *
16  * Redistribution and use in source and binary forms, with or without
17  * modification, are permitted provided that the following conditions are
18  * met: redistributions of source code must retain the above copyright
19  * notice, this list of conditions and the following disclaimer;
20  * redistributions in binary form must reproduce the above copyright
21  * notice, this list of conditions and the following disclaimer in the
22  * documentation and/or other materials provided with the distribution;
23  * neither the name of the copyright holders nor the names of its
24  * contributors may be used to endorse or promote products derived from
25  * this software without specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38  *
39  * Authors: Thomas Grass
40  * Andreas Hansson
41  * Rahul Thakur
42  * Pierre-Yves Peneau
43  */
44 
45 #ifndef __MEM_COMM_MONITOR_HH__
46 #define __MEM_COMM_MONITOR_HH__
47 
48 #include "base/statistics.hh"
49 #include "mem/mem_object.hh"
50 #include "params/CommMonitor.hh"
51 #include "sim/probe/mem.hh"
52 
64 class CommMonitor : public MemObject
65 {
66 
67  public: // Construction & SimObject interfaces
68 
70  typedef CommMonitorParams Params;
71  const Params* params() const
72  { return reinterpret_cast<const Params*>(_params); }
73 
80 
81  void init() override;
82  void regStats() override;
83  void startup() override;
84  void regProbePoints() override;
85 
86  public: // MemObject interfaces
87  BaseMasterPort& getMasterPort(const std::string& if_name,
88  PortID idx = InvalidPortID) override;
89 
90  BaseSlavePort& getSlavePort(const std::string& if_name,
91  PortID idx = InvalidPortID) override;
92 
93  private:
94 
100  {
101 
102  public:
103 
111  : transmitTime(_transmitTime)
112  { }
113 
116 
119 
120  };
121 
129  {
130 
131  public:
132 
133  MonitorMasterPort(const std::string& _name, CommMonitor& _mon)
134  : MasterPort(_name, &_mon), mon(_mon)
135  { }
136 
137  protected:
138 
140  {
142  }
143 
145  {
146  return mon.recvAtomicSnoop(pkt);
147  }
148 
150  {
151  return mon.recvTimingResp(pkt);
152  }
153 
155  {
156  mon.recvTimingSnoopReq(pkt);
157  }
158 
160  {
162  }
163 
164  bool isSnooping() const
165  {
166  return mon.isSnooping();
167  }
168 
170  {
171  mon.recvReqRetry();
172  }
173 
175  {
177  }
178 
179  private:
180 
182 
183  };
184 
187 
195  {
196 
197  public:
198 
199  MonitorSlavePort(const std::string& _name, CommMonitor& _mon)
200  : SlavePort(_name, &_mon), mon(_mon)
201  { }
202 
203  protected:
204 
206  {
207  mon.recvFunctional(pkt);
208  }
209 
211  {
212  return mon.recvAtomic(pkt);
213  }
214 
216  {
217  return mon.recvTimingReq(pkt);
218  }
219 
221  {
222  return mon.recvTimingSnoopResp(pkt);
223  }
224 
226  {
227  return mon.getAddrRanges();
228  }
229 
231  {
232  mon.recvRespRetry();
233  }
234 
235  private:
236 
238 
239  };
240 
243 
244  void recvFunctional(PacketPtr pkt);
245 
246  void recvFunctionalSnoop(PacketPtr pkt);
247 
249 
251 
252  bool recvTimingReq(PacketPtr pkt);
253 
254  bool recvTimingResp(PacketPtr pkt);
255 
256  void recvTimingSnoopReq(PacketPtr pkt);
257 
258  bool recvTimingSnoopResp(PacketPtr pkt);
259 
260  void recvRetrySnoopResp();
261 
263 
264  bool isSnooping() const;
265 
266  void recvReqRetry();
267 
268  void recvRespRetry();
269 
270  void recvRangeChange();
271 
274  {
275 
278 
281 
284 
287 
292  unsigned int readBytes;
296 
301  unsigned int writtenBytes;
305 
308 
311 
314 
317 
330 
333 
340  unsigned int outstandingReadReqs;
341 
348  unsigned int outstandingWriteReqs;
349 
352 
355  unsigned int readTrans;
356 
359  unsigned int writeTrans;
360 
363 
366 
369 
375 
381 
387  MonitorStats(const CommMonitorParams* params) :
388  disableBurstLengthHists(params->disable_burst_length_hists),
389  disableBandwidthHists(params->disable_bandwidth_hists),
390  readBytes(0), writtenBytes(0),
391  disableLatencyHists(params->disable_latency_hists),
392  disableITTDists(params->disable_itt_dists),
394  disableOutstandingHists(params->disable_outstanding_hists),
396  disableTransactionHists(params->disable_transaction_hists),
397  readTrans(0), writeTrans(0),
398  disableAddrDists(params->disable_addr_dists),
399  readAddrMask(params->read_addr_mask),
400  writeAddrMask(params->write_addr_mask)
401  { }
402 
403  void updateReqStats(const ProbePoints::PacketInfo& pkt, bool is_atomic,
404  bool expects_response);
405  void updateRespStats(const ProbePoints::PacketInfo& pkt, Tick latency,
406  bool is_atomic);
407  };
408 
410  void samplePeriodic();
411 
414 
423  const double samplePeriod;
424 
429 
430  protected: // Probe points
438 
441 
443 };
444 
445 #endif //__MEM_COMM_MONITOR_HH__
Stats::Formula averageReadBW
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:167
unsigned int writtenBytes
Histogram for write bandwidth per sample window.
void startup() override
startup() is the final initialization call before simulation.
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the slave port.
BaseSlavePort & getSlavePort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a slave port with a given name and index.
Definition: comm_monitor.cc:97
Tick recvAtomic(PacketPtr pkt)
void recvTimingSnoopReq(PacketPtr pkt)
Receive a timing snoop request from the slave port.
bool disableBurstLengthHists
Disable flag for burst length histograms.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: comm_monitor.cc:72
const Tick samplePeriodTicks
Length of simulation time bin.
const PortID InvalidPortID
Definition: types.hh:182
bool isSnooping() const
unsigned int readBytes
Histogram for read bandwidth per sample window.
MonitorMasterPort(const std::string &_name, CommMonitor &_mon)
Sender state class for the monitor so that we can annotate packets with a transmit time and receive t...
Definition: comm_monitor.hh:99
void updateRespStats(const ProbePoints::PacketInfo &pkt, Tick latency, bool is_atomic)
void recvRespRetry()
MemObject declaration.
void recvRespRetry()
Called by the master port if sendTimingResp was called on this slave port (causing recvTimingResp to ...
void regStats() override
Register statistics for this object.
bool recvTimingReq(PacketPtr pkt)
void recvReqRetry()
Called by the slave port if sendTimingReq was called on this master port (causing recvTimingReq to be...
MonitorSlavePort(const std::string &_name, CommMonitor &_mon)
A SlavePort is a specialisation of a port.
Definition: port.hh:331
Tick recvAtomic(PacketPtr pkt)
Receive an atomic request packet from the master port.
CommMonitor(Params *params)
Constructor based on the Python params.
Definition: comm_monitor.cc:51
unsigned int outstandingWriteReqs
void recvRetrySnoopResp()
Called by the slave port if sendTimingSnoopResp was called on this master port (causing recvTimingSno...
bool disableITTDists
Disable flag for ITT distributions.
A BaseSlavePort is a protocol-agnostic slave port, responsible only for the structural connection to ...
Definition: port.hh:139
Declaration of Statistics objects.
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2475
void recvReqRetry()
void recvFunctionalSnoop(PacketPtr pkt)
std::unique_ptr< Packet > PacketUPtr
Definition: mem.hh:103
Stats declarations, all in a struct for convenience.
AddrRangeList getAddrRanges() const
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.
Stats::Formula averageWriteBW
const Addr writeAddrMask
Address mask for sources of write accesses to be captured.
This is the slave port of the communication monitor.
CommMonitorParams Params
Parameters of communication monitor.
Definition: comm_monitor.hh:70
This is the master port of the communication monitor.
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.
Definition: types.hh:63
A simple distribution stat.
Definition: statistics.hh:2523
Stats::Histogram writeTransHist
Histogram of number of timing write transactions per time bin.
void regProbePoints() override
Register probe points for this object.
Definition: comm_monitor.cc:80
Tick recvAtomicSnoop(PacketPtr pkt)
Receive an atomic snoop request packet from the slave port.
A simple histogram stat.
Definition: statistics.hh:2551
bool recvTimingSnoopResp(PacketPtr pkt)
Receive a timing snoop response from the master port.
CommMonitorSenderState(Tick _transmitTime)
Construct a new sender state and store the time so we can calculate round-trip latency.
Tick transmitTime
Tick when request is transmitted.
MonitorSlavePort slavePort
Instance of slave port, i.e.
The communication monitor is a MemObject which can monitor statistics of the communication happening ...
Definition: comm_monitor.hh:64
Stats::Distribution ittWriteWrite
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
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...
Definition: packet.hh:245
Stats::Distribution ittReadRead
Inter transaction time (ITT) distributions.
void recvRangeChange()
AddrRangeList getAddrRanges() const
Get a list of the non-overlapping address ranges the owner is responsible for.
A virtual base opaque structure used to hold state associated with the packet (e.g., an MSHR), specific to a MemObject that sees the packet.
Definition: packet.hh:377
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2895
const Addr readAddrMask
Address mask for sources of read accesses to be captured.
MonitorMasterPort masterPort
Instance of master port, facing the memory side.
BaseMasterPort & getMasterPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a master port with a given name and index.
Definition: comm_monitor.cc:87
Stats::Scalar totalWrittenBytes
bool recvTimingReq(PacketPtr pkt)
Receive a timing request from the master port.
Stats::Histogram readBandwidthHist
void recvRangeChange()
Called to receive an address range change from the peer slave port.
The MemObject class extends the ClockedObject with accessor functions to get its master and slave por...
Definition: mem_object.hh:60
bool isSnooping() const
Determine if this master port is snooping or not.
A BaseMasterPort is a protocol-agnostic master port, responsible only for the structural connection t...
Definition: port.hh:115
bool disableBandwidthHists
Disable flag for the bandwidth histograms.
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:107
Stats::Histogram readBurstLengthHist
Histogram of read burst lengths.
void recvTimingSnoopReq(PacketPtr pkt)
ProbePoints::PacketUPtr ppPktResp
Successfully forwarded response packet.
void recvFunctional(PacketPtr pkt)
Receive a functional request packet from the master port.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:181
void samplePeriodic()
This function is called periodically at the end of each time bin.
const double samplePeriod
Sample period in seconds.
EventWrapper< CommMonitor,&CommMonitor::samplePeriodic > samplePeriodicEvent
Periodic event called at the end of each simulation time bin.
unsigned int outstandingReadReqs
Tick recvAtomicSnoop(PacketPtr pkt)
MonitorStats(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.
Stats::Histogram outstandingReadsHist
Histogram of outstanding read requests.
const Params * params() const
Definition: comm_monitor.hh:71
Stats::SparseHistogram readAddrDist
Histogram of number of read accesses to addresses over time.
void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the slave port.
Stats::Histogram writeBandwidthHist
Stats::Distribution ittReqReq
Stats::SparseHistogram writeAddrDist
Histogram of number of write accesses to addresses over time.
bool recvTimingSnoopResp(PacketPtr pkt)
MonitorStats stats
Instantiate stats.
A struct to hold on to the essential fields from a packet, so that the packet and underlying request ...
Definition: mem.hh:54
Stats::Histogram readLatencyHist
Histogram of read request-to-response latencies.
void updateReqStats(const ProbePoints::PacketInfo &pkt, bool is_atomic, bool expects_response)

Generated on Fri Jun 9 2017 13:03:48 for gem5 by doxygen 1.8.6