ruby: move stall and wakeup functions to AbstractController
authorNilay Vaish <nilay@cs.wisc.edu>
Fri, 22 Mar 2013 20:53:24 +0000 (15:53 -0500)
committerNilay Vaish <nilay@cs.wisc.edu>
Fri, 22 Mar 2013 20:53:24 +0000 (15:53 -0500)
These functions are currently implemented in one of the files related to Slicc.
Since these are purely C++ functions, they are better suited to be in the base
class.

src/mem/ruby/slicc_interface/AbstractController.cc
src/mem/ruby/slicc_interface/AbstractController.hh
src/mem/slicc/symbols/StateMachine.py

index 1615f8c1d09dcbb401440a2aa77b04aff8265f3d..13107038c7d45aef7a1d64dc3c13d0698fe723c6 100644 (file)
@@ -86,3 +86,87 @@ AbstractController::connectWithPeer(AbstractController *c)
     getQueuesFromPeer(c);
     c->getQueuesFromPeer(this);
 }
+
+void
+AbstractController::stallBuffer(MessageBuffer* buf, Address addr)
+{
+    if (m_waiting_buffers.count(addr) == 0) {
+        MsgVecType* msgVec = new MsgVecType;
+        msgVec->resize(m_max_in_port_rank, NULL);
+        m_waiting_buffers[addr] = msgVec;
+    }
+    (*(m_waiting_buffers[addr]))[m_cur_in_port_rank] = buf;
+}
+
+void
+AbstractController::wakeUpBuffers(Address addr)
+{
+    if (m_waiting_buffers.count(addr) > 0) {
+        //
+        // Wake up all possible lower rank (i.e. lower priority) buffers that could
+        // be waiting on this message.
+        //
+        for (int in_port_rank = m_cur_in_port_rank - 1;
+             in_port_rank >= 0;
+             in_port_rank--) {
+            if ((*(m_waiting_buffers[addr]))[in_port_rank] != NULL) {
+                (*(m_waiting_buffers[addr]))[in_port_rank]->reanalyzeMessages(addr);
+            }
+        }
+        delete m_waiting_buffers[addr];
+        m_waiting_buffers.erase(addr);
+    }
+}
+
+void
+AbstractController::wakeUpAllBuffers(Address addr)
+{
+    if (m_waiting_buffers.count(addr) > 0) {
+        //
+        // Wake up all possible lower rank (i.e. lower priority) buffers that could
+        // be waiting on this message.
+        //
+        for (int in_port_rank = m_max_in_port_rank - 1;
+             in_port_rank >= 0;
+             in_port_rank--) {
+            if ((*(m_waiting_buffers[addr]))[in_port_rank] != NULL) {
+                (*(m_waiting_buffers[addr]))[in_port_rank]->reanalyzeMessages(addr);
+            }
+        }
+        delete m_waiting_buffers[addr];
+        m_waiting_buffers.erase(addr);
+    }
+}
+
+void
+AbstractController::wakeUpAllBuffers()
+{
+    //
+    // Wake up all possible buffers that could be waiting on any message.
+    //
+
+    std::vector<MsgVecType*> wokeUpMsgVecs;
+
+    if(m_waiting_buffers.size() > 0) {
+        for (WaitingBufType::iterator buf_iter = m_waiting_buffers.begin();
+             buf_iter != m_waiting_buffers.end();
+             ++buf_iter) {
+             for (MsgVecType::iterator vec_iter = buf_iter->second->begin();
+                  vec_iter != buf_iter->second->end();
+                  ++vec_iter) {
+                  if (*vec_iter != NULL) {
+                      (*vec_iter)->reanalyzeAllMessages();
+                  }
+             }
+             wokeUpMsgVecs.push_back(buf_iter->second);
+        }
+
+        for (std::vector<MsgVecType*>::iterator wb_iter = wokeUpMsgVecs.begin();
+             wb_iter != wokeUpMsgVecs.end();
+             ++wb_iter) {
+             delete (*wb_iter);
+        }
+
+        m_waiting_buffers.clear();
+    }
+}
index 81ef3c52bc29554acaaf09c828c01146cdb97255..e2471777bae6c884219e0c334019cf93f9ea747c 100644 (file)
@@ -33,6 +33,7 @@
 #include <string>
 
 #include "mem/protocol/AccessPermission.hh"
