summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Wilson <spwilson2@wisc.edu>2017-06-28 13:34:02 -0500
committerSean Wilson <spwilson2@wisc.edu>2017-07-12 20:07:05 +0000
commitfc575f8266149c78b29bcbe12ab86ccb7614ffbf (patch)
tree8f6ad3a6af8a5b4c529638b94ceb7a897d6192fb
parent381aa8498997f5ce93480511f7514be85356687a (diff)
downloadgem5-fc575f8266149c78b29bcbe12ab86ccb7614ffbf.tar.xz
ruby: Refactor some Event subclasses to lambdas
Change-Id: I9f47a20a869553515a759d9a29c05f6ce4b42d64 Signed-off-by: Sean Wilson <spwilson2@wisc.edu> Reviewed-on: https://gem5-review.googlesource.com/3930 Maintainer: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
-rw-r--r--src/mem/ruby/common/Consumer.cc4
-rw-r--r--src/mem/ruby/common/Consumer.hh14
-rw-r--r--src/mem/ruby/system/GPUCoalescer.cc22
-rw-r--r--src/mem/ruby/system/GPUCoalescer.hh30
-rw-r--r--src/mem/ruby/system/RubySystem.cc10
-rw-r--r--src/mem/ruby/system/RubySystem.hh19
-rw-r--r--src/mem/ruby/system/Sequencer.cc3
-rw-r--r--src/mem/ruby/system/Sequencer.hh14
8 files changed, 20 insertions, 96 deletions
diff --git a/src/mem/ruby/common/Consumer.cc b/src/mem/ruby/common/Consumer.cc
index 59605d51b..f68ee14d0 100644
--- a/src/mem/ruby/common/Consumer.cc
+++ b/src/mem/ruby/common/Consumer.cc
@@ -41,7 +41,9 @@ Consumer::scheduleEventAbsolute(Tick evt_time)
{
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 20f2bdd0f..b0d35bf70 100644
--- a/src/mem/ruby/common/Consumer.hh
+++ b/src/mem/ruby/common/Consumer.hh
@@ -76,20 +76,6 @@ class Consumer
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 991b21717..a615c40fd 100644
--- a/src/mem/ruby/system/GPUCoalescer.cc
+++ b/src/mem/ruby/system/GPUCoalescer.cc
@@ -116,7 +116,10 @@ reqSegmentToHSASegment(Request* req)
}
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 @@ GPUCoalescer::recordRequestType(SequencerRequestType requestType) {
SequencerRequestType_to_string(requestType));
}
-GPUCoalescer::IssueEvent::IssueEvent(GPUCoalescer* _seq)
- : Event(Progress_Event_Pri), seq(_seq)
-{
-}
-
void
GPUCoalescer::completeIssue()
@@ -1042,18 +1040,6 @@ GPUCoalescer::completeIssue()
}
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 2b42e1933..894683811 100644
--- a/src/mem/ruby/system/GPUCoalescer.hh
+++ b/src/mem/ruby/system/GPUCoalescer.hh
@@ -255,17 +255,7 @@ class GPUCoalescer : public RubyPort
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 @@ class GPUCoalescer : public RubyPort
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 @@ operator<<(std::ostream& out, const GPUCoalescer& obj)
}
#endif // __MEM_RUBY_SYSTEM_GPU_COALESCER_HH__
-
diff --git a/src/mem/ruby/system/RubySystem.cc b/src/mem/ruby/system/RubySystem.cc
index e1717e519..3d0470ca3 100644
--- a/src/mem/ruby/system/RubySystem.cc
+++ b/src/mem/ruby/system/RubySystem.cc
@@ -380,12 +380,12 @@ RubySystem::startup()
}
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 8ebd3494a..407a253f3 100644
--- a/src/mem/ruby/system/RubySystem.hh
+++ b/src/mem/ruby/system/RubySystem.hh
@@ -50,21 +50,6 @@ class AbstractController;
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 @@ class RubySystem : public ClockedObject
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 @@ class RubySystem : public ClockedObject
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 97afa5ec6..541b52138 100644
--- a/src/mem/ruby/system/Sequencer.cc
+++ b/src/mem/ruby/system/Sequencer.cc
@@ -53,7 +53,8 @@ RubySequencerParams::create()
}
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 8c009b567..fcfa8ad86 100644
--- a/src/mem/ruby/system/Sequencer.hh
+++ b/src/mem/ruby/system/Sequencer.hh
@@ -237,19 +237,7 @@ class Sequencer : public RubyPort
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&