changeset 23e13ad7091f in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=23e13ad7091f
description:
        Ruby: remove reference to g_system_ptr from class Message
        This patch was initiated so as to remove reference to g_system_ptr,
        the pointer to Ruby System that is used for getting the current time.
        That simple change actual requires changing a lot many things in slicc 
and
        garnet. All these changes are related to how time is handled.

        In most of the places, g_system_ptr has been replaced by another clock
        object. The changes have been done under the assumption that all the
        components in the memory system are on the same clock frequency, but the
        actual clocks might be distributed.

diffstat:

 src/mem/ruby/common/Global.hh                                     |   7 -
 src/mem/ruby/network/garnet/BaseGarnetNetwork.cc                  |   2 +-
 src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc     |   6 +-
 src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.cc         |   8 +-
 src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh         |  29 ++--
 src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc  |  38 +++--
 src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.cc       |   4 +-
 src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh       |   2 +-
 src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.cc        |   6 +-
 src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh        |   9 +-
 src/mem/ruby/network/garnet/fixed-pipeline/RoutingUnit_d.cc       |   4 +-
 src/mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.cc       |  30 +++-
 src/mem/ruby/network/garnet/fixed-pipeline/Switch_d.cc            |  12 +-
 src/mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.cc       |  15 +-
 src/mem/ruby/network/garnet/fixed-pipeline/VirtualChannel_d.cc    |  47 
++++----
 src/mem/ruby/network/garnet/fixed-pipeline/VirtualChannel_d.hh    |  18 +-
 src/mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.cc        |   8 +-
 src/mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh        |   4 +-
 src/mem/ruby/network/garnet/fixed-pipeline/flit_d.cc              |  11 +-
 src/mem/ruby/network/garnet/fixed-pipeline/flit_d.hh              |  17 +-
 src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc    |   6 +-
 src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.cc |  27 ++--
 src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.cc      |   6 +-
 src/mem/ruby/network/garnet/flexible-pipeline/Router.cc           |  56 
+++------
 src/mem/ruby/network/garnet/flexible-pipeline/flit.cc             |   6 +-
 src/mem/ruby/network/garnet/flexible-pipeline/flit.hh             |   2 +-
 src/mem/ruby/network/garnet/flexible-pipeline/flitBuffer.cc       |   8 +-
 src/mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh       |   4 +-
 src/mem/ruby/network/orion/NetworkPower.cc                        |   6 +-
 src/mem/ruby/slicc_interface/Message.hh                           |   9 +-
 src/mem/ruby/slicc_interface/NetworkMessage.hh                    |   6 +-
 src/mem/ruby/slicc_interface/RubyRequest.hh                       |  17 +-
 src/mem/ruby/slicc_interface/RubySlicc_Util.hh                    |   5 +
 src/mem/ruby/structures/Prefetcher.hh                             |   2 +-
 src/mem/ruby/system/DMASequencer.cc                               |   4 +-
 src/mem/ruby/system/Sequencer.cc                                  |   2 +-
 src/mem/ruby/system/WireBuffer.cc                                 |   2 +
 src/mem/slicc/ast/EnqueueStatementAST.py                          |   3 +-
 src/mem/slicc/symbols/Type.py                                     |  29 ++--
 39 files changed, 243 insertions(+), 234 deletions(-)

diffs (truncated from 1447 to 300 lines):

diff -r 4ae4f3f4b870 -r 23e13ad7091f src/mem/ruby/common/Global.hh
--- a/src/mem/ruby/common/Global.hh     Mon Jan 14 10:04:21 2013 -0600
+++ b/src/mem/ruby/common/Global.hh     Mon Jan 14 10:05:10 2013 -0600
@@ -34,12 +34,5 @@
 class RubySystem;
 extern RubySystem* g_system_ptr;
 
-// FIXME: this is required by the contructor of Directory_Entry.hh.
-// It can't go into slicc_util.hh because it opens a can of ugly worms
-extern inline int max_tokens()
-{
-  return 1024;
-}
-
 #endif // __MEM_RUBY_COMMON_GLOBAL_HH__
 
