ruby: network: garnet: fixed: removes next cycle functions
authorNilay Vaish <nilay@cs.wisc.edu>
Thu, 20 Feb 2014 23:28:01 +0000 (17:28 -0600)
committerNilay Vaish <nilay@cs.wisc.edu>
Thu, 20 Feb 2014 23:28:01 +0000 (17:28 -0600)
At several places, there are functions that take a cycle value as input
and performs some computation.  Along with each such function, another
function was being defined that simply added one more cycle to input and
computed the same function.  This patch removes this second copy of the
function.  Places where these functions were being called have been updated
to use the original function with argument being current cycle + 1.

src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh
src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/Switch_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/VirtualChannel_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/VirtualChannel_d.hh
src/mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh
src/mem/ruby/network/garnet/fixed-pipeline/flit_d.hh

index 2c37996b3efcbc781b4ddac6d4ae4e2ea98870ff..836613d02895cb0b84e795f163310941b8084dfa 100644 (file)
@@ -125,16 +125,9 @@ class InputUnit_d : public Consumer
     }
 
     inline bool
-    need_stage(int vc, VC_state_type state, flit_stage stage, Cycles curTime)
+    need_stage(int vc, VC_state_type state, flit_stage stage, Cycles cTime)
     {
-        return m_vcs[vc]->need_stage(state, stage, curTime);
-    }
-
-    inline bool
-    need_stage_nextcycle(int vc, VC_state_type state, flit_stage stage,
-                         Cycles curTime)
-    {
-        return m_vcs[vc]->need_stage_nextcycle(state, stage, curTime);
+        return m_vcs[vc]->need_stage(state, stage, cTime);
     }
 
     inline bool
