mem-ruby: change MessageBuffer randomization param
authorTiago Mück <tiago.muck@arm.com>
Sat, 20 Jun 2020 02:16:45 +0000 (21:16 -0500)
committerTiago Mück <tiago.muck@arm.com>
Mon, 12 Oct 2020 14:09:55 +0000 (14:09 +0000)
There are cases in which we need to prevent randomization for a
specific buffer when enabled at the RubySystem level (e.g. a internal
trigger queue that requires zero latency enqueue, while other buffers
can be randomized).

This changes the randomization parameter to support enabling and
disabling randomization regardless of the RubySystem setting.

Change-Id: If7520153cc5864897fa42e8911a6f8acbcf01db5
Signed-off-by: Tiago Mück <tiago.muck@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/31419
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/mem/ruby/network/MessageBuffer.cc
src/mem/ruby/network/MessageBuffer.hh
src/mem/ruby/network/MessageBuffer.py

index 8843694bd728ca14943b12fa51b8765d1d605952..00e8fea22448a89a6765bb979680c0162c3c1097 100644 (file)
@@ -176,9 +176,11 @@ MessageBuffer::enqueue(MsgPtr message, Tick current_time, Tick delta)
     assert((delta > 0) || m_allow_zero_latency);
     Tick arrival_time = 0;
 
-    // random delays are inserted if either RubySystem level randomization flag
-    // is turned on, or the buffer level randomization is set
-    if (!RubySystem::getRandomization() && !m_randomization) {
+    // random delays are inserted if the RubySystem level randomization flag
+    // is turned on and this buffer allows it
+    if ((m_randomization == MessageRandomization::disabled) ||
+        ((m_randomization == MessageRandomization::ruby_system) &&
+          !RubySystem::getRandomization())) {
         // No randomization
         arrival_time = current_time + delta;
     } else {
index 3887340e561d491b1daf018136fea92cd7cf3e27..fc69d34fdc2d35046adceb6e52b1688fd006e29b 100644 (file)
@@ -248,7 +248,7 @@ class MessageBuffer : public SimObject
     uint64_t m_msg_counter;
     int m_priority_rank;
     const bool m_strict_fifo;
-    const bool m_randomization;
+    const MessageRandomization m_randomization;
     const bool m_allow_zero_latency;
 
     int m_input_link_id;
index 297835f1e523e5304fd2f7c0a6d714c4ba4cd885..807ffb4bdabcbb89631b0950985e2572666478a4 100644 (file)
@@ -40,6 +40,13 @@ from m5.params import *
 from m5.proxy import *
 from m5.SimObject import SimObject
 
+# A MessageBuffer inserts random delays to enqueued messages when the
+# randomization param is set to 'enabled' or when globally enabled for the
+# RubySystem and the param is set to 'ruby_system' (default). 'disabled'
+# completely prevents randomization.
+class MessageRandomization(ScopedEnum):
+    vals = ['disabled', 'enabled', 'ruby_system']
+
 class MessageBuffer(SimObject):
     type = 'MessageBuffer'
     cxx_class = 'MessageBuffer'
@@ -47,10 +54,8 @@ class MessageBuffer(SimObject):
     ordered = Param.Bool(False, "Whether the buffer is ordered")
     buffer_size = Param.Unsigned(0, "Maximum number of entries to buffer \
                                      (0 allows infinite entries)")
-    randomization = Param.Bool(False, "Insert random delays on message \
-                                       enqueue times (enforced to have \
-                                       random delays if RubySystem \
-                                       randomization flag is True)")
+    randomization = Param.MessageRandomization('ruby_system',
+                                       "Randomization parameter")
     allow_zero_latency = Param.Bool(False, "Allows messages to be enqueued \
                                             with zero latency. This is useful \
                                             for internall trigger queues and \