1/* 2 * Copyright (c) 2012-2013, 2015 ARM Limited |
3 * Copyright (c) 2016 Google Inc. 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, --- 19 unchanged lines hidden (view full) --- 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 |
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), |
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* --- 44 unchanged lines hidden (view full) --- 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 |
215Tick 216CommMonitor::recvAtomic(PacketPtr pkt) 217{ |
218 const bool expects_response(pkt->needsResponse() && 219 !pkt->cacheResponding()); |
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 |
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) --- 8 unchanged lines hidden (view full) --- 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(); |
253 const bool expects_response(pkt->needsResponse() && 254 !pkt->cacheResponding()); |
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 } --- 5 unchanged lines hidden (view full) --- 268 if (!successful && expects_response && !stats.disableLatencyHists) { 269 delete pkt->popSenderState(); 270 } 271 272 if (successful) { 273 ppPktReq->notify(pkt_info); 274 } 275 |
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); |
280 } |
281 return successful; 282} 283 284bool 285CommMonitor::recvTimingResp(PacketPtr pkt) 286{ 287 // should always see responses 288 assert(pkt->isResponse()); --- 31 unchanged lines hidden (view full) --- 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); |
331 } |
332 return successful; 333} 334 335void 336CommMonitor::recvTimingSnoopReq(PacketPtr pkt) 337{ 338 slavePort.sendTimingSnoopReq(pkt); 339} --- 216 unchanged lines hidden --- |