From b3fc8839c4727da575ed916cbd6a76d8ad5fc644 Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Tue, 19 Feb 2013 05:56:06 -0500 Subject: mem: Make packet bus-related time accounting relative This patch changes the bus-related time accounting done in the packet to be relative. Besides making it easier to align the cache timing to cache clock cycles, it also makes it possible to create a Last-Level Cache (LLC) directly to a memory controller without a bus inbetween. The bus is unique in that it does not ever make the packets wait to reflect the time spent forwarding them. Instead, the cache is currently responsible for making the packets wait. Thus, the bus annotates the packets with the time needed for the first word to appear, and also the last word. The cache then delays the packets in its queues before passing them on. It is worth noting that every object attached to a bus (devices, memories, bridges, etc) should be doing this if we opt for keeping this way of accounting for the bus timing. --- src/mem/cache/cache_impl.hh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/mem/cache') diff --git a/src/mem/cache/cache_impl.hh b/src/mem/cache/cache_impl.hh index a7e6a6186..7aa922055 100644 --- a/src/mem/cache/cache_impl.hh +++ b/src/mem/cache/cache_impl.hh @@ -898,8 +898,9 @@ Cache::handleResponse(PacketPtr pkt) // responseLatency is the latency of the return path // from lower level caches/memory to an upper level cache or // the core. - completion_time = responseLatency * clockPeriod() + - (transfer_offset ? pkt->finishTime : pkt->firstWordTime); + completion_time = curTick() + responseLatency * clockPeriod() + + (transfer_offset ? pkt->busLastWordDelay : + pkt->busFirstWordDelay); assert(!target->pkt->req->isUncacheable()); @@ -914,15 +915,15 @@ Cache::handleResponse(PacketPtr pkt) // responseLatency is the latency of the return path // from lower level caches/memory to an upper level cache or // the core. - completion_time = responseLatency * clockPeriod() + - pkt->finishTime; + completion_time = curTick() + responseLatency * clockPeriod() + + pkt->busLastWordDelay; target->pkt->req->setExtraData(0); } else { // not a cache fill, just forwarding response // responseLatency is the latency of the return path // from lower level cahces/memory to the core. - completion_time = responseLatency * clockPeriod() + - pkt->finishTime; + completion_time = curTick() + responseLatency * clockPeriod() + + pkt->busLastWordDelay; if (pkt->isRead() && !is_error) { target->pkt->setData(pkt->getPtr()); } @@ -984,7 +985,8 @@ Cache::handleResponse(PacketPtr pkt) } MSHRQueue *mq = mshr->queue; mq->markPending(mshr); - requestMemSideBus((RequestCause)mq->index, pkt->finishTime); + requestMemSideBus((RequestCause)mq->index, curTick() + + pkt->busLastWordDelay); } else { mq->deallocate(mshr); if (wasFull && !mq->isFull()) { @@ -1217,7 +1219,7 @@ Cache::handleFill(PacketPtr pkt, BlkType *blk, std::memcpy(blk->data, pkt->getPtr(), blkSize); } - blk->whenReady = pkt->finishTime; + blk->whenReady = curTick() + pkt->busLastWordDelay; return blk; } @@ -1575,7 +1577,7 @@ Cache::getTimingPacket() pkt = new Packet(tgt_pkt); pkt->cmd = MemCmd::UpgradeFailResp; pkt->senderState = mshr; - pkt->firstWordTime = pkt->finishTime = curTick(); + pkt->busFirstWordDelay = pkt->busLastWordDelay = 0; handleResponse(pkt); return NULL; } else if (mshr->isForwardNoResponse()) { -- cgit v1.2.3