ruby: network: garnet: add statistics for different activities
authorNilay Vaish <nilay@cs.wisc.edu>
Sat, 11 Oct 2014 20:02:23 +0000 (15:02 -0500)
committerNilay Vaish <nilay@cs.wisc.edu>
Sat, 11 Oct 2014 20:02:23 +0000 (15:02 -0500)
This patch adds some statistics to garnet that record the activity
of certain structures in the on-chip network.  These statistics, in a later
patch, will be used for computing the energy consumed by the on-chip network.

src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh
src/mem/ruby/network/garnet/fixed-pipeline/Router_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/Router_d.hh

index 82d89912e3c97b712f7a5eb7bad0ff5e09076de3..6cb60032a0b2a39a49b7a7b9eaae29fd767cfd01 100644 (file)
@@ -105,3 +105,12 @@ InputUnit_d::functionalWrite(Packet *pkt)
 
     return num_functional_writes;
 }
+
+void
+InputUnit_d::resetStats()
+{
+    for (int j = 0; j < m_num_buffer_reads.size(); j++) {
+        m_num_buffer_reads[j] = 0;
+        m_num_buffer_writes[j] = 0;
+    }
+}
index c3dc5e69dfcc7d8adb49b33fc6f9f8ce89c87525..c9437a77419a8a06823efac80141f3f889ea0f9f 100644 (file)
@@ -159,6 +159,7 @@ class InputUnit_d : public Consumer
     { return m_num_buffer_writes[vnet]; }
 
     uint32_t functionalWrite(Packet *pkt);
+    void resetStats();
 
   private:
     int m_id;
index 9f0b6c33f70ad0fb6fd9fa9747b5b53d1c537f17..126cf79e6a8f375d9dd5cdab2587fded6fd9c8c0 100644 (file)
@@ -57,20 +57,6 @@ Router_d::Router_d(const Params *p)
 
     m_input_unit.clear();
     m_output_unit.clear();
-
-    crossbar_count = 0;
-    sw_local_arbit_count = 0;
-    sw_global_arbit_count = 0;
-    buf_read_count.resize(m_virtual_networks);
-    buf_write_count.resize(m_virtual_networks);
-    vc_local_arbit_count.resize(m_virtual_networks);
-    vc_global_arbit_count.resize(m_virtual_networks);
-    for (int i = 0; i < m_virtual_networks; i++) {
-        buf_read_count[i] = 0;
-        buf_write_count[i] = 0;
-        vc_local_arbit_count[i] = 0;
-        vc_global_arbit_count[i] = 0;
-    }
 }
 
 Router_d::~Router_d()
@@ -157,22 +143,71 @@ Router_d::update_sw_winner(int inport, flit_d *t_flit)
     m_switch->scheduleEventAbsolute(clockEdge(Cycles(1)));
 }
 
+void
+Router_d::regStats()
+{
+    m_buffer_reads
+        .name(name() + ".buffer_reads")
+        .flags(Stats::nozero)
+    ;
+
+    m_buffer_writes
+        .name(name() + ".buffer_writes")
+        .flags(Stats::nozero)
+    ;
+
+    m_crossbar_activity
+        .name(name() + ".crossbar_activity")
+        .flags(Stats::nozero)
+    ;
+
+    m_sw_local_arbiter_activity
+        .name(name() + ".sw_local_arbiter_activity")
+        .flags(Stats::nozero)
+    ;
+
+    m_sw_global_arbiter_activity
+        .name(name() + ".sw_global_arbiter_activity")
+        .flags(Stats::nozero)
+    ;
+
+    m_vc_local_arbiter_activity
+        .name(name() + ".vc_local_arbiter_activity")
+        .flags(Stats::nozero)
+    ;
+
+    m_vc_global_arbiter_activity
+        .name(name() + ".vc_global_arbiter_activity")
+        .flags(Stats::nozero)
+    ;
+}
+
 void
 Router_d::collateStats()
 {
     for (int j = 0; j < m_virtual_networks; j++) {
         for (int i = 0; i < m_input_unit.size(); i++) {
-            buf_read_count[j] += m_input_unit[i]->get_buf_read_count(j);
-            buf_write_count[j] += m_input_unit[i]->get_buf_write_count(j);
+            m_buffer_reads += m_input_unit[i]->get_buf_read_count(j);
+            m_buffer_writes += m_input_unit[i]->get_buf_write_count(j);
         }
 
-        vc_local_arbit_count[j]  = m_vc_alloc->get_local_arbit_count(j);
-        vc_global_arbit_count[j] = m_vc_alloc->get_global_arbit_count(j);
+        m_vc_local_arbiter_activity  += m_vc_alloc->get_local_arbit_count(j);
+        m_vc_global_arbiter_activity += m_vc_alloc->get_global_arbit_count(j);
     }
 
-    sw_local_arbit_count = m_sw_alloc->get_local_arbit_count();
-    sw_global_arbit_count = m_sw_alloc->get_global_arbit_count();
-    crossbar_count = m_switch->get_crossbar_count();
+    m_sw_local_arbiter_activity = m_sw_alloc->get_local_arbit_count();
+    m_sw_global_arbiter_activity = m_sw_alloc->get_global_arbit_count();
+    m_crossbar_activity = m_switch->get_crossbar_count();
+}
+
+void
+Router_d::resetStats()
+{
+    for (int j = 0; j < m_virtual_networks; j++) {
+        for (int i = 0; i < m_input_unit.size(); i++) {
+            m_input_unit[i]->resetStats();
+        }
+    }
 }
 
 void
index 931455e43b31d0bc43c3329520a8da830a1b8326..5d09fb045eb97cbc62b53e062c94efa0d49f705d 100644 (file)
@@ -88,7 +88,10 @@ class Router_d : public BasicRouter
 
     void printFaultVector(std::ostream& out);
     void printAggregateFaultProbability(std::ostream& out);
+
+    void regStats();
     void collateStats();
+    void resetStats();
 
     bool get_fault_vector(int temperature, float fault_vector[]){ 
         return m_network_ptr->fault_model->fault_vector(m_id, temperature, 
@@ -105,8 +108,6 @@ class Router_d : public BasicRouter
   private:
     int m_virtual_networks, m_num_vcs, m_vc_per_vnet;
     GarnetNetwork_d *m_network_ptr;
-    double sw_local_arbit_count, sw_global_arbit_count;
-    double crossbar_count;
 
     std::vector<InputUnit_d *> m_input_unit;
     std::vector<OutputUnit_d *> m_output_unit;
@@ -115,11 +116,17 @@ class Router_d : public BasicRouter
     SWallocator_d *m_sw_alloc;
     Switch_d *m_switch;
 
-    // Statistical variables for performance
-    std::vector<double> buf_read_count;
-    std::vector<double> buf_write_count;
-    std::vector<double> vc_local_arbit_count;
-    std::vector<double> vc_global_arbit_count;
+    // Statistical variables required for power computations
+    Stats::Scalar m_buffer_reads;
+    Stats::Scalar m_buffer_writes;
+
+    Stats::Scalar m_sw_local_arbiter_activity;
+    Stats::Scalar m_sw_global_arbiter_activity;
+
+    Stats::Scalar m_vc_local_arbiter_activity;
+    Stats::Scalar m_vc_global_arbiter_activity;
+
+    Stats::Scalar m_crossbar_activity;
 };
 
 #endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_ROUTER_D_HH__