mem: Simplify DRAM response scheduling
authorAndreas Hansson <andreas.hansson@arm.com>
Fri, 9 May 2014 22:58:48 +0000 (18:58 -0400)
committerAndreas Hansson <andreas.hansson@arm.com>
Fri, 9 May 2014 22:58:48 +0000 (18:58 -0400)
This patch simplifies the DRAM response scheduling based on the
assumption that they are always returned in order.

src/mem/dram_ctrl.cc
src/mem/dram_ctrl.hh

index b5566c88dafb8daf333724f835778c8a3fbca75d..1e00dd606dffc2ae1259e49323cef81a17ed020c 100644 (file)
@@ -1041,47 +1041,6 @@ DRAMCtrl::doDRAMAccess(DRAMPacket* dram_pkt)
     }
 }
 
-void
-DRAMCtrl::moveToRespQ()
-{
-    // Remove from read queue
-    DRAMPacket* dram_pkt = readQueue.front();
-    readQueue.pop_front();
-
-    // sanity check
-    assert(dram_pkt->size <= burstSize);
-
-    // Insert into response queue sorted by readyTime
-    // It will be sent back to the requestor at its
-    // readyTime
-    if (respQueue.empty()) {
-        respQueue.push_front(dram_pkt);
-        assert(!respondEvent.scheduled());
-        assert(dram_pkt->readyTime >= curTick());
-        schedule(respondEvent, dram_pkt->readyTime);
-    } else {
-        bool done = false;
-        auto i = respQueue.begin();
-        while (!done && i != respQueue.end()) {
-            if ((*i)->readyTime > dram_pkt->readyTime) {
-                respQueue.insert(i, dram_pkt);
-                done = true;
-            }
-            ++i;
-        }
-
-        if (!done)
-            respQueue.push_back(dram_pkt);
-
-        assert(respondEvent.scheduled());
-
-        if (respQueue.front()->readyTime < respondEvent.when()) {
-            assert(respQueue.front()->readyTime >= curTick());
-            reschedule(respondEvent, respQueue.front()->readyTime);
-        }
-    }
-}
-
 void
 DRAMCtrl::processNextReqEvent()
 {
@@ -1152,13 +1111,28 @@ DRAMCtrl::processNextReqEvent()
             // front of the read queue
             chooseNext(readQueue);
 
-            doDRAMAccess(readQueue.front());
+            DRAMPacket* dram_pkt = readQueue.front();
+
+            doDRAMAccess(dram_pkt);
 
             // At this point we're done dealing with the request
-            // It will be moved to a separate response queue with a
-            // correct readyTime, and eventually be sent back at that
-            // time
-            moveToRespQ();
+            readQueue.pop_front();
+
+            // sanity check
+            assert(dram_pkt->size <= burstSize);
+            assert(dram_pkt->readyTime >= curTick());
+
+            // Insert into response queue. It will be sent back to the
+            // requestor at its readyTime
+            if (respQueue.empty()) {
+                assert(!respondEvent.scheduled());
+                schedule(respondEvent, dram_pkt->readyTime);
+            } else {
+                assert(respQueue.back()->readyTime <= dram_pkt->readyTime);
+                assert(respondEvent.scheduled());
+            }
+
+            respQueue.push_back(dram_pkt);
 
             // we have so many writes that we have to transition
             if (writeQueue.size() > writeHighThreshold) {
index c673e059507d53621fc0e6984df8c0d706f29bf8..24f9729c5f62a32f14ba906d0c2d2a7113db38cf 100644 (file)
@@ -366,14 +366,6 @@ class DRAMCtrl : public AbstractMemory
      */
     void chooseNext(std::deque<DRAMPacket*>& queue);
 
-    /**
-     * Move the request at the head of the read queue to the response
-     * queue, sorting by readyTime.\ If it is the only packet in the
-     * response queue, schedule a respond event to send it back to the
-     * outside world
-     */
-    void moveToRespQ();
-
     /**
      * For FR-FCFS policy reorder the read/write queue depending on row buffer
      * hits and earliest banks available in DRAM