diff -r 4ae4f3f4b870 -r 23e13ad7091f 
src/mem/ruby/network/garnet/BaseGarnetNetwork.cc
--- a/src/mem/ruby/network/garnet/BaseGarnetNetwork.cc  Mon Jan 14 10:04:21 
2013 -0600
+++ b/src/mem/ruby/network/garnet/BaseGarnetNetwork.cc  Mon Jan 14 10:05:10 
2013 -0600
@@ -127,7 +127,7 @@
 void
 BaseGarnetNetwork::clearStats()
 {
-    m_ruby_start = g_system_ptr->getTime();
+    m_ruby_start = curCycle();
 }
 
 Time
diff -r 4ae4f3f4b870 -r 23e13ad7091f 
src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc
--- a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc     Mon Jan 
14 10:04:21 2013 -0600
+++ b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc     Mon Jan 
14 10:05:10 2013 -0600
@@ -272,7 +272,7 @@
     for (int i = 0; i < m_link_ptr_vector.size(); i++) {
         average_link_utilization +=
             (double(m_link_ptr_vector[i]->getLinkUtilization())) /
-            (double(g_system_ptr->getTime()-m_ruby_start));
+            (double(curCycle() - m_ruby_start));
 
         vector<int> vc_load = m_link_ptr_vector[i]->getVcLoad();
         for (int j = 0; j < vc_load.size(); j++) {
@@ -290,8 +290,8 @@
         if (!m_in_use[i/m_vcs_per_vnet])
             continue;
 
-        average_vc_load[i] = (double(average_vc_load[i]) /
-            (double(g_system_ptr->getTime()) - m_ruby_start));
+        average_vc_load[i] = (double(average_vc_load[i])) /
+            (double(curCycle() - m_ruby_start));
         out << "Average VC Load [" << i << "] = " << average_vc_load[i]
             << " flits/cycle " << endl;
     }
diff -r 4ae4f3f4b870 -r 23e13ad7091f 
src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.cc
--- a/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.cc Mon Jan 14 
10:04:21 2013 -0600
+++ b/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.cc Mon Jan 14 
10:05:10 2013 -0600
@@ -53,7 +53,7 @@
     // Instantiating the virtual channels
     m_vcs.resize(m_num_vcs);
     for (int i=0; i < m_num_vcs; i++) {
-        m_vcs[i] = new VirtualChannel_d(i);
+        m_vcs[i] = new VirtualChannel_d(i, m_router->curCycle());
     }
 }
 
@@ -67,7 +67,7 @@
 InputUnit_d::wakeup()
 {
     flit_d *t_flit;
-    if (m_in_link->isReady()) {
+    if (m_in_link->isReady(m_router->curCycle())) {
 
         t_flit = m_in_link->consumeLink();
         int vc = t_flit->get_vc();
@@ -79,9 +79,9 @@
             // Do the route computation for this vc
             m_router->route_req(t_flit, this, vc);
 
-            m_vcs[vc]->set_enqueue_time(g_system_ptr->getTime());
+            m_vcs[vc]->set_enqueue_time(m_router->curCycle());
         } else {
-            t_flit->advance_stage(SA_);
+            t_flit->advance_stage(SA_, m_router->curCycle());
             m_router->swarb_req();
         }
         // write flit into input buffer
diff -r 4ae4f3f4b870 -r 23e13ad7091f 
src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh
--- a/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh Mon Jan 14 
10:04:21 2013 -0600
+++ b/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh Mon Jan 14 
10:05:10 2013 -0600
@@ -56,9 +56,9 @@
     inline int get_inlink_id() { return m_in_link->get_id(); }
 
     inline void
-    set_vc_state(VC_state_type state, int vc)
+    set_vc_state(VC_state_type state, int vc, Time curTime)
     {
-        m_vcs[vc]->set_state(state);
+        m_vcs[vc]->set_state(state, curTime);
     }
 
     inline void
@@ -86,9 +86,9 @@
     }
 
     inline void
-    increment_credit(int in_vc, bool free_signal)
+    increment_credit(int in_vc, bool free_signal, Time curTime)
     {
-        flit_d *t_flit = new flit_d(in_vc, free_signal);
+        flit_d *t_flit = new flit_d(in_vc, free_signal, curTime);
         creditQueue->insert(t_flit);
         m_credit_link->scheduleEvent(1);
     }
@@ -100,16 +100,16 @@
     }
 
     inline void
