changeset ba635023d4bb in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=ba635023d4bb
description:
        ruby: changes to simple network
        This patch makes the Switch structure inherit from BasicRouter, as is
        done in two other networks.

diffstat:

 configs/ruby/Ruby.py                                          |   2 +-
 src/mem/ruby/network/BasicRouter.hh                           |   2 +-
 src/mem/ruby/network/Topology.cc                              |   3 -
 src/mem/ruby/network/Topology.hh                              |   1 +
 src/mem/ruby/network/garnet/flexible-pipeline/GarnetRouter.py |   2 -
 src/mem/ruby/network/garnet/flexible-pipeline/Router.cc       |   1 -
 src/mem/ruby/network/garnet/flexible-pipeline/Router.hh       |   1 -
 src/mem/ruby/network/simple/PerfectSwitch.cc                  |  16 ++-
 src/mem/ruby/network/simple/PerfectSwitch.hh                  |   9 +-
 src/mem/ruby/network/simple/SimpleNetwork.cc                  |  21 ++--
 src/mem/ruby/network/simple/SimpleNetwork.py                  |   8 +
 src/mem/ruby/network/simple/Switch.cc                         |  46 ++++++----
 src/mem/ruby/network/simple/Switch.hh                         |  11 +-
 13 files changed, 74 insertions(+), 49 deletions(-)

diffs (truncated from 400 to 300 lines):

diff -r 05b12cb19cc8 -r ba635023d4bb configs/ruby/Ruby.py
--- a/configs/ruby/Ruby.py      Tue Oct 02 14:35:44 2012 -0500
+++ b/configs/ruby/Ruby.py      Tue Oct 02 14:35:45 2012 -0500
@@ -135,7 +135,7 @@
         class NetworkClass(SimpleNetwork): pass
         class IntLinkClass(SimpleIntLink): pass
         class ExtLinkClass(SimpleExtLink): pass
-        class RouterClass(BasicRouter): pass
+        class RouterClass(Switch): pass
 
     #
     # Important: the topology must be instantiated before the network and after
diff -r 05b12cb19cc8 -r ba635023d4bb src/mem/ruby/network/BasicRouter.hh
--- a/src/mem/ruby/network/BasicRouter.hh       Tue Oct 02 14:35:44 2012 -0500
+++ b/src/mem/ruby/network/BasicRouter.hh       Tue Oct 02 14:35:45 2012 -0500
@@ -53,7 +53,7 @@
     //
     // ID in relation to other routers in the system
     //
-    int m_id;
+    uint32_t m_id;
 };
 
 inline std::ostream&
diff -r 05b12cb19cc8 -r ba635023d4bb src/mem/ruby/network/Topology.cc
--- a/src/mem/ruby/network/Topology.cc  Tue Oct 02 14:35:44 2012 -0500
+++ b/src/mem/ruby/network/Topology.cc  Tue Oct 02 14:35:45 2012 -0500
@@ -32,7 +32,6 @@
 #include "mem/protocol/MachineType.hh"
 #include "mem/ruby/common/NetDest.hh"
 #include "mem/ruby/network/BasicLink.hh"
-#include "mem/ruby/network/BasicRouter.hh"
 #include "mem/ruby/network/Network.hh"
 #include "mem/ruby/network/Topology.hh"
 #include "mem/ruby/slicc_interface/AbstractController.hh"
@@ -41,8 +40,6 @@
 
 const int INFINITE_LATENCY = 10000; // Yes, this is a big hack
 
-class BasicRouter;
-
 // Note: In this file, we use the first 2*m_nodes SwitchIDs to
 // represent the input and output endpoint links.  These really are
 // not 'switches', as they will not have a Switch object allocated for
diff -r 05b12cb19cc8 -r ba635023d4bb src/mem/ruby/network/Topology.hh
--- a/src/mem/ruby/network/Topology.hh  Tue Oct 02 14:35:44 2012 -0500
+++ b/src/mem/ruby/network/Topology.hh  Tue Oct 02 14:35:45 2012 -0500
@@ -46,6 +46,7 @@
 
 #include "mem/protocol/LinkDirection.hh"
 #include "mem/ruby/common/TypeDefines.hh"
