Sean Wilson has uploaded this change for review. ( https://gem5-review.googlesource.com/3930

Change subject: ruby: Refactor some Event subclasses to lambdas
......................................................................

ruby: Refactor some Event subclasses to lambdas

Change-Id: I9f47a20a869553515a759d9a29c05f6ce4b42d64
Signed-off-by: Sean Wilson <[email protected]>
---
M src/mem/ruby/common/Consumer.cc
M src/mem/ruby/common/Consumer.hh
M src/mem/ruby/system/GPUCoalescer.cc
M src/mem/ruby/system/GPUCoalescer.hh
M src/mem/ruby/system/RubySystem.cc
M src/mem/ruby/system/RubySystem.hh
M src/mem/ruby/system/Sequencer.cc
M src/mem/ruby/system/Sequencer.hh
8 files changed, 20 insertions(+), 96 deletions(-)



diff --git a/src/mem/ruby/common/Consumer.cc b/src/mem/ruby/common/Consumer.cc
index 59605d5..f68ee14 100644
--- a/src/mem/ruby/common/Consumer.cc
+++ b/src/mem/ruby/common/Consumer.cc
@@ -41,7 +41,9 @@
 {
     if (!alreadyScheduled(evt_time)) {
         // This wakeup is not redundant
-        ConsumerEvent *evt = new ConsumerEvent(this);
+        auto *evt = new EventFunctionWrapper(
+            [this]{ wakeup(); }, "Consumer Event", true);
+
         em->schedule(evt, evt_time);
         insertScheduledWakeupTime(evt_time);
     }
diff --git a/src/mem/ruby/common/Consumer.hh b/src/mem/ruby/common/Consumer.hh
index 20f2bdd..b0d35bf 100644
--- a/src/mem/ruby/common/Consumer.hh
+++ b/src/mem/ruby/common/Consumer.hh
@@ -76,20 +76,6 @@
   private:
     std::set<Tick> m_scheduled_wakeups;
     ClockedObject *em;
-
-    class ConsumerEvent : public Event
-    {
-      public:
-          ConsumerEvent(Consumer* _consumer)
-              : Event(Default_Pri, AutoDelete), m_consumer_ptr(_consumer)
-          {
-          }
-
-          void process() { m_consumer_ptr->wakeup(); }
-
-      private:
-          Consumer* m_consumer_ptr;
-    };
 };

 inline std::ostream&
diff --git a/src/mem/ruby/system/GPUCoalescer.cc b/src/mem/ruby/system/GPUCoalescer.cc
index 991b217..a615c40 100644
--- a/src/mem/ruby/system/GPUCoalescer.cc
+++ b/src/mem/ruby/system/GPUCoalescer.cc
@@ -116,7 +116,10 @@
 }

 GPUCoalescer::GPUCoalescer(const Params *p)
-    : RubyPort(p), issueEvent(this), deadlockCheckEvent(this)
+    : RubyPort(p),
+      issueEvent([this]{ completeIssue(); }, "Issue coalesced request",
+                 false, Event::Progress_Event_Pri),
+ deadlockCheckEvent([this]{ wakeup(); }, "GPUCoalescer deadlock check")
 {
     m_store_waiting_on_load_cycles = 0;
     m_store_waiting_on_store_cycles = 0;
@@ -996,11 +999,6 @@
             SequencerRequestType_to_string(requestType));
 }

-GPUCoalescer::IssueEvent::IssueEvent(GPUCoalescer* _seq)
-    : Event(Progress_Event_Pri), seq(_seq)
-{
-}
-

 void
 GPUCoalescer::completeIssue()
@@ -1042,18 +1040,6 @@
 }

 void
-GPUCoalescer::IssueEvent::process()
-{
-    seq->completeIssue();
-}
-
-const char *
-GPUCoalescer::IssueEvent::description() const
-{
-    return "Issue coalesced request";
-}
-
-void
 GPUCoalescer::evictionCallback(Addr address)
 {
     ruby_eviction_callback(address);
diff --git a/src/mem/ruby/system/GPUCoalescer.hh b/src/mem/ruby/system/GPUCoalescer.hh
index 2b42e19..8946838 100644
--- a/src/mem/ruby/system/GPUCoalescer.hh
+++ b/src/mem/ruby/system/GPUCoalescer.hh
@@ -255,17 +255,7 @@

     bool handleLlsc(Addr address, GPUCoalescerRequest* request);

-    class IssueEvent : public Event
-    {
-      private:
-        GPUCoalescer *seq;
-      public:
-        IssueEvent(GPUCoalescer *_seq);
-        void process();
-        const char *description() const;
-    };
-
-    IssueEvent issueEvent;
+    EventFunctionWrapper issueEvent;


   // Changed to protected to enable inheritance by VIPER Coalescer
@@ -305,22 +295,7 @@

     bool m_runningGarnetStandalone;

-    class GPUCoalescerWakeupEvent : public Event
-    {
-      private:
-        GPUCoalescer *m_GPUCoalescer_ptr;
-
-      public:
-        GPUCoalescerWakeupEvent(GPUCoalescer *_seq) :
-            m_GPUCoalescer_ptr(_seq) {}
-        void process() { m_GPUCoalescer_ptr->wakeup(); }
-        const char *description() const
-        {
-            return "GPUCoalescer deadlock check";
-        }
-    };
-
-    GPUCoalescerWakeupEvent deadlockCheckEvent;
+    EventFunctionWrapper deadlockCheckEvent;
     bool assumingRfOCoherence;

     // m5 style stats for TCP hit/miss counts
@@ -382,4 +357,3 @@
 }

 #endif // __MEM_RUBY_SYSTEM_GPU_COALESCER_HH__