-    updateRoute(int vc, int outport)
+    updateRoute(int vc, int outport, Time curTime)
     {
         m_vcs[vc]->set_outport(outport);
-        m_vcs[vc]->set_state(VC_AB_);
+        m_vcs[vc]->set_state(VC_AB_, curTime);
     }
 
     inline void
-    grant_vc(int in_vc, int out_vc)
+    grant_vc(int in_vc, int out_vc, Time curTime)
     {
-        m_vcs[in_vc]->grant_vc(out_vc);
+        m_vcs[in_vc]->grant_vc(out_vc, curTime);
     }
 
     inline flit_d*
@@ -125,21 +125,22 @@
     }
 
     inline bool
-    need_stage(int vc, VC_state_type state, flit_stage stage)
+    need_stage(int vc, VC_state_type state, flit_stage stage, Time curTime)
     {
-        return m_vcs[vc]->need_stage(state, stage);
+        return m_vcs[vc]->need_stage(state, stage, curTime);
     }
 
     inline bool
-    need_stage_nextcycle(int vc, VC_state_type state, flit_stage stage)
+    need_stage_nextcycle(int vc, VC_state_type state, flit_stage stage,
+                         Time curTime)
     {
-        return m_vcs[vc]->need_stage_nextcycle(state, stage);
+        return m_vcs[vc]->need_stage_nextcycle(state, stage, curTime);
     }
 
     inline bool
-    isReady(int invc)
+    isReady(int invc, Time curTime)
     {
-        return m_vcs[invc]->isReady();
+        return m_vcs[invc]->isReady(curTime);
     }
 
     inline int
diff -r 4ae4f3f4b870 -r 23e13ad7091f 
src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc
--- a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc  Mon Jan 
14 10:04:21 2013 -0600
+++ b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc  Mon Jan 
14 10:05:10 2013 -0600
@@ -71,7 +71,7 @@
 
     for (int i = 0; i < m_num_vcs; i++) {
         m_out_vc_state.push_back(new OutVcState_d(i, m_net_ptr));
-        m_out_vc_state[i]->setState(IDLE_, g_system_ptr->getTime());
+        m_out_vc_state[i]->setState(IDLE_, m_net_ptr->curCycle());
     }
 }
 
@@ -170,12 +170,15 @@
 
         for (int i = 0; i < num_flits; i++) {
             m_net_ptr->increment_injected_flits(vnet);
-            flit_d *fl = new flit_d(i, vc, vnet, num_flits, new_msg_ptr);
-            fl->set_delay(g_system_ptr->getTime() - msg_ptr->getTime());
+            flit_d *fl = new flit_d(i, vc, vnet, num_flits, new_msg_ptr,
+                m_net_ptr->curCycle());
+
+            fl->set_delay(m_net_ptr->curCycle() - msg_ptr->getTime());
             m_ni_buffers[vc]->insert(fl);
         }
-        m_ni_enqueue_time[vc] = g_system_ptr->getTime();
-        m_out_vc_state[vc]->setState(ACTIVE_, g_system_ptr->getTime());
+
+        m_ni_enqueue_time[vc] = m_net_ptr->curCycle();
+        m_out_vc_state[vc]->setState(ACTIVE_, m_net_ptr->curCycle());
     }
     return true ;
 }
@@ -191,7 +194,7 @@
                         m_vc_allocator[vnet] = 0;
 
                 if (m_out_vc_state[(vnet*m_vc_per_vnet) + delta]->isInState(
-                    IDLE_, g_system_ptr->getTime())) {
+                    IDLE_, m_net_ptr->curCycle())) {
                         return ((vnet*m_vc_per_vnet) + delta);
                 }
         }
@@ -212,7 +215,7 @@
 NetworkInterface_d::wakeup()
 {
     DPRINTF(RubyNetwork, "m_id: %d woke up at time: %lld",
-            m_id, g_system_ptr->getTime());
+            m_id, m_net_ptr->curCycle());
 
     MsgPtr msg_ptr;
 
