ruby: Wrapped ruby events into m5 events

Wrapped ruby events using the m5 event object.  Removed the prio_heap
from ruby's event queue and instead schedule ruby events on the m5 event
queue.
This commit is contained in:
Brad Beckmann 2010-01-29 20:29:19 -08:00
parent 63a60cc81e
commit e15abd17f9
5 changed files with 28 additions and 97 deletions

View file

@ -33,83 +33,35 @@
#include "mem/ruby/eventqueue/RubyEventQueue.hh"
#include "mem/ruby/common/Consumer.hh"
#include "mem/ruby/profiler/Profiler.hh"
#include "mem/ruby/system/System.hh"
#include "mem/gems_common/PrioHeap.hh"
#include "mem/ruby/eventqueue/RubyEventQueueNode.hh"
// Class public method definitions
RubyEventQueue::RubyEventQueue(Tick _clock)
: m_clock(_clock)
RubyEventQueue::RubyEventQueue(EventQueue* eventq, Tick _clock)
: EventManager(eventq), m_clock(_clock)
{
m_prio_heap_ptr = NULL;
init();
assert(g_eventQueue_ptr == NULL);
g_eventQueue_ptr = this;
}
RubyEventQueue::~RubyEventQueue()
{
delete m_prio_heap_ptr;
}
void RubyEventQueue::init()
void RubyEventQueue::scheduleEvent(Consumer* consumer, Time timeDelta)
{
m_globalTime = 1;
m_timeOfLastRecovery = 1;
m_prio_heap_ptr = new PrioHeap<RubyEventQueueNode>;
m_prio_heap_ptr->init();
}
bool RubyEventQueue::isEmpty() const
{
return (m_prio_heap_ptr->size() == 0);
scheduleEventAbsolute(consumer, timeDelta + getTime());
}
void RubyEventQueue::scheduleEventAbsolute(Consumer* consumer, Time timeAbs)
{
// Check to see if this is a redundant wakeup
// Time time = timeDelta + m_globalTime;
ASSERT(consumer != NULL);
if (consumer->getLastScheduledWakeup() != timeAbs) {
// This wakeup is not redundant
RubyEventQueueNode thisNode;
thisNode.m_consumer_ptr = consumer;
assert(timeAbs > m_globalTime);
thisNode.m_time = timeAbs;
m_prio_heap_ptr->insert(thisNode);
consumer->setLastScheduledWakeup(timeAbs);
}
}
void RubyEventQueue::triggerEvents(Time t)
{
RubyEventQueueNode thisNode;
while(m_prio_heap_ptr->size() > 0 && m_prio_heap_ptr->peekMin().m_time <= t) {
m_globalTime = m_prio_heap_ptr->peekMin().m_time;
thisNode = m_prio_heap_ptr->extractMin();
assert(thisNode.m_consumer_ptr != NULL);
DEBUG_EXPR(EVENTQUEUE_COMP,MedPrio,*(thisNode.m_consumer_ptr));
DEBUG_EXPR(EVENTQUEUE_COMP,MedPrio,thisNode.m_time);
thisNode.m_consumer_ptr->triggerWakeup(this);
}
m_globalTime = t;
}
void RubyEventQueue::triggerAllEvents()
{
// FIXME - avoid repeated code
RubyEventQueueNode thisNode;
while(m_prio_heap_ptr->size() > 0) {
m_globalTime = m_prio_heap_ptr->peekMin().m_time;
thisNode = m_prio_heap_ptr->extractMin();
assert(thisNode.m_consumer_ptr != NULL);
DEBUG_EXPR(EVENTQUEUE_COMP,MedPrio,*(thisNode.m_consumer_ptr));
DEBUG_EXPR(EVENTQUEUE_COMP,MedPrio,thisNode.m_time);
thisNode.m_consumer_ptr->triggerWakeup(this);
RubyEventQueueNode *thisNode = new RubyEventQueueNode(consumer);
assert(timeAbs > getTime());
schedule(thisNode, (timeAbs * m_clock));
consumer->setLastScheduledWakeup(timeAbs * m_clock);
}
}
@ -118,5 +70,5 @@ void RubyEventQueue::triggerAllEvents()
void
RubyEventQueue::print(ostream& out) const
{
out << "[Event Queue: " << *m_prio_heap_ptr << "]";
out << "[Event Queue:]";
}

View file

