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
+ *