+#include "mem/ruby/network/BasicRouter.hh"
 #include "params/Topology.hh"
 #include "sim/sim_object.hh"
 
diff -r 05b12cb19cc8 -r ba635023d4bb 
src/mem/ruby/network/garnet/flexible-pipeline/GarnetRouter.py
--- a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetRouter.py     Tue Oct 
02 14:35:44 2012 -0500
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetRouter.py     Tue Oct 
02 14:35:45 2012 -0500
@@ -39,5 +39,3 @@
                               "virtual channels per virtual network")
     virt_nets = Param.Int(Parent.number_of_virtual_networks,
                           "number of virtual networks")
-
-
diff -r 05b12cb19cc8 -r ba635023d4bb 
src/mem/ruby/network/garnet/flexible-pipeline/Router.cc
--- a/src/mem/ruby/network/garnet/flexible-pipeline/Router.cc   Tue Oct 02 
14:35:44 2012 -0500
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/Router.cc   Tue Oct 02 
14:35:45 2012 -0500
@@ -43,7 +43,6 @@
 Router::Router(const Params *p)
     : BasicRouter(p), FlexibleConsumer(this)
 {
-    m_id = p->router_id;
     m_virtual_networks = p->virt_nets;
     m_vc_per_vnet = p->vcs_per_vnet;
     m_round_robin_inport = 0;
diff -r 05b12cb19cc8 -r ba635023d4bb 
src/mem/ruby/network/garnet/flexible-pipeline/Router.hh
--- a/src/mem/ruby/network/garnet/flexible-pipeline/Router.hh   Tue Oct 02 
14:35:44 2012 -0500
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/Router.hh   Tue Oct 02 
14:35:45 2012 -0500
@@ -75,7 +75,6 @@
     }
 
   private:
-    int m_id;
     int m_virtual_networks, m_num_vcs, m_vc_per_vnet;
     GarnetNetwork *m_net_ptr;
     std::vector<int> m_vc_round_robin; // For scheduling of out source queues
diff -r 05b12cb19cc8 -r ba635023d4bb 
src/mem/ruby/network/simple/PerfectSwitch.cc
--- a/src/mem/ruby/network/simple/PerfectSwitch.cc      Tue Oct 02 14:35:44 
2012 -0500
+++ b/src/mem/ruby/network/simple/PerfectSwitch.cc      Tue Oct 02 14:35:45 
2012 -0500
@@ -33,9 +33,8 @@
 #include "mem/ruby/buffers/MessageBuffer.hh"
 #include "mem/ruby/network/simple/PerfectSwitch.hh"
 #include "mem/ruby/network/simple/SimpleNetwork.hh"
-#include "mem/ruby/profiler/Profiler.hh"
+#include "mem/ruby/network/simple/Switch.hh"
 #include "mem/ruby/slicc_interface/NetworkMessage.hh"
-#include "mem/ruby/system/System.hh"
 
 using namespace std;
 
@@ -48,14 +47,19 @@
     return (l1.m_value < l2.m_value);
 }
 
