comm_monitor.hh (11848:f438fcbab00e) comm_monitor.hh (11904:870e25baf014)
1/*
2 * Copyright (c) 2012-2013, 2015 ARM Limited
3 * Copyright (c) 2016 Google Inc.
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
4 * All rights reserved.
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating
9 * to a hardware implementation of the functionality of the software
10 * licensed hereunder. You may use the software subject to the license
11 * terms below provided that you ensure that this notice is replicated
12 * unmodified and in its entirety in all distributions of the software,
13 * modified or unmodified, in source code or in binary form.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions are
17 * met: redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer;
19 * redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution;
22 * neither the name of the copyright holders nor the names of its
23 * contributors may be used to endorse or promote products derived from
24 * this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 *
38 * Authors: Thomas Grass
39 * Andreas Hansson
40 * Rahul Thakur
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
41 */
42
43#ifndef __MEM_COMM_MONITOR_HH__
44#define __MEM_COMM_MONITOR_HH__
45
46#include "base/statistics.hh"
47#include "mem/mem_object.hh"
48#include "params/CommMonitor.hh"
49#include "sim/probe/mem.hh"
50
51/**
52 * The communication monitor is a MemObject which can monitor statistics of
53 * the communication happening between two ports in the memory system.
54 *
55 * Currently the following stats are implemented: Histograms of read/write
56 * transactions, read/write burst lengths, read/write bandwidth,
57 * outstanding read/write requests, read latency and inter transaction time
58 * (read-read, write-write, read/write-read/write). Furthermore it allows
59 * to capture the number of accesses to an address over time ("heat map").
60 * All stats can be disabled from Python.
61 */
62class CommMonitor : public MemObject
63{
64
65 public: // Construction & SimObject interfaces
66
67 /** Parameters of communication monitor */
68 typedef CommMonitorParams Params;
69 const Params* params() const
70 { return reinterpret_cast<const Params*>(_params); }
71
72 /**
73 * Constructor based on the Python params
74 *
75 * @param params Python parameters
76 */
77 CommMonitor(Params* params);
78
79 void init() override;
80 void regStats() override;
81 void startup() override;
82 void regProbePoints() override;
83
84 public: // MemObject interfaces
85 BaseMasterPort& getMasterPort(const std::string& if_name,
86 PortID idx = InvalidPortID) override;
87
88 BaseSlavePort& getSlavePort(const std::string& if_name,
89 PortID idx = InvalidPortID) override;
90
91 private:
92
93 /**
94 * Sender state class for the monitor so that we can annotate
95 * packets with a transmit time and receive time.
96 */
97 class CommMonitorSenderState : public Packet::SenderState
98 {
99
100 public:
101
102 /**
103 * Construct a new sender state and store the time so we can
104 * calculate round-trip latency.
105 *
106 * @param _transmitTime Time of packet transmission
107 */
108 CommMonitorSenderState(Tick _transmitTime)
109 : transmitTime(_transmitTime)
110 { }
111
112 /** Destructor */
113 ~CommMonitorSenderState() { }
114
115 /** Tick when request is transmitted */
116 Tick transmitTime;
117
118 };
119
120 /**
121 * This is the master port of the communication monitor. All recv
122 * functions call a function in CommMonitor, where the
123 * send function of the slave port is called. Besides this, these
124 * functions can also perform actions for capturing statistics.
125 */
126 class MonitorMasterPort : public MasterPort
127 {
128
129 public:
130
131 MonitorMasterPort(const std::string& _name, CommMonitor& _mon)
132 : MasterPort(_name, &_mon), mon(_mon)
133 { }
134
135 protected:
136
137 void recvFunctionalSnoop(PacketPtr pkt)
138 {
139 mon.recvFunctionalSnoop(pkt);
140 }
141
142 Tick recvAtomicSnoop(PacketPtr pkt)
143 {
144 return mon.recvAtomicSnoop(pkt);
145 }
146
147 bool recvTimingResp(PacketPtr pkt)
148 {
149 return mon.recvTimingResp(pkt);
150 }
151
152 void recvTimingSnoopReq(PacketPtr pkt)
153 {
154 mon.recvTimingSnoopReq(pkt);
155 }
156
157 void recvRangeChange()
158 {
159 mon.recvRangeChange();
160 }
161
162 bool isSnooping() const
163 {
164 return mon.isSnooping();
165 }
166
167 void recvReqRetry()
168 {
169 mon.recvReqRetry();
170 }
171
172 void recvRetrySnoopResp()
173 {
174 mon.recvRetrySnoopResp();
175 }
176
177 private:
178
179 CommMonitor& mon;
180
181 };
182
183 /** Instance of master port, facing the memory side */
184 MonitorMasterPort masterPort;
185
186 /**
187 * This is the slave port of the communication monitor. All recv
188 * functions call a function in CommMonitor, where the
189 * send function of the master port is called. Besides this, these
190 * functions can also perform actions for capturing statistics.
191 */
192 class MonitorSlavePort : public SlavePort
193 {
194
195 public:
196
197 MonitorSlavePort(const std::string& _name, CommMonitor& _mon)
198 : SlavePort(_name, &_mon), mon(_mon)
199 { }
200
201 protected:
202
203 void recvFunctional(PacketPtr pkt)
204 {
205 mon.recvFunctional(pkt);
206 }
207
208 Tick recvAtomic(PacketPtr pkt)
209 {
210 return mon.recvAtomic(pkt);
211 }
212
213 bool recvTimingReq(PacketPtr pkt)
214 {
215 return mon.recvTimingReq(pkt);
216 }
217
218 bool recvTimingSnoopResp(PacketPtr pkt)
219 {
220 return mon.recvTimingSnoopResp(pkt);
221 }
222
223 AddrRangeList getAddrRanges() const
224 {
225 return mon.getAddrRanges();
226 }
227
228 void recvRespRetry()
229 {
230 mon.recvRespRetry();
231 }
232
233 private:
234
235 CommMonitor& mon;
236
237 };
238
239 /** Instance of slave port, i.e. on the CPU side */
240 MonitorSlavePort slavePort;
241
242 void recvFunctional(PacketPtr pkt);
243
244 void recvFunctionalSnoop(PacketPtr pkt);
245
246 Tick recvAtomic(PacketPtr pkt);
247
248 Tick recvAtomicSnoop(PacketPtr pkt);
249
250 bool recvTimingReq(PacketPtr pkt);
251
252 bool recvTimingResp(PacketPtr pkt);
253
254 void recvTimingSnoopReq(PacketPtr pkt);
255
256 bool recvTimingSnoopResp(PacketPtr pkt);
257
258 void recvRetrySnoopResp();
259
260 AddrRangeList getAddrRanges() const;
261
262 bool isSnooping() const;
263
264 void recvReqRetry();
265
266 void recvRespRetry();
267
268 void recvRangeChange();
269
270 /** Stats declarations, all in a struct for convenience. */
271 struct MonitorStats
272 {
273
274 /** Disable flag for burst length histograms **/
275 bool disableBurstLengthHists;
276
277 /** Histogram of read burst lengths */
278 Stats::Histogram readBurstLengthHist;
279
280 /** Histogram of write burst lengths */
281 Stats::Histogram writeBurstLengthHist;
282
283 /** Disable flag for the bandwidth histograms */
284 bool disableBandwidthHists;
285
286 /**
287 * Histogram for read bandwidth per sample window. The
288 * internal counter is an unsigned int rather than a stat.
289 */
290 unsigned int readBytes;
291 Stats::Histogram readBandwidthHist;
292 Stats::Formula averageReadBW;
293 Stats::Scalar totalReadBytes;
294
295 /**
296 * Histogram for write bandwidth per sample window. The
297 * internal counter is an unsigned int rather than a stat.
298 */
299 unsigned int writtenBytes;
300 Stats::Histogram writeBandwidthHist;
301 Stats::Formula averageWriteBW;
302 Stats::Scalar totalWrittenBytes;
303
304 /** Disable flag for latency histograms. */
305 bool disableLatencyHists;
306
307 /** Histogram of read request-to-response latencies */
308 Stats::Histogram readLatencyHist;
309
310 /** Histogram of write request-to-response latencies */
311 Stats::Histogram writeLatencyHist;
312
313 /** Disable flag for ITT distributions. */
314 bool disableITTDists;
315
316 /**
317 * Inter transaction time (ITT) distributions. There are
318 * histograms of the time between two read, write or arbitrary
319 * accesses. The time of a request is the tick at which the
320 * request is forwarded by the monitor.
321 */
322 Stats::Distribution ittReadRead;
323 Stats::Distribution ittWriteWrite;
324 Stats::Distribution ittReqReq;
325 Tick timeOfLastRead;
326 Tick timeOfLastWrite;
327 Tick timeOfLastReq;
328
329 /** Disable flag for outstanding histograms. */
330 bool disableOutstandingHists;
331
332 /**
333 * Histogram of outstanding read requests. Counter for
334 * outstanding read requests is an unsigned integer because
335 * it should not be reset when stats are reset.
336 */
337 Stats::Histogram outstandingReadsHist;
338 unsigned int outstandingReadReqs;
339
340 /**
341 * Histogram of outstanding write requests. Counter for
342 * outstanding write requests is an unsigned integer because
343 * it should not be reset when stats are reset.
344 */
345 Stats::Histogram outstandingWritesHist;
346 unsigned int outstandingWriteReqs;
347
348 /** Disable flag for transaction histograms. */
349 bool disableTransactionHists;
350
351 /** Histogram of number of read transactions per time bin */
352 Stats::Histogram readTransHist;
353 unsigned int readTrans;
354
355 /** Histogram of number of timing write transactions per time bin */
356 Stats::Histogram writeTransHist;
357 unsigned int writeTrans;
358
359 /** Disable flag for address distributions. */
360 bool disableAddrDists;
361
362 /** Address mask for sources of read accesses to be captured */
363 const Addr readAddrMask;
364
365 /** Address mask for sources of write accesses to be captured */
366 const Addr writeAddrMask;
367
368 /**
369 * Histogram of number of read accesses to addresses over
370 * time.
371 */
372 Stats::SparseHistogram readAddrDist;
373
374 /**
375 * Histogram of number of write accesses to addresses over
376 * time.
377 */
378 Stats::SparseHistogram writeAddrDist;
379
380 /**
381 * Create the monitor stats and initialise all the members
382 * that are not statistics themselves, but used to control the
383 * stats or track values during a sample period.
384 */
385 MonitorStats(const CommMonitorParams* params) :
386 disableBurstLengthHists(params->disable_burst_length_hists),
387 disableBandwidthHists(params->disable_bandwidth_hists),
388 readBytes(0), writtenBytes(0),
389 disableLatencyHists(params->disable_latency_hists),
390 disableITTDists(params->disable_itt_dists),
391 timeOfLastRead(0), timeOfLastWrite(0), timeOfLastReq(0),
392 disableOutstandingHists(params->disable_outstanding_hists),
393 outstandingReadReqs(0), outstandingWriteReqs(0),
394 disableTransactionHists(params->disable_transaction_hists),
395 readTrans(0), writeTrans(0),
396 disableAddrDists(params->disable_addr_dists),
397 readAddrMask(params->read_addr_mask),
398 writeAddrMask(params->write_addr_mask)
399 { }
400
401 void updateReqStats(const ProbePoints::PacketInfo& pkt, bool is_atomic,
402 bool expects_response);
403 void updateRespStats(const ProbePoints::PacketInfo& pkt, Tick latency,
404 bool is_atomic);
405 };
406
407 /** This function is called periodically at the end of each time bin */
408 void samplePeriodic();
409
410 /** Periodic event called at the end of each simulation time bin */
411 EventWrapper<CommMonitor, &CommMonitor::samplePeriodic> samplePeriodicEvent;
412
413 /**
414 *@{
415 * @name Configuration
416 */
417
418 /** Length of simulation time bin*/
419 const Tick samplePeriodTicks;
420 /** Sample period in seconds */
421 const double samplePeriod;
422
423 /** @} */
424
425 /** Instantiate stats */
426 MonitorStats stats;
427
428 protected: // Probe points
429 /**
430 * @{
431 * @name Memory system probe points
432 */
433
434 /** Successfully forwarded request packet */
435 ProbePoints::PacketUPtr ppPktReq;
436
437 /** Successfully forwarded response packet */
438 ProbePoints::PacketUPtr ppPktResp;
439
440 /** @} */
441};
442
443#endif //__MEM_COMM_MONITOR_HH__
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
53/**
54 * The communication monitor is a MemObject which can monitor statistics of
55 * the communication happening between two ports in the memory system.
56 *
57 * Currently the following stats are implemented: Histograms of read/write
58 * transactions, read/write burst lengths, read/write bandwidth,
59 * outstanding read/write requests, read latency and inter transaction time
60 * (read-read, write-write, read/write-read/write). Furthermore it allows
61 * to capture the number of accesses to an address over time ("heat map").
62 * All stats can be disabled from Python.
63 */
64class CommMonitor : public MemObject
65{
66
67 public: // Construction & SimObject interfaces
68
69 /** Parameters of communication monitor */
70 typedef CommMonitorParams Params;
71 const Params* params() const
72 { return reinterpret_cast<const Params*>(_params); }
73
74 /**
75 * Constructor based on the Python params
76 *
77 * @param params Python parameters
78 */
79 CommMonitor(Params* params);
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
95 /**
96 * Sender state class for the monitor so that we can annotate
97 * packets with a transmit time and receive time.
98 */
99 class CommMonitorSenderState : public Packet::SenderState
100 {
101
102 public:
103
104 /**
105 * Construct a new sender state and store the time so we can
106 * calculate round-trip latency.
107 *
108 * @param _transmitTime Time of packet transmission
109 */
110 CommMonitorSenderState(Tick _transmitTime)
111 : transmitTime(_transmitTime)
112 { }
113
114 /** Destructor */
115 ~CommMonitorSenderState() { }
116
117 /** Tick when request is transmitted */
118 Tick transmitTime;
119
120 };
121
122 /**
123 * This is the master port of the communication monitor. All recv
124 * functions call a function in CommMonitor, where the
125 * send function of the slave port is called. Besides this, these
126 * functions can also perform actions for capturing statistics.
127 */
128 class MonitorMasterPort : public MasterPort
129 {
130
131 public:
132
133 MonitorMasterPort(const std::string& _name, CommMonitor& _mon)
134 : MasterPort(_name, &_mon), mon(_mon)
135 { }
136
137 protected:
138
139 void recvFunctionalSnoop(PacketPtr pkt)
140 {
141 mon.recvFunctionalSnoop(pkt);
142 }
143
144 Tick recvAtomicSnoop(PacketPtr pkt)
145 {
146 return mon.recvAtomicSnoop(pkt);
147 }
148
149 bool recvTimingResp(PacketPtr pkt)
150 {
151 return mon.recvTimingResp(pkt);
152 }
153
154 void recvTimingSnoopReq(PacketPtr pkt)
155 {
156 mon.recvTimingSnoopReq(pkt);
157 }
158
159 void recvRangeChange()
160 {
161 mon.recvRangeChange();
162 }
163
164 bool isSnooping() const
165 {
166 return mon.isSnooping();
167 }
168
169 void recvReqRetry()
170 {
171 mon.recvReqRetry();
172 }
173
174 void recvRetrySnoopResp()
175 {
176 mon.recvRetrySnoopResp();
177 }
178
179 private:
180
181 CommMonitor& mon;
182
183 };
184
185 /** Instance of master port, facing the memory side */
186 MonitorMasterPort masterPort;
187
188 /**
189 * This is the slave port of the communication monitor. All recv
190 * functions call a function in CommMonitor, where the
191 * send function of the master port is called. Besides this, these
192 * functions can also perform actions for capturing statistics.
193 */
194 class MonitorSlavePort : public SlavePort
195 {
196
197 public:
198
199 MonitorSlavePort(const std::string& _name, CommMonitor& _mon)
200 : SlavePort(_name, &_mon), mon(_mon)
201 { }
202
203 protected:
204
205 void recvFunctional(PacketPtr pkt)
206 {
207 mon.recvFunctional(pkt);
208 }
209
210 Tick recvAtomic(PacketPtr pkt)
211 {
212 return mon.recvAtomic(pkt);
213 }
214
215 bool recvTimingReq(PacketPtr pkt)
216 {
217 return mon.recvTimingReq(pkt);
218 }
219
220 bool recvTimingSnoopResp(PacketPtr pkt)
221 {
222 return mon.recvTimingSnoopResp(pkt);
223 }
224
225 AddrRangeList getAddrRanges() const
226 {
227 return mon.getAddrRanges();
228 }
229
230 void recvRespRetry()
231 {
232 mon.recvRespRetry();
233 }
234
235 private:
236
237 CommMonitor& mon;
238
239 };
240
241 /** Instance of slave port, i.e. on the CPU side */
242 MonitorSlavePort slavePort;
243
244 void recvFunctional(PacketPtr pkt);
245
246 void recvFunctionalSnoop(PacketPtr pkt);
247
248 Tick recvAtomic(PacketPtr pkt);
249
250 Tick recvAtomicSnoop(PacketPtr pkt);
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
262 AddrRangeList getAddrRanges() const;
263
264 bool isSnooping() const;
265
266 void recvReqRetry();
267
268 void recvRespRetry();
269
270 void recvRangeChange();
271
272 /** Stats declarations, all in a struct for convenience. */
273 struct MonitorStats
274 {
275
276 /** Disable flag for burst length histograms **/
277 bool disableBurstLengthHists;
278
279 /** Histogram of read burst lengths */
280 Stats::Histogram readBurstLengthHist;
281
282 /** Histogram of write burst lengths */
283 Stats::Histogram writeBurstLengthHist;
284
285 /** Disable flag for the bandwidth histograms */
286 bool disableBandwidthHists;
287
288 /**
289 * Histogram for read bandwidth per sample window. The
290 * internal counter is an unsigned int rather than a stat.
291 */
292 unsigned int readBytes;
293 Stats::Histogram readBandwidthHist;
294 Stats::Formula averageReadBW;
295 Stats::Scalar totalReadBytes;
296
297 /**
298 * Histogram for write bandwidth per sample window. The
299 * internal counter is an unsigned int rather than a stat.
300 */
301 unsigned int writtenBytes;
302 Stats::Histogram writeBandwidthHist;
303 Stats::Formula averageWriteBW;
304 Stats::Scalar totalWrittenBytes;
305
306 /** Disable flag for latency histograms. */
307 bool disableLatencyHists;
308
309 /** Histogram of read request-to-response latencies */
310 Stats::Histogram readLatencyHist;
311
312 /** Histogram of write request-to-response latencies */
313 Stats::Histogram writeLatencyHist;
314
315 /** Disable flag for ITT distributions. */
316 bool disableITTDists;
317
318 /**
319 * Inter transaction time (ITT) distributions. There are
320 * histograms of the time between two read, write or arbitrary
321 * accesses. The time of a request is the tick at which the
322 * request is forwarded by the monitor.
323 */
324 Stats::Distribution ittReadRead;
325 Stats::Distribution ittWriteWrite;
326 Stats::Distribution ittReqReq;
327 Tick timeOfLastRead;
328 Tick timeOfLastWrite;
329 Tick timeOfLastReq;
330
331 /** Disable flag for outstanding histograms. */
332 bool disableOutstandingHists;
333
334 /**
335 * Histogram of outstanding read requests. Counter for
336 * outstanding read requests is an unsigned integer because
337 * it should not be reset when stats are reset.
338 */
339 Stats::Histogram outstandingReadsHist;
340 unsigned int outstandingReadReqs;
341
342 /**
343 * Histogram of outstanding write requests. Counter for
344 * outstanding write requests is an unsigned integer because
345 * it should not be reset when stats are reset.
346 */
347 Stats::Histogram outstandingWritesHist;
348 unsigned int outstandingWriteReqs;
349
350 /** Disable flag for transaction histograms. */
351 bool disableTransactionHists;
352
353 /** Histogram of number of read transactions per time bin */
354 Stats::Histogram readTransHist;
355 unsigned int readTrans;
356
357 /** Histogram of number of timing write transactions per time bin */
358 Stats::Histogram writeTransHist;
359 unsigned int writeTrans;
360
361 /** Disable flag for address distributions. */
362 bool disableAddrDists;
363
364 /** Address mask for sources of read accesses to be captured */
365 const Addr readAddrMask;
366
367 /** Address mask for sources of write accesses to be captured */
368 const Addr writeAddrMask;
369
370 /**
371 * Histogram of number of read accesses to addresses over
372 * time.
373 */
374 Stats::SparseHistogram readAddrDist;
375
376 /**
377 * Histogram of number of write accesses to addresses over
378 * time.
379 */
380 Stats::SparseHistogram writeAddrDist;
381
382 /**
383 * Create the monitor stats and initialise all the members
384 * that are not statistics themselves, but used to control the
385 * stats or track values during a sample period.
386 */
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),
393 timeOfLastRead(0), timeOfLastWrite(0), timeOfLastReq(0),
394 disableOutstandingHists(params->disable_outstanding_hists),
395 outstandingReadReqs(0), outstandingWriteReqs(0),
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
409 /** This function is called periodically at the end of each time bin */
410 void samplePeriodic();
411
412 /** Periodic event called at the end of each simulation time bin */
413 EventWrapper<CommMonitor, &CommMonitor::samplePeriodic> samplePeriodicEvent;
414
415 /**
416 *@{
417 * @name Configuration
418 */
419
420 /** Length of simulation time bin*/
421 const Tick samplePeriodTicks;
422 /** Sample period in seconds */
423 const double samplePeriod;
424
425 /** @} */
426
427 /** Instantiate stats */
428 MonitorStats stats;
429
430 protected: // Probe points
431 /**
432 * @{
433 * @name Memory system probe points
434 */
435
436 /** Successfully forwarded request packet */
437 ProbePoints::PacketUPtr ppPktReq;
438
439 /** Successfully forwarded response packet */
440 ProbePoints::PacketUPtr ppPktResp;
441
442 /** @} */
443};
444
445#endif //__MEM_COMM_MONITOR_HH__