-
diff --git a/src/mem/ruby/system/RubySystem.cc b/src/mem/ruby/system/RubySystem.cc
index e1717e5..3d0470c 100644
--- a/src/mem/ruby/system/RubySystem.cc
+++ b/src/mem/ruby/system/RubySystem.cc
@@ -380,12 +380,12 @@
 }

 void
-RubySystem::RubyEvent::process()
+RubySystem::processRubyEvent()
 {
-    if (RubySystem::getWarmupEnabled()) {
-        m_ruby_system->m_cache_recorder->enqueueNextFetchRequest();
-    } else if (RubySystem::getCooldownEnabled()) {
-        m_ruby_system->m_cache_recorder->enqueueNextFlushRequest();
+    if (getWarmupEnabled()) {
+        m_cache_recorder->enqueueNextFetchRequest();
+    } else if (getCooldownEnabled()) {
+        m_cache_recorder->enqueueNextFlushRequest();
     }
 }

diff --git a/src/mem/ruby/system/RubySystem.hh b/src/mem/ruby/system/RubySystem.hh
index 8ebd349..407a253 100644
--- a/src/mem/ruby/system/RubySystem.hh
+++ b/src/mem/ruby/system/RubySystem.hh
@@ -50,21 +50,6 @@
 class RubySystem : public ClockedObject
 {
   public:
-    class RubyEvent : public Event
-    {
-      public:
-        RubyEvent(RubySystem* _ruby_system)
-        {
-            m_ruby_system = _ruby_system;
-        }
-      private:
-        void process();
-
-        RubySystem* m_ruby_system;
-    };
-
-    friend class RubyEvent;
-
     typedef RubySystemParams Params;
     RubySystem(const Params *p);
     ~RubySystem();
@@ -111,7 +96,8 @@
     bool eventQueueEmpty() { return eventq->empty(); }
     void enqueueRubyEvent(Tick tick)
     {
-        RubyEvent* e = new RubyEvent(this);
+        auto e = new EventFunctionWrapper(
+            [this]{ processRubyEvent(); }, "RubyEvent");
         schedule(e, tick);
     }

@@ -130,6 +116,7 @@
     static void writeCompressedTrace(uint8_t *raw_data, std::string file,
                                      uint64_t uncompressed_trace_size);

+    void processRubyEvent();
   private:
     // configuration parameters
     static bool m_randomization;
diff --git a/src/mem/ruby/system/Sequencer.cc b/src/mem/ruby/system/Sequencer.cc
index 97afa5e..541b521 100644
--- a/src/mem/ruby/system/Sequencer.cc
+++ b/src/mem/ruby/system/Sequencer.cc
@@ -53,7 +53,8 @@
 }

 Sequencer::Sequencer(const Params *p)
- : RubyPort(p), m_IncompleteTimes(MachineType_NUM), deadlockCheckEvent(this)
+    : RubyPort(p), m_IncompleteTimes(MachineType_NUM),
+      deadlockCheckEvent([this]{ wakeup(); }, "Sequencer deadlock check")
 {
     m_outstanding_count = 0;

diff --git a/src/mem/ruby/system/Sequencer.hh b/src/mem/ruby/system/Sequencer.hh
index 8c009b5..fcfa8ad 100644
--- a/src/mem/ruby/system/Sequencer.hh
+++ b/src/mem/ruby/system/Sequencer.hh
@@ -237,19 +237,7 @@
     std::vector<Stats::Histogram *> m_FirstResponseToCompletionDelayHist;
     std::vector<Stats::Counter> m_IncompleteTimes;

-
-    class SequencerWakeupEvent : public Event
-    {
-      private:
-        Sequencer *m_sequencer_ptr;
-
-      public:
-        SequencerWakeupEvent(Sequencer *_seq) : m_sequencer_ptr(_seq) {}
-        void process() { m_sequencer_ptr->wakeup(); }
- const char *description() const { return "Sequencer deadlock check"; }
-    };
-
-    SequencerWakeupEvent deadlockCheckEvent;
+    EventFunctionWrapper deadlockCheckEvent;
 };

 inline std::ostream&

--
To view, visit https://gem5-review.googlesource.com/3930
To unsubscribe, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9f47a20a869553515a759d9a29c05f6ce4b42d64
Gerrit-Change-Number: 3930
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Wilson <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to