diff options
author | Nilay Vaish <nilay@cs.wisc.edu> | 2013-01-14 10:04:21 -0600 |
---|---|---|
committer | Nilay Vaish <nilay@cs.wisc.edu> | 2013-01-14 10:04:21 -0600 |
commit | cf232de4615f0fe9435d6e92a1d6319c972a8c88 (patch) | |
tree | 539c365baf0b078b2fdbf820feeb89c1afee8726 /src/mem/ruby/network/simple | |
parent | cbbc4c7f6b4cb718cc3907b955f7ae527d2d0274 (diff) | |
download | gem5-cf232de4615f0fe9435d6e92a1d6319c972a8c88.tar.xz |
Ruby: use ClockedObject in Consumer class
Many Ruby structures inherit from the Consumer, which is used for scheduling
events. The Consumer used to relay on an Event Manager for scheduling events
and on g_system_ptr for time. With this patch, the Consumer will now use a
ClockedObject to schedule events and to query for current time. This resulted
in several structures being converted from SimObjects to ClockedObjects. Also,
the MessageBuffer class now requires a pointer to a ClockedObject so as to
query for time.
Diffstat (limited to 'src/mem/ruby/network/simple')
-rw-r--r-- | src/mem/ruby/network/simple/PerfectSwitch.cc | 4 | ||||
-rw-r--r-- | src/mem/ruby/network/simple/PerfectSwitch.hh | 2 | ||||
-rw-r--r-- | src/mem/ruby/network/simple/Switch.cc | 4 | ||||
-rw-r--r-- | src/mem/ruby/network/simple/Throttle.cc | 13 | ||||
-rw-r--r-- | src/mem/ruby/network/simple/Throttle.hh | 9 |
5 files changed, 19 insertions, 13 deletions
diff --git a/src/mem/ruby/network/simple/PerfectSwitch.cc b/src/mem/ruby/network/simple/PerfectSwitch.cc index b38b6d539..37035f95f 100644 --- a/src/mem/ruby/network/simple/PerfectSwitch.cc +++ b/src/mem/ruby/network/simple/PerfectSwitch.cc @@ -68,7 +68,7 @@ PerfectSwitch::init(SimpleNetwork *network_ptr) } void -PerfectSwitch::addInPort(const vector<MessageBuffer*>& in) +PerfectSwitch::addInPort(const vector<MessageBuffer*>& in, Switch *sw) { assert(in.size() == m_virtual_networks); NodeID port = m_in.size(); @@ -76,6 +76,8 @@ PerfectSwitch::addInPort(const vector<MessageBuffer*>& in) for (int j = 0; j < m_virtual_networks; j++) { m_in[port][j]->setConsumer(this); + m_in[port][j]->setClockObj(sw); + string desc = csprintf("[Queue from port %s %s %s to PerfectSwitch]", to_string(m_switch_id), to_string(port), to_string(j)); m_in[port][j]->setDescription(desc); diff --git a/src/mem/ruby/network/simple/PerfectSwitch.hh b/src/mem/ruby/network/simple/PerfectSwitch.hh index 695c848bc..ffd1f84ba 100644 --- a/src/mem/ruby/network/simple/PerfectSwitch.hh +++ b/src/mem/ruby/network/simple/PerfectSwitch.hh @@ -63,7 +63,7 @@ class PerfectSwitch : public Consumer { return csprintf("PerfectSwitch-%i", m_switch_id); } void init(SimpleNetwork *); - void addInPort(const std::vector<MessageBuffer*>& in); + void addInPort(const std::vector<MessageBuffer*>& in, Switch *); void addOutPort(const std::vector<MessageBuffer*>& out, const NetDest& routing_table_entry); void clearRoutingTables(); diff --git a/src/mem/ruby/network/simple/Switch.cc b/src/mem/ruby/network/simple/Switch.cc index 1bb944f91..d9abc4cc7 100644 --- a/src/mem/ruby/network/simple/Switch.cc +++ b/src/mem/ruby/network/simple/Switch.cc @@ -67,7 +67,7 @@ Switch::init() void Switch::addInPort(const vector<MessageBuffer*>& in) { - m_perfect_switch_ptr->addInPort(in); + m_perfect_switch_ptr->addInPort(in, this); } void @@ -97,7 +97,7 @@ Switch::addOutPort(const vector<MessageBuffer*>& out, m_perfect_switch_ptr->addOutPort(intermediateBuffers, routing_table_entry); // Hook the queues to the Throttle - throttle_ptr->addLinks(intermediateBuffers, out); + throttle_ptr->addLinks(intermediateBuffers, out, this); } void diff --git a/src/mem/ruby/network/simple/Throttle.cc b/src/mem/ruby/network/simple/Throttle.cc index 653791c29..b591cc81b 100644 --- a/src/mem/ruby/network/simple/Throttle.cc +++ b/src/mem/ruby/network/simple/Throttle.cc @@ -50,7 +50,7 @@ static int network_message_to_size(NetworkMessage* net_msg_ptr); Throttle::Throttle(int sID, NodeID node, int link_latency, int link_bandwidth_multiplier, int endpoint_bandwidth, - EventManager *em) + ClockedObject *em) : Consumer(em) { init(node, link_latency, link_bandwidth_multiplier, endpoint_bandwidth); @@ -59,7 +59,7 @@ Throttle::Throttle(int sID, NodeID node, int link_latency, Throttle::Throttle(NodeID node, int link_latency, int link_bandwidth_multiplier, int endpoint_bandwidth, - EventManager *em) + ClockedObject *em) : Consumer(em) { init(node, link_latency, link_bandwidth_multiplier, endpoint_bandwidth); @@ -93,11 +93,11 @@ Throttle::clear() void Throttle::addLinks(const std::vector<MessageBuffer*>& in_vec, - const std::vector<MessageBuffer*>& out_vec) + const std::vector<MessageBuffer*>& out_vec, ClockedObject *em) { assert(in_vec.size() == out_vec.size()); for (int i=0; i<in_vec.size(); i++) { - addVirtualNetwork(in_vec[i], out_vec[i]); + addVirtualNetwork(in_vec[i], out_vec[i], em); } m_message_counters.resize(MessageSizeType_NUM); @@ -110,7 +110,8 @@ Throttle::addLinks(const std::vector<MessageBuffer*>& in_vec, } void -Throttle::addVirtualNetwork(MessageBuffer* in_ptr, MessageBuffer* out_ptr) +Throttle::addVirtualNetwork(MessageBuffer* in_ptr, MessageBuffer* out_ptr, + ClockedObject *em) { m_units_remaining.push_back(0); m_in.push_back(in_ptr); @@ -118,6 +119,8 @@ Throttle::addVirtualNetwork(MessageBuffer* in_ptr, MessageBuffer* out_ptr) // Set consumer and description m_in[m_vnets]->setConsumer(this); + m_in[m_vnets]->setClockObj(em); + string desc = "[Queue to Throttle " + to_string(m_sID) + " " + to_string(m_node) + "]"; m_in[m_vnets]->setDescription(desc); diff --git a/src/mem/ruby/network/simple/Throttle.hh b/src/mem/ruby/network/simple/Throttle.hh index b86a247d2..077382041 100644 --- a/src/mem/ruby/network/simple/Throttle.hh +++ b/src/mem/ruby/network/simple/Throttle.hh @@ -54,16 +54,16 @@ class Throttle : public Consumer public: Throttle(int sID, NodeID node, int link_latency, int link_bandwidth_multiplier, int endpoint_bandwidth, - EventManager *em); + ClockedObject *em); Throttle(NodeID node, int link_latency, int link_bandwidth_multiplier, - int endpoint_bandwidth, EventManager *em); + int endpoint_bandwidth, ClockedObject *em); ~Throttle() {} std::string name() { return csprintf("Throttle-%i", m_sID); } void addLinks(const std::vector<MessageBuffer*>& in_vec, - const std::vector<MessageBuffer*>& out_vec); + const std::vector<MessageBuffer*>& out_vec, ClockedObject *em); void wakeup(); void printStats(std::ostream& out) const; @@ -90,7 +90,8 @@ class Throttle : public Consumer private: void init(NodeID node, int link_latency, int link_bandwidth_multiplier, int endpoint_bandwidth); - void addVirtualNetwork(MessageBuffer* in_ptr, MessageBuffer* out_ptr); + void addVirtualNetwork(MessageBuffer* in_ptr, MessageBuffer* out_ptr, + ClockedObject *em); void linkUtilized(double ratio) { m_links_utilized += ratio; } // Private copy constructor and assignment operator |