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