1d0
<
30,43d28
< /*
< * Switch.cc
< *
< * Description: See Switch.hh
< *
< * $Id$
< *
< */
<
<
< #include "mem/ruby/network/simple/Switch.hh"
< #include "mem/ruby/network/simple/PerfectSwitch.hh"
< #include "mem/ruby/buffers/MessageBuffer.hh"
< #include "mem/ruby/network/simple/Throttle.hh"
45d29
< #include "mem/ruby/network/Network.hh"
46a31,35
> #include "mem/ruby/buffers/MessageBuffer.hh"
> #include "mem/ruby/network/Network.hh"
> #include "mem/ruby/network/simple/PerfectSwitch.hh"
> #include "mem/ruby/network/simple/Switch.hh"
> #include "mem/ruby/network/simple/Throttle.hh"
50,52c39,41
< m_perfect_switch_ptr = new PerfectSwitch(sid, network_ptr);
< m_switch_id = sid;
< m_throttles.setSize(0);
---
> m_perfect_switch_ptr = new PerfectSwitch(sid, network_ptr);
> m_switch_id = sid;
> m_throttles.setSize(0);
57c46
< delete m_perfect_switch_ptr;
---
> delete m_perfect_switch_ptr;
59,60c48,49
< // Delete throttles (one per output port)
< m_throttles.deletePointers();
---
> // Delete throttles (one per output port)
> m_throttles.deletePointers();
62,63c51,52
< // Delete MessageBuffers
< m_buffers_to_free.deletePointers();
---
> // Delete MessageBuffers
> m_buffers_to_free.deletePointers();
66c55,56
< void Switch::addInPort(const Vector<MessageBuffer*>& in)
---
> void
> Switch::addInPort(const Vector<MessageBuffer*>& in)
68c58
< m_perfect_switch_ptr->addInPort(in);
---
> m_perfect_switch_ptr->addInPort(in);
71c61,63
< void Switch::addOutPort(const Vector<MessageBuffer*>& out, const NetDest& routing_table_entry, int link_latency, int bw_multiplier)
---
> void
> Switch::addOutPort(const Vector<MessageBuffer*>& out,
> const NetDest& routing_table_entry, int link_latency, int bw_multiplier)
73c65
< Throttle* throttle_ptr = NULL;
---
> Throttle* throttle_ptr = NULL;
75,77c67,70
< // Create a throttle
< throttle_ptr = new Throttle(m_switch_id, m_throttles.size(), link_latency, bw_multiplier);
< m_throttles.insertAtBottom(throttle_ptr);
---
> // Create a throttle
> throttle_ptr = new Throttle(m_switch_id, m_throttles.size(), link_latency,
> bw_multiplier);
> m_throttles.insertAtBottom(throttle_ptr);
79,90c72,83
< // Create one buffer per vnet (these are intermediaryQueues)
< Vector<MessageBuffer*> intermediateBuffers;
< for (int i=0; i<out.size(); i++) {
< MessageBuffer* buffer_ptr = new MessageBuffer;
< // Make these queues ordered
< buffer_ptr->setOrdering(true);
< Network* net_ptr = RubySystem::getNetwork();
< if(net_ptr->getBufferSize() > 0) {
< buffer_ptr->setSize(net_ptr->getBufferSize());
< }
< intermediateBuffers.insertAtBottom(buffer_ptr);
< m_buffers_to_free.insertAtBottom(buffer_ptr);
---
> // Create one buffer per vnet (these are intermediaryQueues)
> Vector<MessageBuffer*> intermediateBuffers;
> for (int i = 0; i < out.size(); i++) {
> MessageBuffer* buffer_ptr = new MessageBuffer;
> // Make these queues ordered
> buffer_ptr->setOrdering(true);
> Network* net_ptr = RubySystem::getNetwork();
> if (net_ptr->getBufferSize() > 0) {
> buffer_ptr->setSize(net_ptr->getBufferSize());
> }
> intermediateBuffers.insertAtBottom(buffer_ptr);
> m_buffers_to_free.insertAtBottom(buffer_ptr);
93,94c86,87
< // Hook the queues to the PerfectSwitch
< m_perfect_switch_ptr->addOutPort(intermediateBuffers, routing_table_entry);
---
> // Hook the queues to the PerfectSwitch
> m_perfect_switch_ptr->addOutPort(intermediateBuffers, routing_table_entry);
96,98c89,90
< // Hook the queues to the Throttle
< throttle_ptr->addLinks(intermediateBuffers, out);
<
---
> // Hook the queues to the Throttle
> throttle_ptr->addLinks(intermediateBuffers, out);
101c93,94
< void Switch::clearRoutingTables()
---
> void
> Switch::clearRoutingTables()
103c96
< m_perfect_switch_ptr->clearRoutingTables();
---
> m_perfect_switch_ptr->clearRoutingTables();
106c99,100
< void Switch::clearBuffers()
---
> void
> Switch::clearBuffers()
108,111c102,106
< m_perfect_switch_ptr->clearBuffers();
< for (int i=0; i<m_throttles.size(); i++) {
< if (m_throttles[i] != NULL) {
< m_throttles[i]->clear();
---
> m_perfect_switch_ptr->clearBuffers();
> for (int i = 0; i < m_throttles.size(); i++) {
> if (m_throttles[i] != NULL) {
> m_throttles[i]->clear();
> }
113d107
< }
116c110,111
< void Switch::reconfigureOutPort(const NetDest& routing_table_entry)
---
> void
> Switch::reconfigureOutPort(const NetDest& routing_table_entry)
118c113
< m_perfect_switch_ptr->reconfigureOutPort(routing_table_entry);
---
> m_perfect_switch_ptr->reconfigureOutPort(routing_table_entry);
121c116,117
< const Throttle* Switch::getThrottle(LinkID link_number) const
---
> const Throttle*
> Switch::getThrottle(LinkID link_number) const
123,124c119,120
< assert(m_throttles[link_number] != NULL);
< return m_throttles[link_number];
---
> assert(m_throttles[link_number] != NULL);
> return m_throttles[link_number];
127c123,124
< const Vector<Throttle*>* Switch::getThrottles() const
---
> const Vector<Throttle*>*
> Switch::getThrottles() const
129c126
< return &m_throttles;
---
> return &m_throttles;
132c129,130
< void Switch::printStats(std::ostream& out) const
---
> void
> Switch::printStats(std::ostream& out) const
134c132
< using namespace std;
---
> using namespace std;
136,137c134,137
< out << "switch_" << m_switch_id << "_inlinks: " << m_perfect_switch_ptr->getInLinks() << endl;
< out << "switch_" << m_switch_id << "_outlinks: " << m_perfect_switch_ptr->getOutLinks() << endl;
---
> ccprintf(out, "switch_%d_inlinks: %d\n", m_switch_id,
> m_perfect_switch_ptr->getInLinks());
> ccprintf(out, "switch_%d_outlinks: %d\n", m_switch_id,
> m_perfect_switch_ptr->getOutLinks());
139,141c139,141
< // Average link utilizations
< double average_utilization = 0.0;
< int throttle_count = 0;
---
> // Average link utilizations
> double average_utilization = 0.0;
> int throttle_count = 0;
143,147c143,148
< for (int i=0; i<m_throttles.size(); i++) {
< Throttle* throttle_ptr = m_throttles[i];
< if (throttle_ptr != NULL) {
< average_utilization += throttle_ptr->getUtilization();
< throttle_count++;
---
> for (int i = 0; i < m_throttles.size(); i++) {
> Throttle* throttle_ptr = m_throttles[i];
> if (throttle_ptr) {
> average_utilization += throttle_ptr->getUtilization();
> throttle_count++;
> }
149,150c150,151
< }
< average_utilization = (throttle_count == 0) ? 0 : average_utilization / float(throttle_count);
---
> average_utilization =
> throttle_count == 0 ? 0 : average_utilization / throttle_count;
152,159c153,165
< // Individual link utilizations
< out << "links_utilized_percent_switch_" << m_switch_id << ": " << average_utilization << endl;
< for (int link=0; link<m_throttles.size(); link++) {
< Throttle* throttle_ptr = m_throttles[link];
< if (throttle_ptr != NULL) {
< out << " links_utilized_percent_switch_" << m_switch_id << "_link_" << link << ": "
< << throttle_ptr->getUtilization() << " bw: " << throttle_ptr->getLinkBandwidth()
< << " base_latency: " << throttle_ptr->getLatency() << endl;
---
> // Individual link utilizations
> out << "links_utilized_percent_switch_" << m_switch_id << ": "
> << average_utilization << endl;
>
> for (int link = 0; link < m_throttles.size(); link++) {
> Throttle* throttle_ptr = m_throttles[link];
> if (throttle_ptr != NULL) {
> out << " links_utilized_percent_switch_" << m_switch_id
> << "_link_" << link << ": "
> << throttle_ptr->getUtilization() << " bw: "
> << throttle_ptr->getLinkBandwidth()
> << " base_latency: " << throttle_ptr->getLatency() << endl;
> }
161,162c167
< }
< out << endl;
---
> out << endl;
164,175c169,187
< // Traffic breakdown
< for (int link=0; link<m_throttles.size(); link++) {
< Throttle* throttle_ptr = m_throttles[link];
< if (throttle_ptr != NULL) {
< const Vector<Vector<int> >& message_counts = throttle_ptr->getCounters();
< for (int int_type=0; int_type<MessageSizeType_NUM; int_type++) {
< MessageSizeType type = MessageSizeType(int_type);
< int sum = message_counts[type].sum();
< if (sum != 0) {
< out << " outgoing_messages_switch_" << m_switch_id << "_link_" << link << "_" << type
< << ": " << sum << " " << sum * (RubySystem::getNetwork()->MessageSizeType_to_int(type))
< << " " << message_counts[type] << " base_latency: " << throttle_ptr->getLatency() << endl;
---
> // Traffic breakdown
> for (int link = 0; link < m_throttles.size(); link++) {
> Throttle* throttle_ptr = m_throttles[link];
> if (!throttle_ptr)
> continue;
>
> const Vector<Vector<int> >& message_counts =
> throttle_ptr->getCounters();
> for (int int_type = 0; int_type < MessageSizeType_NUM; int_type++) {
> MessageSizeType type = MessageSizeType(int_type);
> int sum = message_counts[type].sum();
> if (sum == 0)
> continue;
>
> out << " outgoing_messages_switch_" << m_switch_id
> << "_link_" << link << "_" << type << ": " << sum << " "
> << sum * RubySystem::getNetwork()->MessageSizeType_to_int(type)
> << " " << message_counts[type] << " base_latency: "
> << throttle_ptr->getLatency() << endl;
177d188
< }
179,180c190
< }
< out << endl;
---
> out << endl;
183c193,194
< void Switch::clearStats()
---
> void
> Switch::clearStats()
185,188c196,199
< m_perfect_switch_ptr->clearStats();
< for (int i=0; i<m_throttles.size(); i++) {
< if (m_throttles[i] != NULL) {
< m_throttles[i]->clearStats();
---
> m_perfect_switch_ptr->clearStats();
> for (int i = 0; i < m_throttles.size(); i++) {
> if (m_throttles[i] != NULL)
> m_throttles[i]->clearStats();
190d200
< }
193c203,204
< void Switch::printConfig(std::ostream& out) const
---
> void
> Switch::printConfig(std::ostream& out) const
195,198c206,209
< m_perfect_switch_ptr->printConfig(out);
< for (int i=0; i<m_throttles.size(); i++) {
< if (m_throttles[i] != NULL) {
< m_throttles[i]->printConfig(out);
---
> m_perfect_switch_ptr->printConfig(out);
> for (int i = 0; i < m_throttles.size(); i++) {
> if (m_throttles[i] != NULL)
> m_throttles[i]->printConfig(out);
200d210
< }
203c213,214
< void Switch::print(std::ostream& out) const
---
> void
> Switch::print(std::ostream& out) const
205,206c216,217
< // FIXME printing
< out << "[Switch]";
---
> // FIXME printing
> out << "[Switch]";