# HG changeset patch
# User Brad Beckmann <brad.beckm...@amd.com>
# Date 1263536243 28800
# Node ID bedc07d1355b1d016e93c8a8831274895e5f3741
# Parent  00bb4cb54fa91a68709ce82a878d0b6a724c8950
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.

diff -r 00bb4cb54fa9 -r bedc07d1355b src/mem/ruby/eventqueue/RubyEventQueue.cc
--- a/src/mem/ruby/eventqueue/RubyEventQueue.cc Thu Jan 14 22:17:23 2010 -0800
+++ b/src/mem/ruby/eventqueue/RubyEventQueue.cc Thu Jan 14 22:17:23 2010 -0800
@@ -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()
-{
-  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);
+void RubyEventQueue::scheduleEvent(Consumer* consumer, Time timeDelta) 
+{ 
+  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::print(ostream& out) const
 {
-  out << "[Event Queue: " << *m_prio_heap_ptr << "]";
+  out << "[Event Queue:]";
 }
diff -r 00bb4cb54fa9 -r bedc07d1355b src/mem/ruby/eventqueue/RubyEventQueue.hh
--- a/src/mem/ruby/eventqueue/RubyEventQueue.hh Thu Jan 14 22:17:23 2010 -0800
+++ b/src/mem/ruby/eventqueue/RubyEventQueue.hh Thu Jan 14 22:17:23 2010 -0800
@@ -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 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
diff -r 00bb4cb54fa9 -r bedc07d1355b 
src/mem/ruby/eventqueue/RubyEventQueueNode.cc
--- a/src/mem/ruby/eventqueue/RubyEventQueueNode.cc     Thu Jan 14 22:17:23 
2010 -0800
+++ b/src/mem/ruby/eventqueue/RubyEventQueueNode.cc     Thu Jan 14 22:17:23 
2010 -0800
@@ -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 {
diff -r 00bb4cb54fa9 -r bedc07d1355b 
src/mem/ruby/eventqueue/RubyEventQueueNode.hh
--- a/src/mem/ruby/eventqueue/RubyEventQueueNode.hh     Thu Jan 14 22:17:23 
2010 -0800
+++ b/src/mem/ruby/eventqueue/RubyEventQueueNode.hh     Thu Jan 14 22:17:23 
2010 -0800
@@ -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 @@
   // RubyEventQueueNode(const RubyEventQueueNode& obj);
 
   // Data Members (m_ prefix)
-public:
-  Time m_time;
   Consumer* m_consumer_ptr;
 };
 
@@ -78,14 +72,6 @@
 
 // ******************* 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)
diff -r 00bb4cb54fa9 -r bedc07d1355b src/mem/ruby/system/System.cc
--- a/src/mem/ruby/system/System.cc     Thu Jan 14 22:17:23 2010 -0800
+++ b/src/mem/ruby/system/System.cc     Thu Jan 14 22:17:23 2010 -0800
@@ -107,7 +107,7 @@
     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);

_______________________________________________
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to