-PerfectSwitch::PerfectSwitch(SwitchID sid, SimpleNetwork* network_ptr)
-    : Consumer(network_ptr)
+PerfectSwitch::PerfectSwitch(SwitchID sid, Switch *sw, uint32_t virt_nets)
+    : Consumer(sw)
 {
-    m_virtual_networks = network_ptr->getNumberOfVirtualNetworks();
     m_switch_id = sid;
     m_round_robin_start = 0;
+    m_wakeups_wo_switch = 0;
+    m_virtual_networks = virt_nets;
+}
+
+void
+PerfectSwitch::init(SimpleNetwork *network_ptr)
+{
     m_network_ptr = network_ptr;
-    m_wakeups_wo_switch = 0;
 
     for(int i = 0;i < m_virtual_networks;++i)
     {
diff -r 05b12cb19cc8 -r ba635023d4bb 
src/mem/ruby/network/simple/PerfectSwitch.hh
--- a/src/mem/ruby/network/simple/PerfectSwitch.hh      Tue Oct 02 14:35:44 
2012 -0500
+++ b/src/mem/ruby/network/simple/PerfectSwitch.hh      Tue Oct 02 14:35:45 
2012 -0500
@@ -41,11 +41,11 @@
 #include <vector>
 
 #include "mem/ruby/common/Consumer.hh"
-#include "mem/ruby/common/Global.hh"
 
 class MessageBuffer;
 class NetDest;
 class SimpleNetwork;
+class Switch;
 
 struct LinkOrder
 {
@@ -56,12 +56,13 @@
 class PerfectSwitch : public Consumer
 {
   public:
-    PerfectSwitch(SwitchID sid, SimpleNetwork* network_ptr);
+    PerfectSwitch(SwitchID sid, Switch *, uint32_t);
     ~PerfectSwitch();
 
     std::string name()
     { return csprintf("PerfectSwitch-%i", m_switch_id); }
 
+    void init(SimpleNetwork *);
     void addInPort(const std::vector<MessageBuffer*>& in);
     void addOutPort(const std::vector<MessageBuffer*>& out,
         const NetDest& routing_table_entry);
@@ -90,9 +91,11 @@
     std::vector<std::vector<MessageBuffer*> > m_out;
     std::vector<NetDest> m_routing_table;
     std::vector<LinkOrder> m_link_order;
-    int m_virtual_networks;
+
+    uint32_t m_virtual_networks;
     int m_round_robin_start;
     int m_wakeups_wo_switch;
+
     SimpleNetwork* m_network_ptr;
     std::vector<int> m_pending_message_count;
 };
diff -r 05b12cb19cc8 -r ba635023d4bb 
src/mem/ruby/network/simple/SimpleNetwork.cc
--- a/src/mem/ruby/network/simple/SimpleNetwork.cc      Tue Oct 02 14:35:44 
2012 -0500
+++ b/src/mem/ruby/network/simple/SimpleNetwork.cc      Tue Oct 02 14:35:45 
2012 -0500
@@ -78,6 +78,15 @@
                 new MessageBuffer(csprintf("fromNet node %d j %d", node, j));
         }
     }
+
+    // record the routers
+    for (vector<BasicRouter*>::const_iterator i =
+             m_topology_ptr->params()->routers.begin();
+         i != m_topology_ptr->params()->routers.end(); ++i) {
+        Switch* s = safe_cast<Switch*>(*i);
+        m_switch_ptr_vector.push_back(s);
+        s->init_net_ptr(this);
+    }
 }
 
 void
@@ -88,11 +97,6 @@
     // The topology pointer should have already been initialized in
     // the parent class network constructor.
     assert(m_topology_ptr != NULL);
-    int number_of_switches = m_topology_ptr->numSwitches();
-    for (int i = 0; i < number_of_switches; i++) {
-        m_switch_ptr_vector.push_back(new Switch(i, this));
-    }
-
     // false because this isn't a reconfiguration
     m_topology_ptr->createLinks(this, false);
 }
@@ -282,15 +286,14 @@
         
         if (total_msg_counts[type] > 0) {
             out << "total_msg_count_" << type << ": " << 
total_msg_counts[type] 
-                << " " << total_msg_counts[type] * 
-                uint64(RubySystem::getNetwork()->MessageSizeType_to_int(type))
+                << " " << total_msg_counts[type] *
+                uint64(MessageSizeType_to_int(type))
                 << endl;
             
             total_msgs += total_msg_counts[type];
             
             total_bytes += total_msg_counts[type] * 
-                uint64(RubySystem::getNetwork()->MessageSizeType_to_int(type));
-            
+                uint64(MessageSizeType_to_int(type));
         }
     }
     
