changeset 150338b8ba12 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=150338b8ba12
description:
        ruby: slicc: replace max_in_port_rank with number of inports

        This patch replaces max_in_port_rank with the number of inports.  The 
use of
        max_in_port_rank was causing spurious re-builds and incorrect 
initialization
        of variables in ruby related regression tests.  This was due to the 
variable
        value being used across threads while compiling when it was not meant 
to be.

        Since the number of inports is state machine specific value, this 
problem
        should get solved.

diffstat:

 src/mem/ruby/slicc_interface/AbstractController.cc |   8 ++++----
 src/mem/ruby/slicc_interface/AbstractController.hh |   4 ++--
 src/mem/slicc/ast/InPortDeclAST.py                 |   8 --------
 src/mem/slicc/symbols/StateMachine.py              |  12 ++++--------
 4 files changed, 10 insertions(+), 22 deletions(-)

diffs (107 lines):

diff -r 2df9c3856989 -r 150338b8ba12 
src/mem/ruby/slicc_interface/AbstractController.cc
--- a/src/mem/ruby/slicc_interface/AbstractController.cc        Fri Dec 20 
20:34:03 2013 -0600
+++ b/src/mem/ruby/slicc_interface/AbstractController.cc        Fri Dec 20 
20:34:04 2013 -0600
@@ -104,10 +104,10 @@
 {
     if (m_waiting_buffers.count(addr) == 0) {
         MsgVecType* msgVec = new MsgVecType;
-        msgVec->resize(m_max_in_port_rank, NULL);
+        msgVec->resize(m_in_ports, NULL);
         m_waiting_buffers[addr] = msgVec;
     }
-    (*(m_waiting_buffers[addr]))[m_cur_in_port_rank] = buf;
+    (*(m_waiting_buffers[addr]))[m_cur_in_port] = buf;
 }
 
 void
@@ -118,7 +118,7 @@
         // 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;
+        for (int in_port_rank = m_cur_in_port - 1;
              in_port_rank >= 0;
              in_port_rank--) {
             if ((*(m_waiting_buffers[addr]))[in_port_rank] != NULL) {
@@ -138,7 +138,7 @@
         // 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;
+        for (int in_port_rank = m_in_ports - 1;
              in_port_rank >= 0;
              in_port_rank--) {
             if ((*(m_waiting_buffers[addr]))[in_port_rank] != NULL) {
diff -r 2df9c3856989 -r 150338b8ba12 
src/mem/ruby/slicc_interface/AbstractController.hh
--- a/src/mem/ruby/slicc_interface/AbstractController.hh        Fri Dec 20 
20:34:03 2013 -0600
+++ b/src/mem/ruby/slicc_interface/AbstractController.hh        Fri Dec 20 
20:34:04 2013 -0600
@@ -145,8 +145,8 @@
     typedef std::vector<MessageBuffer*> MsgVecType;
     typedef std::map< Address, MsgVecType* > WaitingBufType;
     WaitingBufType m_waiting_buffers;
-    int m_max_in_port_rank;
-    int m_cur_in_port_rank;
+    unsigned int m_in_ports;
+    unsigned int m_cur_in_port;
     int m_number_of_TBEs;
 
     //! Map from physical network number to the Message Buffer.
diff -r 2df9c3856989 -r 150338b8ba12 src/mem/slicc/ast/InPortDeclAST.py
--- a/src/mem/slicc/ast/InPortDeclAST.py        Fri Dec 20 20:34:03 2013 -0600
+++ b/src/mem/slicc/ast/InPortDeclAST.py        Fri Dec 20 20:34:04 2013 -0600
@@ -30,8 +30,6 @@
 from slicc.symbols import Func, Type, Var
 
 class InPortDeclAST(DeclAST):
-    max_port_rank = 0
-    
     def __init__(self, slicc, ident, msg_type, var_expr, pairs, statements):
         super(InPortDeclAST, self).__init__(slicc, pairs)
 
@@ -40,9 +38,6 @@
         self.var_expr = var_expr
         self.statements = statements
         self.queue_type = TypeAST(slicc, "InPort")
-        if self.pairs.has_key("rank"):
-            InPortDeclAST.max_port_rank = max(self.pairs["rank"],
-                                              InPortDeclAST.max_port_rank)
 
     def __repr__(self):
         return "[InPortDecl: %s]" % self.ident
@@ -120,6 +115,3 @@
 
         # Add port to state machine
         machine.addInPort(in_port)
-
-        # Include max_rank to be used by StateMachine.py
-        in_port["max_port_rank"] = InPortDeclAST.max_port_rank
diff -r 2df9c3856989 -r 150338b8ba12 src/mem/slicc/symbols/StateMachine.py
--- a/src/mem/slicc/symbols/StateMachine.py     Fri Dec 20 20:34:03 2013 -0600
+++ b/src/mem/slicc/symbols/StateMachine.py     Fri Dec 20 20:34:04 2013 -0600
@@ -460,12 +460,8 @@
 {
     m_name = "${ident}";
 ''')
-        #
-        # max_port_rank is used to size vectors and thus should be one plus the
-        # largest port rank
-        #
-        max_port_rank = self.in_ports[0].pairs["max_port_rank"] + 1
-        code('    m_max_in_port_rank = $max_port_rank;')
+        num_in_ports = len(self.in_ports)
+        code('    m_in_ports = $num_in_ports;')
         code.indent()
 
         #
@@ -1104,9 +1100,9 @@
             code.indent()
             code('// ${ident}InPort $port')
             if port.pairs.has_key("rank"):
-                code('m_cur_in_port_rank = ${{port.pairs["rank"]}};')
+                code('m_cur_in_port = ${{port.pairs["rank"]}};')
             else:
-                code('m_cur_in_port_rank = 0;')
+                code('m_cur_in_port = 0;')
             code('${{port["c_code_in_port"]}}')
             code.dedent()
 
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to