[gem5-dev] Change in gem5/gem5[develop]: mem-ruby: Allow same-cycle enqueue

2020-10-08 Thread Gerrit
Tiago Mück has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/31255 )


Change subject: mem-ruby: Allow same-cycle enqueue
..

mem-ruby: Allow same-cycle enqueue

Messages may be enqueued and be ready in the same cycle.

Using this feature may introduce nondeterminism in the protocol and
should be used in specific cases. A case study is to avoid needing an
additional cycle for internal protocol triggers (e.g. the All_Acks
event in src/mem/ruby/protocol/MOESI_CMP_directory-L2cache.sm).
To mitigate modeling mistakes, the 'allow_zero_latency' parameter must
be set for a MessageBuffer where this behavior is acceptable.

This changes also updates the Consumer to schedule events according to
this new behavior. The original implementation would not schedule a new
wakeup event if the wakeup for the Consumer had already been executed
in that cycle.

Additional authors:
- Tuan Ta 

Change-Id: Ib194e7b4b4ee4b06da1baea17c0eb743f650dfdd
Signed-off-by: Tiago Mück 
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/31255
Reviewed-by: Jason Lowe-Power 
Maintainer: Jason Lowe-Power 
Tested-by: kokoro 
---
M src/mem/ruby/common/Consumer.cc
M src/mem/ruby/common/Consumer.hh
M src/mem/ruby/network/MessageBuffer.cc
M src/mem/ruby/network/MessageBuffer.hh
M src/mem/ruby/network/MessageBuffer.py
5 files changed, 92 insertions(+), 29 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/mem/ruby/common/Consumer.cc  
b/src/mem/ruby/common/Consumer.cc

index f68ee14..d5db717 100644
--- a/src/mem/ruby/common/Consumer.cc
+++ b/src/mem/ruby/common/Consumer.cc
@@ -1,4 +1,16 @@
 /*
+ * Copyright (c) 2020 ARM Limited
+ * All rights reserved.
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder.  You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
  * Copyright (c) 2012 Mark D. Hill and David A. Wood
  * All rights reserved.
  *
@@ -30,26 +42,51 @@

 using namespace std;

+Consumer::Consumer(ClockedObject *_em)
+: m_wakeup_event([this]{ processCurrentEvent(); },
+"Consumer Event", false),
+  em(_em)
+{ }
+
 void
 Consumer::scheduleEvent(Cycles timeDelta)
 {
-scheduleEventAbsolute(em->clockEdge(timeDelta));
+m_wakeup_ticks.insert(em->clockEdge(timeDelta));
+scheduleNextWakeup();
 }

 void
 Consumer::scheduleEventAbsolute(Tick evt_time)
 {
-if (!alreadyScheduled(evt_time)) {
-// This wakeup is not redundant
-auto *evt = new EventFunctionWrapper(
-[this]{ wakeup(); }, "Consumer Event", true);
+m_wakeup_ticks.insert(
+divCeil(evt_time, em->clockPeriod()) * em->clockPeriod());
+scheduleNextWakeup();
+}

-em->schedule(evt, evt_time);
-insertScheduledWakeupTime(evt_time);
+void
+Consumer::scheduleNextWakeup()
+{
+// look for the next tick in the future to schedule
+auto it = m_wakeup_ticks.lower_bound(em->clockEdge());
+if (it != m_wakeup_ticks.end()) {
+Tick when = *it;
+assert(when >= em->clockEdge());
+if (m_wakeup_event.scheduled() && (when < m_wakeup_event.when()))
+em->reschedule(m_wakeup_event, when, true);
+else if (!m_wakeup_event.scheduled())
+em->schedule(m_wakeup_event, when);
 }
+}

-Tick t = em->clockEdge();
-set::iterator bit = m_scheduled_wakeups.begin();
-set::iterator eit = m_scheduled_wakeups.lower_bound(t);
-m_scheduled_wakeups.erase(bit,eit);
+void
+Consumer::processCurrentEvent()
+{
+auto curr = m_wakeup_ticks.begin();
+assert(em->clockEdge() == *curr);
+
+// remove the current tick from the wakeup list, wake up, and then  
schedule

+// the next wakeup
+m_wakeup_ticks.erase(curr);
+wakeup();
+scheduleNextWakeup();
 }
diff --git a/src/mem/ruby/common/Consumer.hh  
b/src/mem/ruby/common/Consumer.hh

index 2e18684..2c7065b 100644
--- a/src/mem/ruby/common/Consumer.hh
+++ b/src/mem/ruby/common/Consumer.hh
@@ -1,4 +1,16 @@
 /*
+ * Copyright (c) 2020 ARM Limited
+ * All rights reserved.
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder.  You may use the software subject to the license
+ * 

[gem5-dev] Change in gem5/gem5[develop]: mem-ruby: Allow same-cycle enqueue

2020-07-13 Thread Gerrit
Tiago Mück has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/31255 )



Change subject: mem-ruby: Allow same-cycle enqueue
..

mem-ruby: Allow same-cycle enqueue

Messages may be enqueued and be ready in the same cycle.

Change-Id: Ib194e7b4b4ee4b06da1baea17c0eb743f650dfdd
Signed-off-by: Tiago Mück 
---
M src/mem/ruby/network/MessageBuffer.cc
1 file changed, 1 insertion(+), 2 deletions(-)



diff --git a/src/mem/ruby/network/MessageBuffer.cc  
b/src/mem/ruby/network/MessageBuffer.cc

index fb1d734..f2c952e 100644
--- a/src/mem/ruby/network/MessageBuffer.cc
+++ b/src/mem/ruby/network/MessageBuffer.cc
@@ -172,7 +172,6 @@

 // Calculate the arrival time of the message, that is, the first
 // cycle the message can be dequeued.
-assert(delta > 0);
 Tick arrival_time = 0;

 // random delays are inserted if either RubySystem level randomization  
flag

@@ -193,7 +192,7 @@
 }

 // Check the arrival time
-assert(arrival_time > current_time);
+assert(arrival_time >= current_time);
 if (m_strict_fifo) {
 if (arrival_time < m_last_arrival_time) {
 panic("FIFO ordering violated: %s name: %s current time: %d "

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/31255
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: Ib194e7b4b4ee4b06da1baea17c0eb743f650dfdd
Gerrit-Change-Number: 31255
Gerrit-PatchSet: 1
Gerrit-Owner: Tiago Mück 
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