garnet: added network ptr to links to be used by orion
authorTushar Krishna <tushar@csail.mit.edu>
Tue, 31 May 2011 06:55:14 +0000 (02:55 -0400)
committerTushar Krishna <tushar@csail.mit.edu>
Tue, 31 May 2011 06:55:14 +0000 (02:55 -0400)
src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh
src/mem/ruby/network/orion/NetworkPower.cc

index 7ba2e561a75ef4b77b63ceb7cd69deaef5aee1be..1fa4abbac0d86f8f8ec75c9e9261c6ee9ed259a9 100644 (file)
@@ -90,6 +90,13 @@ GarnetNetwork_d::init()
     }
     // false because this isn't a reconfiguration
     m_topology_ptr->createLinks(this, false);
+
+    // initialize the link's network pointers
+   for (vector<NetworkLink_d*>::const_iterator i = m_link_ptr_vector.begin();
+         i != m_link_ptr_vector.end(); ++i) {
+        NetworkLink_d* net_link = safe_cast<NetworkLink_d*>(*i);
+        net_link->init_net_ptr(this);
+    }
 }
 
 GarnetNetwork_d::~GarnetNetwork_d()
index 5da006c4d50378374475ab8168d6753a25003243..61dfe5c52f6797e0a7709f01b4a3c6dd44469c2c 100644 (file)
@@ -65,12 +65,17 @@ class NetworkLink_d : public SimObject, public Consumer
     inline bool isReady()           { return linkBuffer->isReady(); }
     inline flit_d* peekLink()       { return linkBuffer->peekTopFlit(); }
     inline flit_d* consumeLink()    { return linkBuffer->getTopFlit(); }
+    void init_net_ptr(GarnetNetwork_d* net_ptr)
+    {
+        m_net_ptr = net_ptr;
+    }
 
   protected:
     int m_id;
     int m_latency;
-
     int channel_width;
+
+    GarnetNetwork_d *m_net_ptr;
     flitBuffer_d *linkBuffer;
     Consumer *link_consumer;
     flitBuffer_d *link_srcQueue;
index 73d60697a541931fcbbb5f33123f7cd89a8ccbf3..af163ac29b04d26aeeca04a35394efae8e8bee38 100644 (file)
@@ -245,13 +245,9 @@ NetworkLink_d::calculate_power()
         channel_width    /* channel width */,
         orion_cfg_ptr);
 
-//
-//  NOTE!  I believe this calculation will be moved to McPAT, thus this
-//  reference to the net_ptr can be removed
-//
 //    // Dynamic Power
-    double sim_cycles = 0.0;
-//         (double)(g_eventQueue_ptr->getTime() - m_net_ptr->getRubyStartTime());
+    double sim_cycles =
+        (double)(g_eventQueue_ptr->getTime() - m_net_ptr->getRubyStartTime());
 
     double Plink_dyn = orion_link_ptr->calc_dynamic_energy(channel_width/2)*
         (m_link_utilized/ sim_cycles)*freq_Hz;