summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoel Hestness ext:(%2C%20Nilay%20Vaish%20%3Cnilay%40cs.wisc.edu%3E) <jthestness@gmail.com>2013-06-24 06:57:06 -0500
committerJoel Hestness ext:(%2C%20Nilay%20Vaish%20%3Cnilay%40cs.wisc.edu%3E) <jthestness@gmail.com>2013-06-24 06:57:06 -0500
commit71c6c4311060fb2bc8711188a37f5b6b1a035654 (patch)
tree66f35e1d3db8403a86ff93c1007e62eec2569adc /src
parent94280c7e512d5f4c7dbaefc8e387b9255c9ba9f7 (diff)
downloadgem5-71c6c4311060fb2bc8711188a37f5b6b1a035654.tar.xz
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 <nilay@cs.wisc.edu>
Diffstat (limited to 'src')
-rw-r--r--src/mem/ruby/buffers/MessageBuffer.cc39
-rw-r--r--src/mem/ruby/buffers/MessageBuffer.hh10
2 files changed, 22 insertions, 27 deletions
diff --git a/src/mem/ruby/buffers/MessageBuffer.cc b/src/mem/ruby/buffers/MessageBuffer.cc
index bbfac8ff7..56d807a16 100644
--- a/src/mem/ruby/buffers/MessageBuffer.cc
+++ b/src/mem/ruby/buffers/MessageBuffer.cc
@@ -49,7 +49,6 @@ MessageBuffer::MessageBuffer(const string &name)
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 @@ MessageBuffer::MessageBuffer(const string &name)
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 @@ MessageBuffer::areNSlotsAvailable(int n)
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 @@ MessageBuffer::areNSlotsAvailable(int n)
} 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 @@ MessageBuffer::areNSlotsAvailable(int n)
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 @@ void
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 @@ MessageBuffer::pop()
{
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 @@ MessageBuffer::clear()
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 @@ MessageBuffer::reanalyzeMessages(const Address& addr)
void
MessageBuffer::reanalyzeAllMessages()
{
- DPRINTF(RubyQueue, "ReanalyzeAllMessages %s\n");
+ DPRINTF(RubyQueue, "ReanalyzeAllMessages\n");
Tick nextTick = m_receiver->clockEdge(Cycles(1));
//
diff --git a/src/mem/ruby/buffers/MessageBuffer.hh b/src/mem/ruby/buffers/MessageBuffer.hh
index d45ec6bd9..1133144a2 100644
--- a/src/mem/ruby/buffers/MessageBuffer.hh
+++ b/src/mem/ruby/buffers/MessageBuffer.hh
@@ -193,18 +193,16 @@ class MessageBuffer
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