diff -r 05b12cb19cc8 -r ba635023d4bb 
src/mem/ruby/network/simple/SimpleNetwork.py
--- a/src/mem/ruby/network/simple/SimpleNetwork.py      Tue Oct 02 14:35:44 
2012 -0500
+++ b/src/mem/ruby/network/simple/SimpleNetwork.py      Tue Oct 02 14:35:45 
2012 -0500
@@ -28,7 +28,9 @@
 #          Brad Beckmann
 
 from m5.params import *
+from m5.proxy import *
 from Network import RubyNetwork
+from BasicRouter import BasicRouter
 
 class SimpleNetwork(RubyNetwork):
     type = 'SimpleNetwork'
@@ -36,3 +38,9 @@
         "default buffer size; 0 indicates infinite buffering");
     endpoint_bandwidth = Param.Int(1000, "bandwidth adjustment factor");
     adaptive_routing = Param.Bool(False, "enable adaptive routing");
+
+class Switch(BasicRouter):
+    type = 'Switch'
+    cxx_class = 'Switch'
+    virt_nets = Param.Int(Parent.number_of_virtual_networks,
+                          "number of virtual networks")
diff -r 05b12cb19cc8 -r ba635023d4bb src/mem/ruby/network/simple/Switch.cc
--- a/src/mem/ruby/network/simple/Switch.cc     Tue Oct 02 14:35:44 2012 -0500
+++ b/src/mem/ruby/network/simple/Switch.cc     Tue Oct 02 14:35:45 2012 -0500
@@ -41,10 +41,9 @@
 using m5::stl_helpers::deletePointers;
 using m5::stl_helpers::operator<<;
 
-Switch::Switch(SwitchID sid, SimpleNetwork* network_ptr)
+Switch::Switch(const Params *p) : BasicRouter(p)
 {
-    m_perfect_switch_ptr = new PerfectSwitch(sid, network_ptr);
-    m_switch_id = sid;
+    m_perfect_switch_ptr = new PerfectSwitch(m_id, this, p->virt_nets);
 }
 
 Switch::~Switch()
@@ -59,6 +58,13 @@
 }
 
 void
+Switch::init()
+{
+    BasicRouter::init();
+    m_perfect_switch_ptr->init(m_network_ptr);
+}
+
+void
 Switch::addInPort(const vector<MessageBuffer*>& in)
 {
     m_perfect_switch_ptr->addInPort(in);
@@ -68,14 +74,10 @@
 Switch::addOutPort(const vector<MessageBuffer*>& out,
     const NetDest& routing_table_entry, int link_latency, int bw_multiplier)
 {
-    Throttle* throttle_ptr = NULL;
-    SimpleNetwork* net_ptr = 
-        safe_cast<SimpleNetwork*>(RubySystem::getNetwork());
-
     // Create a throttle
-    throttle_ptr = new Throttle(m_switch_id, m_throttles.size(), link_latency,
-                                bw_multiplier, net_ptr->getEndpointBandwidth(),
-                                net_ptr);
+    Throttle* throttle_ptr = new Throttle(m_id, m_throttles.size(),
+        link_latency, bw_multiplier, m_network_ptr->getEndpointBandwidth(),
+        this);
     m_throttles.push_back(throttle_ptr);
 
     // Create one buffer per vnet (these are intermediaryQueues)
@@ -84,12 +86,12 @@
         MessageBuffer* buffer_ptr = new MessageBuffer;
         // Make these queues ordered
         buffer_ptr->setOrdering(true);
-        if (net_ptr->getBufferSize() > 0) {
-            buffer_ptr->resize(net_ptr->getBufferSize());
+        if (m_network_ptr->getBufferSize() > 0) {
+            buffer_ptr->resize(m_network_ptr->getBufferSize());
         }
         intermediateBuffers.push_back(buffer_ptr);
         m_buffers_to_free.push_back(buffer_ptr);
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to