@@ -234,7 +237,7 @@
 
     /*********** Picking messages destined for this NI **********/
 
-    if (inNetLink->isReady()) {
+    if (inNetLink->isReady(m_net_ptr->curCycle())) {
         flit_d *t_flit = inNetLink->consumeLink();
         bool free_signal = false;
         if (t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_) {
@@ -245,13 +248,14 @@
         }
         // Simply send a credit back since we are not buffering
         // this flit in the NI
-        flit_d *credit_flit = new flit_d(t_flit->get_vc(), free_signal);
+        flit_d *credit_flit = new flit_d(t_flit->get_vc(), free_signal,
+                                         m_net_ptr->curCycle());
         creditQueue->insert(credit_flit);
         m_ni_credit_link->scheduleEvent(1);
 
         int vnet = t_flit->get_vnet();
         m_net_ptr->increment_received_flits(vnet);
-        int network_delay = g_system_ptr->getTime() -
+        int network_delay = m_net_ptr->curCycle() -
                             t_flit->get_enqueue_time();
         int queueing_delay = t_flit->get_delay();
         m_net_ptr->increment_network_latency(network_delay, vnet);
@@ -261,12 +265,12 @@
 
     /****************** Checking for credit link *******/
 
-    if (m_credit_link->isReady()) {
+    if (m_credit_link->isReady(m_net_ptr->curCycle())) {
         flit_d *t_flit = m_credit_link->consumeLink();
         m_out_vc_state[t_flit->get_vc()]->increment_credit();
         if (t_flit->is_free_signal()) {
             m_out_vc_state[t_flit->get_vc()]->setState(IDLE_,
-                g_system_ptr->getTime());
+                m_net_ptr->curCycle());
         }
         delete t_flit;
     }
@@ -292,7 +296,9 @@
             vc = 0;
 
         // model buffer backpressure
-        if (m_ni_buffers[vc]->isReady() && m_out_vc_state[vc]->has_credits()) {
+        if (m_ni_buffers[vc]->isReady(m_net_ptr->curCycle()) &&
+            m_out_vc_state[vc]->has_credits()) {
+
             bool is_candidate_vc = true;
             int t_vnet = get_vnet(vc);
             int vc_base = t_vnet * m_vc_per_vnet;
@@ -301,7 +307,7 @@
                 for (int vc_offset = 0; vc_offset < m_vc_per_vnet;
                      vc_offset++) {
                     int t_vc = vc_base + vc_offset;
-                    if (m_ni_buffers[t_vc]->isReady()) {
+                    if (m_ni_buffers[t_vc]->isReady(m_net_ptr->curCycle())) {
                         if (m_ni_enqueue_time[t_vc] < m_ni_enqueue_time[vc]) {
                             is_candidate_vc = false;
                             break;
@@ -315,7 +321,7 @@
             m_out_vc_state[vc]->decrement_credit();
             // Just removing the flit
             flit_d *t_flit = m_ni_buffers[vc]->getTopFlit();
-            t_flit->set_time(g_system_ptr->getTime() + 1);
+            t_flit->set_time(m_net_ptr->curCycle() + 1);
             outSrcQueue->insert(t_flit);
             // schedule the out link
             outNetLink->scheduleEvent(1);
@@ -350,7 +356,7 @@
         }
     }
     for (int vc = 0; vc < m_num_vcs; vc++) {
-        if (m_ni_buffers[vc]->isReadyForNext()) {
+        if (m_ni_buffers[vc]->isReadyForNext(m_net_ptr->curCycle())) {
             scheduleEvent(1);
             return;
         }
diff -r 4ae4f3f4b870 -r 23e13ad7091f 
src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.cc
--- a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.cc       Mon Jan 
14 10:04:21 2013 -0600
+++ b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.cc       Mon Jan 
14 10:05:10 2013 -0600
@@ -66,9 +66,9 @@
 void
 NetworkLink_d::wakeup()
 {
-    if (link_srcQueue->isReady()) {
+    if (link_srcQueue->isReady(curCycle())) {
         flit_d *t_flit = link_srcQueue->getTopFlit();
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to