fix garnet fleible pipeline
authorTushar Krishna <tushar@csail.mit.edu>
Tue, 22 Mar 2011 02:51:59 +0000 (22:51 -0400)
committerTushar Krishna <tushar@csail.mit.edu>
Tue, 22 Mar 2011 02:51:59 +0000 (22:51 -0400)
src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc
src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh
src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.cc
src/mem/ruby/network/garnet/flexible-pipeline/Router.cc
src/mem/ruby/network/garnet/flexible-pipeline/flit.cc
src/mem/ruby/network/garnet/flexible-pipeline/flit.hh

index 20ddf86e5b23360d056d85d0733230fe19999e99..8280360c47a40cea397dc8160292ceedb4864672 100644 (file)
@@ -30,7 +30,6 @@
 
 #include <cassert>
 
-#include "base/cprintf.hh"
 #include "base/stl_helpers.hh"
 #include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh"
 #include "mem/protocol/MachineType.hh"
@@ -50,6 +49,10 @@ GarnetNetwork::GarnetNetwork(const Params *p)
     : BaseGarnetNetwork(p)
 {
     m_ruby_start = 0;
+    m_flits_received = 0;
+    m_flits_injected = 0;
+    m_network_latency = 0.0;
+    m_queueing_latency = 0.0;
 
     // Allocate to and from queues
 
@@ -191,7 +194,6 @@ void
 GarnetNetwork::checkNetworkAllocation(NodeID id, bool ordered,
     int network_num)
 {
-    cprintf ("id = %i, m_nodes = %i \n", id, m_nodes);
     assert(id < m_nodes);
     assert(network_num < m_virtual_networks);
 
@@ -264,6 +266,18 @@ GarnetNetwork::printStats(ostream& out) const
                " flits/cycle" << endl;
     }
     out << "-------------" << endl;
+
+    out << "Total flits injected = " << m_flits_injected << endl;
+    out << "Total flits received = " << m_flits_received << endl;
+    out << "Average network latency = "
+        << ((double) m_network_latency/ (double) m_flits_received)<< endl;
+    out << "Average queueing (at source NI) latency = "
+        << ((double) m_queueing_latency/ (double) m_flits_received)<< endl;
+    out << "Average latency = "
+        << ((double)  (m_queueing_latency + m_network_latency) /
+            (double) m_flits_received)<< endl;
+    out << "-------------" << endl;
+
     m_topology_ptr->printStats(out);
 }
 
index 96aa5fd10c61cad2fca7d6961f476aff8e3e91fb..51a9380cb803428f2d1c895432177a592f74474c 100644 (file)
@@ -65,6 +65,21 @@ class GarnetNetwork : public BaseGarnetNetwork
     void printConfig(std::ostream& out) const;
     void print(std::ostream& out) const;
 
+    inline void increment_injected_flits() { m_flits_injected++; }
+    inline void increment_received_flits() { m_flits_received++; }
+
+    inline void
+    increment_network_latency(Time latency)
+    {
+        m_network_latency += latency;
+    }
+
+    inline void
+    increment_queueing_latency(Time latency)
+    {
+        m_queueing_latency += latency;
+    }
+
     bool isVNetOrdered(int vnet) { return m_ordered[vnet]; }
     bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; }
 
@@ -92,6 +107,8 @@ class GarnetNetwork : public BaseGarnetNetwork
 
     // int m_virtual_networks;
     // int m_nodes;
+    int m_flits_received, m_flits_injected;
+    double m_network_latency, m_queueing_latency;
 
     std::vector<bool> m_in_use;
     std::vector<bool> m_ordered;
index 60ec09e588dbeac83b7c790fbd9792a8af295370..11da465a89a0d1215c35e6f10e1eef8fbda0c189 100644 (file)
@@ -162,7 +162,9 @@ NetworkInterface::flitisizeMessage(MsgPtr msg_ptr, int vnet)
             net_msg_ptr->getInternalDestination().removeNetDest(personal_dest);
         }
         for (int i = 0; i < num_flits; i++) {
+            m_net_ptr->increment_injected_flits();
             flit *fl = new flit(i, vc, vnet, num_flits, new_msg_ptr);
+            fl->set_delay(g_eventQueue_ptr->getTime() - msg_ptr->getTime());
             m_ni_buffers[vc]->insert(fl);
         }
 
@@ -269,6 +271,12 @@ NetworkInterface::wakeup()
             inNetLink->release_vc_link(t_flit->get_vc(),
                 g_eventQueue_ptr->getTime() + 1);
         }
+        m_net_ptr->increment_received_flits();
+        int network_delay = g_eventQueue_ptr->getTime() -
+                            t_flit->get_enqueue_time();
+        int queueing_delay = t_flit->get_delay();
+        m_net_ptr->increment_network_latency(network_delay);
+        m_net_ptr->increment_queueing_latency(queueing_delay);
         delete t_flit;
     }
 }
index ce90c974831cdc11984cba7ec3a0765f32cac44c..fef6b00a180ebad9cb2d44b49002aac515e556d5 100644 (file)
@@ -99,8 +99,11 @@ Router::addOutPort(NetworkLink *out_link, const NetDest& routing_table_entry,
 
     vector<flitBuffer *> intermediateQueues;
     for (int i = 0; i < m_num_vcs; i++) {
-        intermediateQueues.push_back(new flitBuffer(
-            m_net_ptr->getBufferSize()));
+        int buffer_size = m_net_ptr->getBufferSize();
+        if (buffer_size > 0) // finite size
+            intermediateQueues.push_back(new flitBuffer(buffer_size));
+        else // infinite size
+            intermediateQueues.push_back(new flitBuffer());
     }
     m_router_buffers.push_back(intermediateQueues);
 
index 1227b70f05f12cc7bd16a1971ebc0ecd9db808fb..2f5944c626276981cc9210cbac9a955a0da85666 100644 (file)
@@ -112,6 +112,18 @@ flit::get_type()
     return m_type;
 }
 
+void
+flit::set_delay(int delay)
+{
+    src_delay = delay;
+}
+
+int
+flit::get_delay()
+{
+    return src_delay;
+}
+
 void
 flit::print(std::ostream& out) const
 {
index 4c072b2702ebe4de96cb619228610edd8565c074..83a6f82aa0a0107ad5a3db863fa067bd15318d01 100644 (file)
@@ -52,6 +52,8 @@ class flit
     void set_vc(int vc);
     MsgPtr& get_msg_ptr();
     flit_type get_type();
+    void set_delay(int delay);
+    int get_delay();
     void print(std::ostream& out) const;
 
     static bool
@@ -72,7 +74,7 @@ class flit
     Time m_enqueue_time, m_time;
     flit_type m_type;
     MsgPtr m_msg_ptr;
-
+    int src_delay;
 };
 
 inline std::ostream&