changeset a0ee1b3aec39 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=a0ee1b3aec39
description:
        ruby: MessageBuffer: Remove unused m_size variable

        The m_size variable attempted to track m_prio_heap.size(), but it did so
        incorrectly due to the functions reanalyzeMessages and 
reanalyzeAllMessages().
        Since this variable is intended to track m_prio_heap.size(), we can 
simply
        replace instances where m_size is referenced with m_prio_heap.size(), 
which
        has the added bonus of removing the need for m_size.

        Note: This patch also removes an extraneous DPRINTF format string 
designator
        from reanalyzeAllMessages()

        Committed by: Nilay Vaish <[email protected]>

diffstat:

 src/mem/ruby/buffers/MessageBuffer.cc |  39 ++++++++++++++++------------------
 src/mem/ruby/buffers/MessageBuffer.hh |  10 +++-----
 2 files changed, 22 insertions(+), 27 deletions(-)

diffs (144 lines):

diff -r bf245b82de17 -r a0ee1b3aec39 src/mem/ruby/buffers/MessageBuffer.cc
--- a/src/mem/ruby/buffers/MessageBuffer.cc     Thu Jun 20 16:20:38 2013 -0500
+++ b/src/mem/ruby/buffers/MessageBuffer.cc     Mon Jun 24 06:57:06 2013 -0500
@@ -49,7 +49,6 @@
 
     m_ordering_set = false;
     m_strict_fifo = true;
-    m_size = 0;
     m_max_size = -1;
     m_randomization = true;
     m_size_last_time_size_checked = 0;
@@ -67,13 +66,12 @@
 int
 MessageBuffer::getSize()
 {
-    if (m_time_last_time_size_checked == m_receiver->curCycle()) {
-        return m_size_last_time_size_checked;
-    } else {
+    if (m_time_last_time_size_checked != m_receiver->curCycle()) {
         m_time_last_time_size_checked = m_receiver->curCycle();
-        m_size_last_time_size_checked = m_size;
-        return m_size;
+        m_size_last_time_size_checked = m_prio_heap.size();
     }
+
+    return m_size_last_time_size_checked;
 }
 
 bool
@@ -85,14 +83,15 @@
         return true;
     }
 
-    // determine my correct size for the current cycle
+    // determine the correct size for the current cycle
     // pop operations shouldn't effect the network's visible size
     // until next cycle, but enqueue operations effect the visible
     // size immediately
-    int current_size = max(m_size_at_cycle_start, m_size);
+    unsigned int current_size = 0;
+
     if (m_time_last_time_pop < m_receiver->curCycle()) {
-        // no pops this cycle - m_size is correct
-        current_size = m_size;
+        // no pops this cycle - heap size is correct
+        current_size = m_prio_heap.size();
     } else {
         if (m_time_last_time_enqueue < m_receiver->curCycle()) {
             // no enqueues this cycle - m_size_at_cycle_start is correct
@@ -100,7 +99,7 @@
         } else {
             // both pops and enqueues occured this cycle - add new
             // enqueued msgs to m_size_at_cycle_start
-            current_size = m_size_at_cycle_start+m_msgs_this_cycle;
+            current_size = m_size_at_cycle_start + m_msgs_this_cycle;
         }
     }
 
@@ -108,9 +107,9 @@
     if (current_size + n <= m_max_size) {
         return true;
     } else {
-        DPRINTF(RubyQueue, "n: %d, current_size: %d, m_size: %d, "
+        DPRINTF(RubyQueue, "n: %d, current_size: %d, heap size: %d, "
                 "m_max_size: %d\n",
-                n, current_size, m_size, m_max_size);
+                n, current_size, m_prio_heap.size(), m_max_size);
         m_not_avail_count++;
         return false;
     }
@@ -153,7 +152,6 @@
 MessageBuffer::enqueue(MsgPtr message, Cycles delta)
 {
     m_msg_counter++;
-    m_size++;
 
     // record current time incase we have a pop that also adjusts my size
     if (m_time_last_time_enqueue < m_sender->curCycle()) {
@@ -271,17 +269,17 @@
 {
     DPRINTF(RubyQueue, "Popping\n");
     assert(isReady());
-    pop_heap(m_prio_heap.begin(), m_prio_heap.end(),
-        greater<MessageBufferNode>());
-    m_prio_heap.pop_back();
 
     // record previous size and time so the current buffer size isn't
     // adjusted until next cycle
     if (m_time_last_time_pop < m_receiver->curCycle()) {
-        m_size_at_cycle_start = m_size;
+        m_size_at_cycle_start = m_prio_heap.size();
         m_time_last_time_pop = m_receiver->curCycle();
     }
-    m_size--;
+
+    pop_heap(m_prio_heap.begin(), m_prio_heap.end(),
+        greater<MessageBufferNode>());
+    m_prio_heap.pop_back();
 }
 
 void
@@ -290,7 +288,6 @@
     m_prio_heap.clear();
 
     m_msg_counter = 0;
-    m_size = 0;
     m_time_last_time_enqueue = Cycles(0);
     m_time_last_time_pop = Cycles(0);
     m_size_at_cycle_start = 0;
@@ -343,7 +340,7 @@
 void
 MessageBuffer::reanalyzeAllMessages()
 {
-    DPRINTF(RubyQueue, "ReanalyzeAllMessages %s\n");
+    DPRINTF(RubyQueue, "ReanalyzeAllMessages\n");
     Tick nextTick = m_receiver->clockEdge(Cycles(1));
 
     //
diff -r bf245b82de17 -r a0ee1b3aec39 src/mem/ruby/buffers/MessageBuffer.hh
--- a/src/mem/ruby/buffers/MessageBuffer.hh     Thu Jun 20 16:20:38 2013 -0500
+++ b/src/mem/ruby/buffers/MessageBuffer.hh     Mon Jun 24 06:57:06 2013 -0500
@@ -193,18 +193,16 @@
     StallMsgMapType m_stall_msg_map;
     std::string m_name;
 
-    int m_max_size;
-    int m_size;
-
+    unsigned int m_max_size;
     Cycles m_time_last_time_size_checked;
-    int m_size_last_time_size_checked;
+    unsigned int m_size_last_time_size_checked;
 
     // variables used so enqueues appear to happen imediately, while
     // pop happen the next cycle
     Cycles m_time_last_time_enqueue;
     Cycles m_time_last_time_pop;
-    int m_size_at_cycle_start;
-    int m_msgs_this_cycle;
+    unsigned int m_size_at_cycle_start;
+    unsigned int m_msgs_this_cycle;
 
     int m_not_avail_count;  // count the # of times I didn't have N
                             // slots available
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to