index b48efb6329a1cfb4b5ef1c596a76e4c73a3492b7..c4c64b5ea0d90126a9eb2f94763e5d15954c3116 100644 (file)
@@ -361,7 +361,7 @@ NetworkInterface_d::checkReschedule()
         }
     }
     for (int vc = 0; vc < m_num_vcs; vc++) {
-        if (m_ni_buffers[vc]->isReadyForNext(m_net_ptr->curCycle())) {
+        if (m_ni_buffers[vc]->isReady(m_net_ptr->curCycle() + Cycles(1))) {
             scheduleEvent(Cycles(1));
             return;
         }
index e292745c1cd39f17cbe5aa388cfc40955b6fd7c1..cabf435f42c1eaa07e7f99dcc397a39ea30b089e 100644 (file)
@@ -218,10 +218,11 @@ SWallocator_d::arbitrate_outports()
 void
 SWallocator_d::check_for_wakeup()
 {
+    Cycles nextCycle = m_router->curCycle() + Cycles(1);
+
     for (int i = 0; i < m_num_inports; i++) {
         for (int j = 0; j < m_num_vcs; j++) {
-            if (m_input_unit[i]->need_stage_nextcycle(j, ACTIVE_, SA_,
-                                                      m_router->curCycle())) {
+            if (m_input_unit[i]->need_stage(j, ACTIVE_, SA_, nextCycle)) {
                 scheduleEvent(Cycles(1));
                 return;
             }
index f41dc884d9a8daef5b3d40854fcf5c7c05ddac89..4b4a4f323aecae1d798988e9f88176cac5f3f32b 100644 (file)
@@ -88,8 +88,10 @@ Switch_d::wakeup()
 void
 Switch_d::check_for_wakeup()
 {
+    Cycles nextCycle = m_router->curCycle() + Cycles(1);
+
     for (int inport = 0; inport < m_num_inports; inport++) {
-        if (m_switch_buffer[inport]->isReadyForNext(m_router->curCycle())) {
+        if (m_switch_buffer[inport]->isReady(nextCycle)) {
             scheduleEvent(Cycles(1));
             break;
         }
index e9e2226a8f58f57058dbdc38349ebd1e62acb178..395b1a9c5065f87ee8a9ac18b658fd6e82d36043 100644 (file)
@@ -256,10 +256,11 @@ VCallocator_d::get_vnet(int invc)
 void
 VCallocator_d::check_for_wakeup()
 {
+    Cycles nextCycle = m_router->curCycle() + Cycles(1);
+
     for (int i = 0; i < m_num_inports; i++) {
         for (int j = 0; j < m_num_vcs; j++) {
-            if (m_input_unit[i]->need_stage_nextcycle(j, VC_AB_, VA_,
-                   m_router->curCycle())) {
+            if (m_input_unit[i]->need_stage(j, VC_AB_, VA_, nextCycle)) {
                 scheduleEvent(Cycles(1));
                 return;
             }
index 510a79e8dc14b7420a985a083ee2b0a8b4a68d99..109d2a3be5793b2ee9d994e8e3896f623e2a0da7 100644 (file)
@@ -62,25 +62,12 @@ VirtualChannel_d::grant_vc(int out_vc, Cycles curTime)
 
 bool
 VirtualChannel_d::need_stage(VC_state_type state, flit_stage stage,
-                             Cycles curTime)
+                             Cycles ct)
 {
-    if ((m_vc_state.first == state) && (curTime >= m_vc_state.second)) {
-        if (m_input_buffer->isReady(curTime)) {
+    if ((m_vc_state.first == state) && (ct >= m_vc_state.second)) {
+        if (m_input_buffer->isReady(ct)) {
             flit_d *t_flit = m_input_buffer->peekTopFlit();
-            return(t_flit->is_stage(stage, curTime)) ;
-        }
-    }
-    return false;
-}
-
-bool
-VirtualChannel_d::need_stage_nextcycle(VC_state_type state, flit_stage stage,
-                                       Cycles curTime)
-{
-    if ((m_vc_state.first == state) && ((curTime + 1) >= m_vc_state.second)) {
-        if (m_input_buffer->isReadyForNext(curTime)) {
-            flit_d *t_flit = m_input_buffer->peekTopFlit();
-            return(t_flit->is_next_stage(stage, curTime)) ;
+            return(t_flit->is_stage(stage, ct)) ;
         }
     }
     return false;
index d196303053ea6aeb7ed466825f46f8350ba578fc..b46a095e6fde04ad330769def5672a1d70db620f 100644 (file)
@@ -43,8 +43,6 @@ class VirtualChannel_d
     ~VirtualChannel_d();
 
     bool need_stage(VC_state_type state, flit_stage stage, Cycles curTime);
-    bool need_stage_nextcycle(VC_state_type state, flit_stage stage,
-                              Cycles curTime);
     void set_outport(int outport);
     void grant_vc(int out_vc, Cycles curTime);
 
index 6a7d4be872ddaee3ae5202c386f8390049b3a562..1305b154707c2a14a62b4a2ebc3ea841687cfa1c 100644 (file)
@@ -57,17 +57,6 @@ flitBuffer_d::isReady(Cycles curTime)
     return false;
 }
 
-bool
-flitBuffer_d::isReadyForNext(Cycles curTime)
-{
-    if (m_buffer.size() != 0 ) {
-        flit_d *t_flit = peekTopFlit();
-        if (t_flit->get_time() <= (curTime + 1))
-            return true;
-    }
-    return false;
-}
-
 void
 flitBuffer_d::print(std::ostream& out) const
 {
index 2fe6e982bbac753f1fd7b9adb24088af3f1c3638..bfa6cc9a953c5e6b1747979da7efda0a5d735228 100644 (file)
@@ -45,7 +45,6 @@ class flitBuffer_d
     flitBuffer_d(int maximum_size);
 
     bool isReady(Cycles curTime);
-    bool isReadyForNext(Cycles curTime);
     bool isEmpty();
     void print(std::ostream& out) const;
     bool isFull();
index 87ea1152f23f4514f591ba39a0da814f1aac6a22..55187bd14d527a184efd5ccfb873c758624933c4 100644 (file)
@@ -65,13 +65,6 @@ class flit_d
                 curTime >= m_stage.second);
     }
 
-    bool
-    is_next_stage(flit_stage t_stage, Cycles curTime)
-    {
-        return (m_stage.first == t_stage &&
-                (curTime + 1) >= m_stage.second);
-    }
-
     void
     advance_stage(flit_stage t_stage, Cycles curTime)
     {