ruby: simple network: store Switch* in PerfectSwitch and Throttle
authorNilay Vaish <nilay@cs.wisc.edu>
Sat, 15 Aug 2015 00:28:44 +0000 (19:28 -0500)
committerNilay Vaish <nilay@cs.wisc.edu>
Sat, 15 Aug 2015 00:28:44 +0000 (19:28 -0500)
src/mem/ruby/network/simple/PerfectSwitch.cc
src/mem/ruby/network/simple/PerfectSwitch.hh
src/mem/ruby/network/simple/Throttle.cc
src/mem/ruby/network/simple/Throttle.hh

index 9de2dc2e3fab1dcf12d95746bba05efc04e3dc79..697357ccb86c7ee2730885b82316f253b37c02b8 100644 (file)
@@ -49,9 +49,8 @@ operator<(const LinkOrder& l1, const LinkOrder& l2)
 }
 
 PerfectSwitch::PerfectSwitch(SwitchID sid, Switch *sw, uint32_t virt_nets)
-    : Consumer(sw)
+    : Consumer(sw), m_switch_id(sid), m_switch(sw)
 {
-    m_switch_id = sid;
     m_round_robin_start = 0;
     m_wakeups_wo_switch = 0;
     m_virtual_networks = virt_nets;
index bf515a77704feb40560dd0ff0bdef5779f10acfc..1cc9869642d3220908efbe1b535eae50814eca38 100644 (file)
@@ -87,7 +87,8 @@ class PerfectSwitch : public Consumer
     void operateVnet(int vnet);
     void operateMessageBuffer(MessageBuffer *b, int incoming, int vnet);
 
-    SwitchID m_switch_id;
+    const SwitchID m_switch_id;
+    Switch * const m_switch;
 
     // vector of queues from the components
     std::vector<std::vector<MessageBuffer*> > m_in;
index 785e09aa2aa8a28bd2cbdee17580072c52e2b59d..c97531e585210ae58c212279e00cde0632f42eac 100644 (file)
@@ -31,6 +31,7 @@
 #include "base/cast.hh"
 #include "base/cprintf.hh"
 #include "debug/RubyNetwork.hh"
+#include "mem/ruby/network/simple/Switch.hh"
 #include "mem/ruby/network/simple/Throttle.hh"
 #include "mem/ruby/network/MessageBuffer.hh"
 #include "mem/ruby/network/Network.hh"
@@ -48,27 +49,10 @@ static int network_message_to_size(Message* net_msg_ptr);
 
 Throttle::Throttle(int sID, RubySystem *rs, NodeID node, Cycles link_latency,
                    int link_bandwidth_multiplier, int endpoint_bandwidth,
-                   ClockedObject *em)
-    : Consumer(em), m_ruby_system(rs)
+                   Switch *em)
+    : Consumer(em), m_switch_id(sID), m_switch(em), m_node(node),
+      m_ruby_system(rs)
 {
-    init(node, link_latency, link_bandwidth_multiplier, endpoint_bandwidth);
-    m_sID = sID;
-}
-
-Throttle::Throttle(RubySystem *rs, NodeID node, Cycles link_latency,
-                   int link_bandwidth_multiplier, int endpoint_bandwidth,
-                   ClockedObject *em)
-    : Consumer(em), m_ruby_system(rs)
-{
-    init(node, link_latency, link_bandwidth_multiplier, endpoint_bandwidth);
-    m_sID = 0;
-}
-
-void
-Throttle::init(NodeID node, Cycles link_latency,
-               int link_bandwidth_multiplier, int endpoint_bandwidth)
-{
-    m_node = node;
     m_vnets = 0;
 
     assert(link_bandwidth_multiplier > 0);
@@ -98,7 +82,7 @@ Throttle::addLinks(const vector<MessageBuffer*>& in_vec,
 
         // Set consumer and description
         in_ptr->setConsumer(this);
-        string desc = "[Queue to Throttle " + to_string(m_sID) + " " +
+        string desc = "[Queue to Throttle " + to_string(m_switch_id) + " " +
             to_string(m_node) + "]";
     }
 }
index 85bf9691ad5c6521ce13bdd101f36839addc18a7..405593bb129d70a86313176faffa67f885a03bcf 100644 (file)
 #include "mem/ruby/system/System.hh"
 
 class MessageBuffer;
+class Switch;
 
 class Throttle : public Consumer
 {
   public:
     Throttle(int sID, RubySystem *rs, NodeID node, Cycles link_latency,
              int link_bandwidth_multiplier, int endpoint_bandwidth,
-             ClockedObject *em);
-    Throttle(RubySystem *rs, NodeID node, Cycles link_latency,
-             int link_bandwidth_multiplier, int endpoint_bandwidth,
-             ClockedObject *em);
+             Switch *em);
     ~Throttle() {}
 
     std::string name()
-    { return csprintf("Throttle-%i", m_sID); }
+    { return csprintf("Throttle-%i", m_switch_id); }
 
     void addLinks(const std::vector<MessageBuffer*>& in_vec,
                   const std::vector<MessageBuffer*>& out_vec);
@@ -97,8 +95,10 @@ class Throttle : public Consumer
     unsigned int m_vnets;
     std::vector<int> m_units_remaining;
 
-    int m_sID;
+    const int m_switch_id;
+    Switch *m_switch;
     NodeID m_node;
+
     int m_link_bandwidth_multiplier;
     Cycles m_link_latency;
     int m_wakeups_wo_switch;