comm_monitor.cc (11793:ef606668d247) comm_monitor.cc (11804:220375a47eeb)
1/*
2 * Copyright (c) 2012-2013, 2015 ARM Limited
1/*
2 * Copyright (c) 2012-2013, 2015 ARM Limited
3 * All rights reserved
3 * Copyright (c) 2016 Google Inc.
4 * 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
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
39 */
40
41#include "mem/comm_monitor.hh"
42
43#include "base/trace.hh"
44#include "debug/CommMonitor.hh"
45#include "sim/stats.hh"
46
47CommMonitor::CommMonitor(Params* params)
48 : MemObject(params),
49 masterPort(name() + "-master", *this),
50 slavePort(name() + "-slave", *this),
51 samplePeriodicEvent(this),
52 samplePeriodTicks(params->sample_period),
53 samplePeriod(params->sample_period / SimClock::Float::s),
41 */
42
43#include "mem/comm_monitor.hh"
44
45#include "base/trace.hh"
46#include "debug/CommMonitor.hh"
47#include "sim/stats.hh"
48
49CommMonitor::CommMonitor(Params* params)
50 : MemObject(params),
51 masterPort(name() + "-master", *this),
52 slavePort(name() + "-slave", *this),
53 samplePeriodicEvent(this),
54 samplePeriodTicks(params->sample_period),
55 samplePeriod(params->sample_period / SimClock::Float::s),
54 readAddrMask(params->read_addr_mask),
55 writeAddrMask(params->write_addr_mask),
56 stats(params)
57{
58 DPRINTF(CommMonitor,
59 "Created monitor %s with sample period %d ticks (%f ms)\n",
60 name(), samplePeriodTicks, samplePeriod * 1E3);
61}
62
63CommMonitor*
64CommMonitorParams::create()
65{
66 return new CommMonitor(this);
67}
68
69void
70CommMonitor::init()
71{
72 // make sure both sides of the monitor are connected
73 if (!slavePort.isConnected() || !masterPort.isConnected())
74 fatal("Communication monitor is not connected on both sides.\n");
75}
76
77void
78CommMonitor::regProbePoints()
79{
80 ppPktReq.reset(new ProbePoints::Packet(getProbeManager(), "PktRequest"));
81 ppPktResp.reset(new ProbePoints::Packet(getProbeManager(), "PktResponse"));
82}
83
84BaseMasterPort&
85CommMonitor::getMasterPort(const std::string& if_name, PortID idx)
86{
87 if (if_name == "master") {
88 return masterPort;
89 } else {
90 return MemObject::getMasterPort(if_name, idx);
91 }
92}
93
94BaseSlavePort&
95CommMonitor::getSlavePort(const std::string& if_name, PortID idx)
96{
97 if (if_name == "slave") {
98 return slavePort;
99 } else {
100 return MemObject::getSlavePort(if_name, idx);
101 }
102}
103
104void
105CommMonitor::recvFunctional(PacketPtr pkt)
106{
107 masterPort.sendFunctional(pkt);
108}
109
110void
111CommMonitor::recvFunctionalSnoop(PacketPtr pkt)
112{
113 slavePort.sendFunctionalSnoop(pkt);
114}
115
56 stats(params)
57{
58 DPRINTF(CommMonitor,
59 "Created monitor %s with sample period %d ticks (%f ms)\n",
60 name(), samplePeriodTicks, samplePeriod * 1E3);
61}
62
63CommMonitor*
64CommMonitorParams::create()
65{
66 return new CommMonitor(this);
67}
68
69void
70CommMonitor::init()
71{
72 // make sure both sides of the monitor are connected
73 if (!slavePort.isConnected() || !masterPort.isConnected())
74 fatal("Communication monitor is not connected on both sides.\n");
75}
76
77void
78CommMonitor::regProbePoints()
79{
80 ppPktReq.reset(new ProbePoints::Packet(getProbeManager(), "PktRequest"));
81 ppPktResp.reset(new ProbePoints::Packet(getProbeManager(), "PktResponse"));
82}
83
84BaseMasterPort&
85CommMonitor::getMasterPort(const std::string& if_name, PortID idx)
86{
87 if (if_name == "master") {
88 return masterPort;
89 } else {
90 return MemObject::getMasterPort(if_name, idx);
91 }
92}
93
94BaseSlavePort&
95CommMonitor::getSlavePort(const std::string& if_name, PortID idx)
96{
97 if (if_name == "slave") {
98 return slavePort;
99 } else {
100 return MemObject::getSlavePort(if_name, idx);
101 }
102}
103
104void
105CommMonitor::recvFunctional(PacketPtr pkt)
106{
107 masterPort.sendFunctional(pkt);
108}
109
110void
111CommMonitor::recvFunctionalSnoop(PacketPtr pkt)
112{
113 slavePort.sendFunctionalSnoop(pkt);
114}
115
116void
117CommMonitor::MonitorStats::updateReqStats(
118 const ProbePoints::PacketInfo& pkt_info, bool is_atomic,
119 bool expects_response)
120{
121 if (pkt_info.cmd.isRead()) {
122 // Increment number of observed read transactions
123 if (!disableTransactionHists)
124 ++readTrans;
125
126 // Get sample of burst length
127 if (!disableBurstLengthHists)
128 readBurstLengthHist.sample(pkt_info.size);
129
130 // Sample the masked address
131 if (!disableAddrDists)
132 readAddrDist.sample(pkt_info.addr & readAddrMask);
133
134 if (!disableITTDists) {
135 // Sample value of read-read inter transaction time
136 if (timeOfLastRead != 0)
137 ittReadRead.sample(curTick() - timeOfLastRead);
138 timeOfLastRead = curTick();
139
140 // Sample value of req-req inter transaction time
141 if (timeOfLastReq != 0)
142 ittReqReq.sample(curTick() - timeOfLastReq);
143 timeOfLastReq = curTick();
144 }
145 if (!is_atomic && !disableOutstandingHists && expects_response)
146 ++outstandingReadReqs;
147
148 } else if (pkt_info.cmd.isWrite()) {
149 // Same as for reads
150 if (!disableTransactionHists)
151 ++writeTrans;
152
153 if (!disableBurstLengthHists)
154 writeBurstLengthHist.sample(pkt_info.size);
155
156 // Update the bandwidth stats on the request
157 if (!disableBandwidthHists) {
158 writtenBytes += pkt_info.size;
159 totalWrittenBytes += pkt_info.size;
160 }
161
162 // Sample the masked write address
163 if (!disableAddrDists)
164 writeAddrDist.sample(pkt_info.addr & writeAddrMask);
165
166 if (!disableITTDists) {
167 // Sample value of write-to-write inter transaction time
168 if (timeOfLastWrite != 0)
169 ittWriteWrite.sample(curTick() - timeOfLastWrite);
170 timeOfLastWrite = curTick();
171
172 // Sample value of req-to-req inter transaction time
173 if (timeOfLastReq != 0)
174 ittReqReq.sample(curTick() - timeOfLastReq);
175 timeOfLastReq = curTick();
176 }
177
178 if (!is_atomic && !disableOutstandingHists && expects_response)
179 ++outstandingWriteReqs;
180 }
181}
182
183void
184CommMonitor::MonitorStats::updateRespStats(
185 const ProbePoints::PacketInfo& pkt_info, Tick latency, bool is_atomic)
186{
187 if (pkt_info.cmd.isRead()) {
188 // Decrement number of outstanding read requests
189 if (!is_atomic && !disableOutstandingHists) {
190 assert(outstandingReadReqs != 0);
191 --outstandingReadReqs;
192 }
193
194 if (!disableLatencyHists)
195 readLatencyHist.sample(latency);
196
197 // Update the bandwidth stats based on responses for reads
198 if (!disableBandwidthHists) {
199 readBytes += pkt_info.size;
200 totalReadBytes += pkt_info.size;
201 }
202
203 } else if (pkt_info.cmd.isWrite()) {
204 // Decrement number of outstanding write requests
205 if (!is_atomic && !disableOutstandingHists) {
206 assert(outstandingWriteReqs != 0);
207 --outstandingWriteReqs;
208 }
209
210 if (!disableLatencyHists)
211 writeLatencyHist.sample(latency);
212 }
213}
214
116Tick
117CommMonitor::recvAtomic(PacketPtr pkt)
118{
215Tick
216CommMonitor::recvAtomic(PacketPtr pkt)
217{
218 const bool expects_response(pkt->needsResponse() &&
219 !pkt->cacheResponding());
119 ProbePoints::PacketInfo req_pkt_info(pkt);
120 ppPktReq->notify(req_pkt_info);
121
122 const Tick delay(masterPort.sendAtomic(pkt));
220 ProbePoints::PacketInfo req_pkt_info(pkt);
221 ppPktReq->notify(req_pkt_info);
222
223 const Tick delay(masterPort.sendAtomic(pkt));
224
225 stats.updateReqStats(req_pkt_info, true, expects_response);
226 if (expects_response)
227 stats.updateRespStats(req_pkt_info, delay, true);
228
123 assert(pkt->isResponse());
124 ProbePoints::PacketInfo resp_pkt_info(pkt);
125 ppPktResp->notify(resp_pkt_info);
126 return delay;
127}
128
129Tick
130CommMonitor::recvAtomicSnoop(PacketPtr pkt)
131{
132 return slavePort.sendAtomicSnoop(pkt);
133}
134
135bool
136CommMonitor::recvTimingReq(PacketPtr pkt)
137{
138 // should always see a request
139 assert(pkt->isRequest());
140
141 // Store relevant fields of packet, because packet may be modified
142 // or even deleted when sendTiming() is called.
143 const ProbePoints::PacketInfo pkt_info(pkt);
144
145 const bool is_read = pkt->isRead();
146 const bool is_write = pkt->isWrite();
229 assert(pkt->isResponse());
230 ProbePoints::PacketInfo resp_pkt_info(pkt);
231 ppPktResp->notify(resp_pkt_info);
232 return delay;
233}
234
235Tick
236CommMonitor::recvAtomicSnoop(PacketPtr pkt)
237{
238 return slavePort.sendAtomicSnoop(pkt);
239}
240
241bool
242CommMonitor::recvTimingReq(PacketPtr pkt)
243{
244 // should always see a request
245 assert(pkt->isRequest());
246
247 // Store relevant fields of packet, because packet may be modified
248 // or even deleted when sendTiming() is called.
249 const ProbePoints::PacketInfo pkt_info(pkt);
250
251 const bool is_read = pkt->isRead();
252 const bool is_write = pkt->isWrite();
147 const bool expects_response(
148 pkt->needsResponse() && !pkt->cacheResponding());
253 const bool expects_response(pkt->needsResponse() &&
254 !pkt->cacheResponding());
149
150 // If a cache miss is served by a cache, a monitor near the memory
151 // would see a request which needs a response, but this response
152 // would not come back from the memory. Therefore we additionally
153 // have to check the cacheResponding flag
154 if (expects_response && !stats.disableLatencyHists) {
155 pkt->pushSenderState(new CommMonitorSenderState(curTick()));
156 }
157
158 // Attempt to send the packet
159 bool successful = masterPort.sendTimingReq(pkt);
160
161 // If not successful, restore the sender state
162 if (!successful && expects_response && !stats.disableLatencyHists) {
163 delete pkt->popSenderState();
164 }
165
166 if (successful) {
167 ppPktReq->notify(pkt_info);
168 }
169
255
256 // If a cache miss is served by a cache, a monitor near the memory
257 // would see a request which needs a response, but this response
258 // would not come back from the memory. Therefore we additionally
259 // have to check the cacheResponding flag
260 if (expects_response && !stats.disableLatencyHists) {
261 pkt->pushSenderState(new CommMonitorSenderState(curTick()));
262 }
263
264 // Attempt to send the packet
265 bool successful = masterPort.sendTimingReq(pkt);
266
267 // If not successful, restore the sender state
268 if (!successful && expects_response && !stats.disableLatencyHists) {
269 delete pkt->popSenderState();
270 }
271
272 if (successful) {
273 ppPktReq->notify(pkt_info);
274 }
275
170 if (successful && is_read) {
171 DPRINTF(CommMonitor, "Forwarded read request\n");
172
173 // Increment number of observed read transactions
174 if (!stats.disableTransactionHists) {
175 ++stats.readTrans;
176 }
177
178 // Get sample of burst length
179 if (!stats.disableBurstLengthHists) {
180 stats.readBurstLengthHist.sample(pkt_info.size);
181 }
182
183 // Sample the masked address
184 if (!stats.disableAddrDists) {
185 stats.readAddrDist.sample(pkt_info.addr & readAddrMask);
186 }
187
188 // If it needs a response increment number of outstanding read
189 // requests
190 if (!stats.disableOutstandingHists && expects_response) {
191 ++stats.outstandingReadReqs;
192 }
193
194 if (!stats.disableITTDists) {
195 // Sample value of read-read inter transaction time
196 if (stats.timeOfLastRead != 0) {
197 stats.ittReadRead.sample(curTick() - stats.timeOfLastRead);
198 }
199 stats.timeOfLastRead = curTick();
200
201 // Sample value of req-req inter transaction time
202 if (stats.timeOfLastReq != 0) {
203 stats.ittReqReq.sample(curTick() - stats.timeOfLastReq);
204 }
205 stats.timeOfLastReq = curTick();
206 }
207 } else if (successful && is_write) {
208 DPRINTF(CommMonitor, "Forwarded write request\n");
209
210 // Same as for reads
211 if (!stats.disableTransactionHists) {
212 ++stats.writeTrans;
213 }
214
215 if (!stats.disableBurstLengthHists) {
216 stats.writeBurstLengthHist.sample(pkt_info.size);
217 }
218
219 // Update the bandwidth stats on the request
220 if (!stats.disableBandwidthHists) {
221 stats.writtenBytes += pkt_info.size;
222 stats.totalWrittenBytes += pkt_info.size;
223 }
224
225 // Sample the masked write address
226 if (!stats.disableAddrDists) {
227 stats.writeAddrDist.sample(pkt_info.addr & writeAddrMask);
228 }
229
230 if (!stats.disableOutstandingHists && expects_response) {
231 ++stats.outstandingWriteReqs;
232 }
233
234 if (!stats.disableITTDists) {
235 // Sample value of write-to-write inter transaction time
236 if (stats.timeOfLastWrite != 0) {
237 stats.ittWriteWrite.sample(curTick() - stats.timeOfLastWrite);
238 }
239 stats.timeOfLastWrite = curTick();
240
241 // Sample value of req-to-req inter transaction time
242 if (stats.timeOfLastReq != 0) {
243 stats.ittReqReq.sample(curTick() - stats.timeOfLastReq);
244 }
245 stats.timeOfLastReq = curTick();
246 }
247 } else if (successful) {
248 DPRINTF(CommMonitor, "Forwarded non read/write request\n");
276 if (successful) {
277 DPRINTF(CommMonitor, "Forwarded %s request\n",
278 (is_read ? "read" : (is_write ? "write" : "non read/write")));
279 stats.updateReqStats(pkt_info, false, expects_response);
249 }
280 }
250
251 return successful;
252}
253
254bool
255CommMonitor::recvTimingResp(PacketPtr pkt)
256{
257 // should always see responses
258 assert(pkt->isResponse());
259
260 // Store relevant fields of packet, because packet may be modified
261 // or even deleted when sendTiming() is called.
262 const ProbePoints::PacketInfo pkt_info(pkt);
263
264 bool is_read = pkt->isRead();
265 bool is_write = pkt->isWrite();
266 Tick latency = 0;
267 CommMonitorSenderState* received_state =
268 dynamic_cast<CommMonitorSenderState*>(pkt->senderState);
269
270 if (!stats.disableLatencyHists) {
271 // Restore initial sender state
272 if (received_state == NULL)
273 panic("Monitor got a response without monitor sender state\n");
274
275 // Restore the sate
276 pkt->senderState = received_state->predecessor;
277 }
278
279 // Attempt to send the packet
280 bool successful = slavePort.sendTimingResp(pkt);
281
282 if (!stats.disableLatencyHists) {
283 // If packet successfully send, sample value of latency,
284 // afterwards delete sender state, otherwise restore state
285 if (successful) {
286 latency = curTick() - received_state->transmitTime;
287 DPRINTF(CommMonitor, "Latency: %d\n", latency);
288 delete received_state;
289 } else {
290 // Don't delete anything and let the packet look like we
291 // did not touch it
292 pkt->senderState = received_state;
293 }
294 }
295
296 if (successful) {
297 ppPktResp->notify(pkt_info);
281 return successful;
282}
283
284bool
285CommMonitor::recvTimingResp(PacketPtr pkt)
286{
287 // should always see responses
288 assert(pkt->isResponse());
289
290 // Store relevant fields of packet, because packet may be modified
291 // or even deleted when sendTiming() is called.
292 const ProbePoints::PacketInfo pkt_info(pkt);
293
294 bool is_read = pkt->isRead();
295 bool is_write = pkt->isWrite();
296 Tick latency = 0;
297 CommMonitorSenderState* received_state =
298 dynamic_cast<CommMonitorSenderState*>(pkt->senderState);
299
300 if (!stats.disableLatencyHists) {
301 // Restore initial sender state
302 if (received_state == NULL)
303 panic("Monitor got a response without monitor sender state\n");
304
305 // Restore the sate
306 pkt->senderState = received_state->predecessor;
307 }
308
309 // Attempt to send the packet
310 bool successful = slavePort.sendTimingResp(pkt);
311
312 if (!stats.disableLatencyHists) {
313 // If packet successfully send, sample value of latency,
314 // afterwards delete sender state, otherwise restore state
315 if (successful) {
316 latency = curTick() - received_state->transmitTime;
317 DPRINTF(CommMonitor, "Latency: %d\n", latency);
318 delete received_state;
319 } else {
320 // Don't delete anything and let the packet look like we
321 // did not touch it
322 pkt->senderState = received_state;
323 }
324 }
325
326 if (successful) {
327 ppPktResp->notify(pkt_info);
328 DPRINTF(CommMonitor, "Received %s response\n",
329 (is_read ? "Read" : (is_write ? "Write" : "non read/write")));
330 stats.updateRespStats(pkt_info, latency, false);
298 }
331 }
299
300 if (successful && is_read) {
301 // Decrement number of outstanding read requests
302 DPRINTF(CommMonitor, "Received read response\n");
303 if (!stats.disableOutstandingHists) {
304 assert(stats.outstandingReadReqs != 0);
305 --stats.outstandingReadReqs;
306 }
307
308 if (!stats.disableLatencyHists) {
309 stats.readLatencyHist.sample(latency);
310 }
311
312 // Update the bandwidth stats based on responses for reads
313 if (!stats.disableBandwidthHists) {
314 stats.readBytes += pkt_info.size;
315 stats.totalReadBytes += pkt_info.size;
316 }
317
318 } else if (successful && is_write) {
319 // Decrement number of outstanding write requests
320 DPRINTF(CommMonitor, "Received write response\n");
321 if (!stats.disableOutstandingHists) {
322 assert(stats.outstandingWriteReqs != 0);
323 --stats.outstandingWriteReqs;
324 }
325
326 if (!stats.disableLatencyHists) {
327 stats.writeLatencyHist.sample(latency);
328 }
329 } else if (successful) {
330 DPRINTF(CommMonitor, "Received non read/write response\n");
331 }
332 return successful;
333}
334
335void
336CommMonitor::recvTimingSnoopReq(PacketPtr pkt)
337{
338 slavePort.sendTimingSnoopReq(pkt);
339}
340
341bool
342CommMonitor::recvTimingSnoopResp(PacketPtr pkt)
343{
344 return masterPort.sendTimingSnoopResp(pkt);
345}
346
347void
348CommMonitor::recvRetrySnoopResp()
349{
350 slavePort.sendRetrySnoopResp();
351}
352
353bool
354CommMonitor::isSnooping() const
355{
356 // check if the connected master port is snooping
357 return slavePort.isSnooping();
358}
359
360AddrRangeList
361CommMonitor::getAddrRanges() const
362{
363 // get the address ranges of the connected slave port
364 return masterPort.getAddrRanges();
365}
366
367void
368CommMonitor::recvReqRetry()
369{
370 slavePort.sendRetryReq();
371}
372
373void
374CommMonitor::recvRespRetry()
375{
376 masterPort.sendRetryResp();
377}
378
379void
380CommMonitor::recvRangeChange()
381{
382 slavePort.sendRangeChange();
383}
384
385void
386CommMonitor::regStats()
387{
388 MemObject::regStats();
389
390 // Initialise all the monitor stats
391 using namespace Stats;
392
393 stats.readBurstLengthHist
394 .init(params()->burst_length_bins)
395 .name(name() + ".readBurstLengthHist")
396 .desc("Histogram of burst lengths of transmitted packets")
397 .flags(stats.disableBurstLengthHists ? nozero : pdf);
398
399 stats.writeBurstLengthHist
400 .init(params()->burst_length_bins)
401 .name(name() + ".writeBurstLengthHist")
402 .desc("Histogram of burst lengths of transmitted packets")
403 .flags(stats.disableBurstLengthHists ? nozero : pdf);
404
405 // Stats based on received responses
406 stats.readBandwidthHist
407 .init(params()->bandwidth_bins)
408 .name(name() + ".readBandwidthHist")
409 .desc("Histogram of read bandwidth per sample period (bytes/s)")
410 .flags(stats.disableBandwidthHists ? nozero : pdf);
411
412 stats.averageReadBW
413 .name(name() + ".averageReadBandwidth")
414 .desc("Average read bandwidth (bytes/s)")
415 .flags(stats.disableBandwidthHists ? nozero : pdf);
416
417 stats.totalReadBytes
418 .name(name() + ".totalReadBytes")
419 .desc("Number of bytes read")
420 .flags(stats.disableBandwidthHists ? nozero : pdf);
421
422 stats.averageReadBW = stats.totalReadBytes / simSeconds;
423
424 // Stats based on successfully sent requests
425 stats.writeBandwidthHist
426 .init(params()->bandwidth_bins)
427 .name(name() + ".writeBandwidthHist")
428 .desc("Histogram of write bandwidth (bytes/s)")
429 .flags(stats.disableBandwidthHists ? (pdf | nozero) : pdf);
430
431 stats.averageWriteBW
432 .name(name() + ".averageWriteBandwidth")
433 .desc("Average write bandwidth (bytes/s)")
434 .flags(stats.disableBandwidthHists ? nozero : pdf);
435
436 stats.totalWrittenBytes
437 .name(name() + ".totalWrittenBytes")
438 .desc("Number of bytes written")
439 .flags(stats.disableBandwidthHists ? nozero : pdf);
440
441 stats.averageWriteBW = stats.totalWrittenBytes / simSeconds;
442
443 stats.readLatencyHist
444 .init(params()->latency_bins)
445 .name(name() + ".readLatencyHist")
446 .desc("Read request-response latency")
447 .flags(stats.disableLatencyHists ? nozero : pdf);
448
449 stats.writeLatencyHist
450 .init(params()->latency_bins)
451 .name(name() + ".writeLatencyHist")
452 .desc("Write request-response latency")
453 .flags(stats.disableLatencyHists ? nozero : pdf);
454
455 stats.ittReadRead
456 .init(1, params()->itt_max_bin, params()->itt_max_bin /
457 params()->itt_bins)
458 .name(name() + ".ittReadRead")
459 .desc("Read-to-read inter transaction time")
460 .flags(stats.disableITTDists ? nozero : pdf);
461
462 stats.ittWriteWrite
463 .init(1, params()->itt_max_bin, params()->itt_max_bin /
464 params()->itt_bins)
465 .name(name() + ".ittWriteWrite")
466 .desc("Write-to-write inter transaction time")
467 .flags(stats.disableITTDists ? nozero : pdf);
468
469 stats.ittReqReq
470 .init(1, params()->itt_max_bin, params()->itt_max_bin /
471 params()->itt_bins)
472 .name(name() + ".ittReqReq")
473 .desc("Request-to-request inter transaction time")
474 .flags(stats.disableITTDists ? nozero : pdf);
475
476 stats.outstandingReadsHist
477 .init(params()->outstanding_bins)
478 .name(name() + ".outstandingReadsHist")
479 .desc("Outstanding read transactions")
480 .flags(stats.disableOutstandingHists ? nozero : pdf);
481
482 stats.outstandingWritesHist
483 .init(params()->outstanding_bins)
484 .name(name() + ".outstandingWritesHist")
485 .desc("Outstanding write transactions")
486 .flags(stats.disableOutstandingHists ? nozero : pdf);
487
488 stats.readTransHist
489 .init(params()->transaction_bins)
490 .name(name() + ".readTransHist")
491 .desc("Histogram of read transactions per sample period")
492 .flags(stats.disableTransactionHists ? nozero : pdf);
493
494 stats.writeTransHist
495 .init(params()->transaction_bins)
496 .name(name() + ".writeTransHist")
497 .desc("Histogram of read transactions per sample period")
498 .flags(stats.disableTransactionHists ? nozero : pdf);
499
500 stats.readAddrDist
501 .init(0)
502 .name(name() + ".readAddrDist")
503 .desc("Read address distribution")
504 .flags(stats.disableAddrDists ? nozero : pdf);
505
506 stats.writeAddrDist
507 .init(0)
508 .name(name() + ".writeAddrDist")
509 .desc("Write address distribution")
510 .flags(stats.disableAddrDists ? nozero : pdf);
511}
512
513void
514CommMonitor::samplePeriodic()
515{
516 // the periodic stats update runs on the granularity of sample
517 // periods, but in combination with this there may also be a
518 // external resets and dumps of the stats (through schedStatEvent)
519 // causing the stats themselves to capture less than a sample
520 // period
521
522 // only capture if we have not reset the stats during the last
523 // sample period
524 if (simTicks.value() >= samplePeriodTicks) {
525 if (!stats.disableTransactionHists) {
526 stats.readTransHist.sample(stats.readTrans);
527 stats.writeTransHist.sample(stats.writeTrans);
528 }
529
530 if (!stats.disableBandwidthHists) {
531 stats.readBandwidthHist.sample(stats.readBytes / samplePeriod);
532 stats.writeBandwidthHist.sample(stats.writtenBytes / samplePeriod);
533 }
534
535 if (!stats.disableOutstandingHists) {
536 stats.outstandingReadsHist.sample(stats.outstandingReadReqs);
537 stats.outstandingWritesHist.sample(stats.outstandingWriteReqs);
538 }
539 }
540
541 // reset the sampled values
542 stats.readTrans = 0;
543 stats.writeTrans = 0;
544
545 stats.readBytes = 0;
546 stats.writtenBytes = 0;
547
548 schedule(samplePeriodicEvent, curTick() + samplePeriodTicks);
549}
550
551void
552CommMonitor::startup()
553{
554 schedule(samplePeriodicEvent, curTick() + samplePeriodTicks);
555}
332 return successful;
333}
334
335void
336CommMonitor::recvTimingSnoopReq(PacketPtr pkt)
337{
338 slavePort.sendTimingSnoopReq(pkt);
339}
340
341bool
342CommMonitor::recvTimingSnoopResp(PacketPtr pkt)
343{
344 return masterPort.sendTimingSnoopResp(pkt);
345}
346
347void
348CommMonitor::recvRetrySnoopResp()
349{
350 slavePort.sendRetrySnoopResp();
351}
352
353bool
354CommMonitor::isSnooping() const
355{
356 // check if the connected master port is snooping
357 return slavePort.isSnooping();
358}
359
360AddrRangeList
361CommMonitor::getAddrRanges() const
362{
363 // get the address ranges of the connected slave port
364 return masterPort.getAddrRanges();
365}
366
367void
368CommMonitor::recvReqRetry()
369{
370 slavePort.sendRetryReq();
371}
372
373void
374CommMonitor::recvRespRetry()
375{
376 masterPort.sendRetryResp();
377}
378
379void
380CommMonitor::recvRangeChange()
381{
382 slavePort.sendRangeChange();
383}
384
385void
386CommMonitor::regStats()
387{
388 MemObject::regStats();
389
390 // Initialise all the monitor stats
391 using namespace Stats;
392
393 stats.readBurstLengthHist
394 .init(params()->burst_length_bins)
395 .name(name() + ".readBurstLengthHist")
396 .desc("Histogram of burst lengths of transmitted packets")
397 .flags(stats.disableBurstLengthHists ? nozero : pdf);
398
399 stats.writeBurstLengthHist
400 .init(params()->burst_length_bins)
401 .name(name() + ".writeBurstLengthHist")
402 .desc("Histogram of burst lengths of transmitted packets")
403 .flags(stats.disableBurstLengthHists ? nozero : pdf);
404
405 // Stats based on received responses
406 stats.readBandwidthHist
407 .init(params()->bandwidth_bins)
408 .name(name() + ".readBandwidthHist")
409 .desc("Histogram of read bandwidth per sample period (bytes/s)")
410 .flags(stats.disableBandwidthHists ? nozero : pdf);
411
412 stats.averageReadBW
413 .name(name() + ".averageReadBandwidth")
414 .desc("Average read bandwidth (bytes/s)")
415 .flags(stats.disableBandwidthHists ? nozero : pdf);
416
417 stats.totalReadBytes
418 .name(name() + ".totalReadBytes")
419 .desc("Number of bytes read")
420 .flags(stats.disableBandwidthHists ? nozero : pdf);
421
422 stats.averageReadBW = stats.totalReadBytes / simSeconds;
423
424 // Stats based on successfully sent requests
425 stats.writeBandwidthHist
426 .init(params()->bandwidth_bins)
427 .name(name() + ".writeBandwidthHist")
428 .desc("Histogram of write bandwidth (bytes/s)")
429 .flags(stats.disableBandwidthHists ? (pdf | nozero) : pdf);
430
431 stats.averageWriteBW
432 .name(name() + ".averageWriteBandwidth")
433 .desc("Average write bandwidth (bytes/s)")
434 .flags(stats.disableBandwidthHists ? nozero : pdf);
435
436 stats.totalWrittenBytes
437 .name(name() + ".totalWrittenBytes")
438 .desc("Number of bytes written")
439 .flags(stats.disableBandwidthHists ? nozero : pdf);
440
441 stats.averageWriteBW = stats.totalWrittenBytes / simSeconds;
442
443 stats.readLatencyHist
444 .init(params()->latency_bins)
445 .name(name() + ".readLatencyHist")
446 .desc("Read request-response latency")
447 .flags(stats.disableLatencyHists ? nozero : pdf);
448
449 stats.writeLatencyHist
450 .init(params()->latency_bins)
451 .name(name() + ".writeLatencyHist")
452 .desc("Write request-response latency")
453 .flags(stats.disableLatencyHists ? nozero : pdf);
454
455 stats.ittReadRead
456 .init(1, params()->itt_max_bin, params()->itt_max_bin /
457 params()->itt_bins)
458 .name(name() + ".ittReadRead")
459 .desc("Read-to-read inter transaction time")
460 .flags(stats.disableITTDists ? nozero : pdf);
461
462 stats.ittWriteWrite
463 .init(1, params()->itt_max_bin, params()->itt_max_bin /
464 params()->itt_bins)
465 .name(name() + ".ittWriteWrite")
466 .desc("Write-to-write inter transaction time")
467 .flags(stats.disableITTDists ? nozero : pdf);
468
469 stats.ittReqReq
470 .init(1, params()->itt_max_bin, params()->itt_max_bin /
471 params()->itt_bins)
472 .name(name() + ".ittReqReq")
473 .desc("Request-to-request inter transaction time")
474 .flags(stats.disableITTDists ? nozero : pdf);
475
476 stats.outstandingReadsHist
477 .init(params()->outstanding_bins)
478 .name(name() + ".outstandingReadsHist")
479 .desc("Outstanding read transactions")
480 .flags(stats.disableOutstandingHists ? nozero : pdf);
481
482 stats.outstandingWritesHist
483 .init(params()->outstanding_bins)
484 .name(name() + ".outstandingWritesHist")
485 .desc("Outstanding write transactions")
486 .flags(stats.disableOutstandingHists ? nozero : pdf);
487
488 stats.readTransHist
489 .init(params()->transaction_bins)
490 .name(name() + ".readTransHist")
491 .desc("Histogram of read transactions per sample period")
492 .flags(stats.disableTransactionHists ? nozero : pdf);
493
494 stats.writeTransHist
495 .init(params()->transaction_bins)
496 .name(name() + ".writeTransHist")
497 .desc("Histogram of read transactions per sample period")
498 .flags(stats.disableTransactionHists ? nozero : pdf);
499
500 stats.readAddrDist
501 .init(0)
502 .name(name() + ".readAddrDist")
503 .desc("Read address distribution")
504 .flags(stats.disableAddrDists ? nozero : pdf);
505
506 stats.writeAddrDist
507 .init(0)
508 .name(name() + ".writeAddrDist")
509 .desc("Write address distribution")
510 .flags(stats.disableAddrDists ? nozero : pdf);
511}
512
513void
514CommMonitor::samplePeriodic()
515{
516 // the periodic stats update runs on the granularity of sample
517 // periods, but in combination with this there may also be a
518 // external resets and dumps of the stats (through schedStatEvent)
519 // causing the stats themselves to capture less than a sample
520 // period
521
522 // only capture if we have not reset the stats during the last
523 // sample period
524 if (simTicks.value() >= samplePeriodTicks) {
525 if (!stats.disableTransactionHists) {
526 stats.readTransHist.sample(stats.readTrans);
527 stats.writeTransHist.sample(stats.writeTrans);
528 }
529
530 if (!stats.disableBandwidthHists) {
531 stats.readBandwidthHist.sample(stats.readBytes / samplePeriod);
532 stats.writeBandwidthHist.sample(stats.writtenBytes / samplePeriod);
533 }
534
535 if (!stats.disableOutstandingHists) {
536 stats.outstandingReadsHist.sample(stats.outstandingReadReqs);
537 stats.outstandingWritesHist.sample(stats.outstandingWriteReqs);
538 }
539 }
540
541 // reset the sampled values
542 stats.readTrans = 0;
543 stats.writeTrans = 0;
544
545 stats.readBytes = 0;
546 stats.writtenBytes = 0;
547
548 schedule(samplePeriodicEvent, curTick() + samplePeriodTicks);
549}
550
551void
552CommMonitor::startup()
553{
554 schedule(samplePeriodicEvent, curTick() + samplePeriodTicks);
555}