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>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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&
|
||||
|
||||
@@ -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()
|
||||
@@ -1041,18 +1039,6 @@ GPUCoalescer::completeIssue()
|
||||
newKernelEnds.clear();
|
||||
}
|
||||
|
||||
void
|
||||
GPUCoalescer::IssueEvent::process()
|
||||
{
|
||||
seq->completeIssue();
|
||||
}
|
||||
|
||||
const char *
|
||||
GPUCoalescer::IssueEvent::description() const
|
||||
{
|
||||
return "Issue coalesced request";
|
||||
}
|
||||
|
||||
void
|
||||
GPUCoalescer::evictionCallback(Addr address)
|
||||
{
|
||||
|
||||
@@ -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__
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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&
|
||||
|
||||
Reference in New Issue
Block a user