Daecheol You has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/54363 )

Change subject: mem-ruby: Fix message stall time calculation
......................................................................

mem-ruby: Fix message stall time calculation

Three changes below:
1. The m_stall_time was declared as statistics::Average, but
statistics::Average uses AvgStor as storage and this works as per-tick
average stat. In the case of m_stall_time, Scalar should be used to get
the calculation right.

2. The function used to get a enqueue time was changed since the getTime()
returns the time when the message was created.

3. Record the stall time only when the message is really dequeued
from the buffer (stall time is not evaluated when the message is moved
to stall map).

Change-Id: I090d19828b5c43f0843a8b735d3f00f312c436e9
---
M src/mem/ruby/network/MessageBuffer.cc
M src/mem/ruby/network/MessageBuffer.hh
2 files changed, 41 insertions(+), 5 deletions(-)



diff --git a/src/mem/ruby/network/MessageBuffer.cc b/src/mem/ruby/network/MessageBuffer.cc
index f4b2bb5..34f1a3c 100644
--- a/src/mem/ruby/network/MessageBuffer.cc
+++ b/src/mem/ruby/network/MessageBuffer.cc
@@ -66,10 +66,12 @@
     m_allow_zero_latency(p.allow_zero_latency),
     ADD_STAT(m_not_avail_count, "Number of times this buffer did not have "
                                 "N slots available"),
+    ADD_STAT(m_msg_count, "Number of messages passed the buffer"),
     ADD_STAT(m_buf_msgs, "Average number of messages in buffer"),
- ADD_STAT(m_stall_time, "Average number of cycles messages are stalled in "
-                           "this MB"),
+ ADD_STAT(m_stall_time, "Total number of cycles messages are stalled in "
+                           "this buffer"),
     ADD_STAT(m_stall_count, "Number of times messages were stalled"),
+    ADD_STAT(m_avg_stall_time, "Average stall ticks per message"),
     ADD_STAT(m_occupancy, "Average occupancy of buffer capacity")
 {
     m_msg_counter = 0;
@@ -93,12 +95,18 @@
     m_not_avail_count
         .flags(statistics::nozero);

+    m_msg_count
+        .flags(statistics::nozero);
+
     m_buf_msgs
         .flags(statistics::nozero);

     m_stall_count
         .flags(statistics::nozero);

+    m_avg_stall_time
+        .flags(statistics::nozero | statistics::nonan);
+
     m_occupancy
         .flags(statistics::nozero);

@@ -110,6 +118,8 @@
     } else {
         m_occupancy = 0;
     }
+
+    m_avg_stall_time = m_stall_time / m_msg_count;
 }

 unsigned int
@@ -288,8 +298,6 @@
     message->updateDelayedTicks(current_time);
     Tick delay = message->getDelayedTicks();

-    m_stall_time = curTick() - message->getTime();
-
     // record previous size and time so the current buffer size isn't
     // adjusted until schd cycle
     if (m_time_last_time_pop < current_time) {
@@ -301,6 +309,10 @@
pop_heap(m_prio_heap.begin(), m_prio_heap.end(), std::greater<MsgPtr>());
     m_prio_heap.pop_back();
     if (decrement_messages) {
+        // Record how much time is passed since the message was enqueued
+        m_stall_time += curTick() - message->getLastEnqueueTime();
+        m_msg_count++;
+
         // If the message will be removed from the queue, decrement the
         // number of message in the queue.
         m_buf_msgs--;
diff --git a/src/mem/ruby/network/MessageBuffer.hh b/src/mem/ruby/network/MessageBuffer.hh
index ff2a4dd..7a48a1d 100644
--- a/src/mem/ruby/network/MessageBuffer.hh
+++ b/src/mem/ruby/network/MessageBuffer.hh
@@ -264,9 +264,11 @@

     // Count the # of times I didn't have N slots available
     statistics::Scalar m_not_avail_count;
+    statistics::Scalar m_msg_count;
     statistics::Average m_buf_msgs;
-    statistics::Average m_stall_time;
+    statistics::Scalar m_stall_time;
     statistics::Scalar m_stall_count;
+    statistics::Formula m_avg_stall_time;
     statistics::Formula m_occupancy;
 };


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/54363
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I090d19828b5c43f0843a8b735d3f00f312c436e9
Gerrit-Change-Number: 54363
Gerrit-PatchSet: 1
Gerrit-Owner: Daecheol You <daecheol....@samsung.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to