+#include "mem/ruby/buffers/MessageBuffer.hh"
 #include "mem/ruby/common/Address.hh"
 #include "mem/ruby/common/Consumer.hh"
 #include "mem/ruby/common/DataBlock.hh"
@@ -44,7 +45,6 @@
 #include "params/RubyController.hh"
 #include "sim/clocked_object.hh"
 
-class MessageBuffer;
 class Network;
 
 class AbstractController : public ClockedObject, public Consumer
@@ -116,6 +116,11 @@ class AbstractController : public ClockedObject, public Consumer
     virtual void getQueuesFromPeer(AbstractController *)
     { fatal("getQueuesFromPeer() should be called only if implemented!"); }
 
+    void stallBuffer(MessageBuffer* buf, Address addr);
+    void wakeUpBuffers(Address addr);
+    void wakeUpAllBuffers(Address addr);
+    void wakeUpAllBuffers();
+
   protected:
     int m_transitions_per_cycle;
     int m_buffer_size;
index 3f54a1cdbff34b6ba1f22e41170cc5778ee34f2f..3618563fdbe17d2f74467ee804453b59cc09138e 100644 (file)
@@ -262,9 +262,6 @@ class $c_ident : public AbstractController
     const int & getVersion() const;
     const std::string toString() const;
     const std::string getName() const;
-    void stallBuffer(MessageBuffer* buf, Address addr);
-    void wakeUpBuffers(Address addr);
-    void wakeUpAllBuffers();
     void initNetworkPtr(Network* net_ptr) { m_net_ptr = net_ptr; }
     void print(std::ostream& out) const;
     void wakeup();
@@ -748,70 +745,6 @@ $c_ident::getName() const
     return m_name;
 }
 
-void
-$c_ident::stallBuffer(MessageBuffer* buf, Address addr)
-{
-    if (m_waiting_buffers.count(addr) == 0) {
-        MsgVecType* msgVec = new MsgVecType;
-        msgVec->resize(m_max_in_port_rank, NULL);
-        m_waiting_buffers[addr] = msgVec;
-    }
-    (*(m_waiting_buffers[addr]))[m_cur_in_port_rank] = buf;
-}
-
-void
-$c_ident::wakeUpBuffers(Address addr)
-{
-    if (m_waiting_buffers.count(addr) > 0) {
-        //
-        // Wake up all possible lower rank (i.e. lower priority) buffers that could
-        // be waiting on this message.
-        //
-        for (int in_port_rank = m_cur_in_port_rank - 1;
-             in_port_rank >= 0;
-             in_port_rank--) {
-            if ((*(m_waiting_buffers[addr]))[in_port_rank] != NULL) {
-                (*(m_waiting_buffers[addr]))[in_port_rank]->reanalyzeMessages(addr);
-            }
-        }
-        delete m_waiting_buffers[addr];
-        m_waiting_buffers.erase(addr);
-    }
-}
-
-void
-$c_ident::wakeUpAllBuffers()
-{
-    //
-    // Wake up all possible buffers that could be waiting on any message.
-    //
-
-    std::vector<MsgVecType*> wokeUpMsgVecs;
-    
-    if(m_waiting_buffers.size() > 0) {
-        for (WaitingBufType::iterator buf_iter = m_waiting_buffers.begin();
-             buf_iter != m_waiting_buffers.end();
-             ++buf_iter) {
-             for (MsgVecType::iterator vec_iter = buf_iter->second->begin();
-                  vec_iter != buf_iter->second->end();
-                  ++vec_iter) {
-                  if (*vec_iter != NULL) {
-                      (*vec_iter)->reanalyzeAllMessages();
-                  }
-             }
-             wokeUpMsgVecs.push_back(buf_iter->second);
-        }
-
-        for (std::vector<MsgVecType*>::iterator wb_iter = wokeUpMsgVecs.begin();
-             wb_iter != wokeUpMsgVecs.end();
-             ++wb_iter) {
-             delete (*wb_iter);
-        }
-
-        m_waiting_buffers.clear();
-    }
-}
-
 void
 $c_ident::blockOnQueue(Address addr, MessageBuffer* port)
 {