@ -62,15 +62,16 @@
#include "config/no_vector_bounds_checks.hh"
#include "mem/ruby/common/Global.hh"
#include "mem/gems_common/Vector.hh"
#include "sim/eventq.hh"
class Consumer;
template <class TYPE> class PrioHeap;
class RubyEventQueueNode;
class RubyEventQueue {
class RubyEventQueue : public EventManager {
public:
// Constructors
RubyEventQueue(Tick clock);
RubyEventQueue(EventQueue* eventq, Tick _clock);
// Destructor
~RubyEventQueue();
@ -78,28 +79,21 @@ public:
// Public Methods
Time getTime() const { return curTick/m_clock; }
void scheduleEvent(Consumer* consumer, Time timeDelta) { scheduleEventAbsolute(consumer, timeDelta + m_globalTime); }
void scheduleEvent(Consumer* consumer, Time timeDelta);
void scheduleEventAbsolute(Consumer* consumer, Time timeAbs);
void triggerEvents(Time t); // called to handle all events <= time t
void triggerAllEvents();
void print(ostream& out) const;
bool isEmpty() const;
Time getTimeOfLastRecovery() {return m_timeOfLastRecovery;}
void setTimeOfLastRecovery(Time t) {m_timeOfLastRecovery = t;}
void triggerEvents(Time t) { assert(0); }
void triggerAllEvents() { assert(0); }
// Private Methods
private:
// Private copy constructor and assignment operator
void init();
RubyEventQueue(const RubyEventQueue& obj);
RubyEventQueue& operator=(const RubyEventQueue& obj);
// Data Members (m_ prefix)
Tick m_clock;
PrioHeap<RubyEventQueueNode>* m_prio_heap_ptr;
Time m_globalTime;
Time m_timeOfLastRecovery;
};
// Output operator declaration

View file

@ -37,7 +37,6 @@
void RubyEventQueueNode::print(ostream& out) const
{
out << "[";
out << "Time=" << m_time;
if (m_consumer_ptr != NULL) {
out << " Consumer=" << m_consumer_ptr;
} else {

View file

@ -36,31 +36,27 @@
#define RUBYEVENTQUEUENODE_H
#include "mem/ruby/common/Global.hh"
class Consumer;
#include "sim/eventq.hh"
#include "mem/ruby/common/Consumer.hh"
//class Consumer;
class RubyEventQueueNode {
class RubyEventQueueNode : public Event {
public:
// Constructors
RubyEventQueueNode() { m_time = 0; m_consumer_ptr = NULL; }
RubyEventQueueNode(Consumer* _consumer)
: m_consumer_ptr(_consumer)
{
setFlags(AutoDelete);
}
// Destructor
//~RubyEventQueueNode();
// Public Methods
void print(ostream& out) const;
virtual void process() { m_consumer_ptr->wakeup(); }
virtual const char *description() const { return "Ruby Event"; }
// Assignment operator and copy constructor since the default
// constructors confuse purify when long longs are present.
RubyEventQueueNode& operator=(const RubyEventQueueNode& obj) {
m_time = obj.m_time;
m_consumer_ptr = obj.m_consumer_ptr;
return *this;
}
RubyEventQueueNode(const RubyEventQueueNode& obj) {
m_time = obj.m_time;
m_consumer_ptr = obj.m_consumer_ptr;
}
private:
// Private Methods
@ -68,8 +64,6 @@ private:
// RubyEventQueueNode(const RubyEventQueueNode& obj);
// Data Members (m_ prefix)
public:
Time m_time;
Consumer* m_consumer_ptr;
};
@ -78,14 +72,6 @@ ostream& operator<<(ostream& out, const RubyEventQueueNode& obj);
// ******************* Definitions *******************
inline extern bool node_less_then_eq(const RubyEventQueueNode& n1, const RubyEventQueueNode& n2);
inline extern
bool node_less_then_eq(const RubyEventQueueNode& n1, const RubyEventQueueNode& n2)
{
return (n1.m_time <= n2.m_time);
}
// Output operator definition
extern inline
ostream& operator<<(ostream& out, const RubyEventQueueNode& obj)

View file

@ -105,7 +105,7 @@ RubySystem::RubySystem(const Params *p)
m_profiler_ptr = p->profiler;
m_tracer_ptr = p->tracer;
g_eventQueue_ptr = new RubyEventQueue(m_clock);
g_eventQueue_ptr = new RubyEventQueue(p->eventq, m_clock);
g_system_ptr = this;
m_mem_vec_ptr = new MemoryVector;
m_mem_vec_ptr->setSize(m_memory_size_bytes);