diff options
Diffstat (limited to 'src/mem/ruby/network/simple/Switch.cc')
-rw-r--r-- | src/mem/ruby/network/simple/Switch.cc | 120 |
1 files changed, 38 insertions, 82 deletions
diff --git a/src/mem/ruby/network/simple/Switch.cc b/src/mem/ruby/network/simple/Switch.cc index b90b6eac0..c28bbdd86 100644 --- a/src/mem/ruby/network/simple/Switch.cc +++ b/src/mem/ruby/network/simple/Switch.cc @@ -44,6 +44,8 @@ using m5::stl_helpers::operator<<; Switch::Switch(const Params *p) : BasicRouter(p) { m_perfect_switch = new PerfectSwitch(m_id, this, p->virt_nets); + m_msg_counts.resize(MessageSizeType_NUM); + m_msg_bytes.resize(MessageSizeType_NUM); } Switch::~Switch() @@ -110,29 +112,6 @@ Switch::addOutPort(const vector<MessageBuffer*>& out, throttle_ptr->addLinks(intermediateBuffers, out); } -void -Switch::clearRoutingTables() -{ - m_perfect_switch->clearRoutingTables(); -} - -void -Switch::clearBuffers() -{ - m_perfect_switch->clearBuffers(); - for (int i = 0; i < m_throttles.size(); i++) { - if (m_throttles[i] != NULL) { - m_throttles[i]->clear(); - } - } -} - -void -Switch::reconfigureOutPort(const NetDest& routing_table_entry) -{ - m_perfect_switch->reconfigureOutPort(routing_table_entry); -} - const Throttle* Switch::getThrottle(LinkID link_number) const { @@ -147,77 +126,54 @@ Switch::getThrottles() const } void -Switch::printStats(std::ostream& out) const +Switch::regStats() { - ccprintf(out, "switch_%d_inlinks: %d\n", m_id, - m_perfect_switch->getInLinks()); - ccprintf(out, "switch_%d_outlinks: %d\n", m_id, - m_perfect_switch->getOutLinks()); - - // Average link utilizations - double average_utilization = 0.0; - int throttle_count = 0; - - 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++; - } - } - average_utilization = - throttle_count == 0 ? 0 : average_utilization / throttle_count; - - // Individual link utilizations - out << "links_utilized_percent_switch_" << m_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_id - << "_link_" << link << ": " - << throttle_ptr->getUtilization() << " bw: " - << throttle_ptr->getLinkBandwidth() - << " base_latency: " << throttle_ptr->getLatency() << endl; - } + m_throttles[link]->regStats(name()); } - out << 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); - const vector<int> &mct = message_counts[type]; - int sum = accumulate(mct.begin(), mct.end(), 0); - if (sum == 0) - continue; - - out << " outgoing_messages_switch_" << m_id - << "_link_" << link << "_" << type << ": " << sum << " " - << sum * m_network_ptr->MessageSizeType_to_int(type) - << " "; - out << mct; - out << " base_latency: " - << throttle_ptr->getLatency() << endl; + m_avg_utilization.name(name() + ".percent_links_utilized"); + for (unsigned int i = 0; i < m_throttles.size(); i++) { + m_avg_utilization += m_throttles[i]->getUtilization(); + } + m_avg_utilization /= Stats::constant(m_throttles.size()); + + for (unsigned int type = MessageSizeType_FIRST; + type < MessageSizeType_NUM; ++type) { + m_msg_counts[type] + .name(name() + ".msg_count." + + MessageSizeType_to_string(MessageSizeType(type))) + .flags(Stats::nozero) + ; + m_msg_bytes[type] + .name(name() + ".msg_bytes." + + MessageSizeType_to_string(MessageSizeType(type))) + .flags(Stats::nozero) + ; + + for (unsigned int i = 0; i < m_throttles.size(); i++) { + m_msg_counts[type] += m_throttles[i]->getMsgCount(type); } + m_msg_bytes[type] = m_msg_counts[type] * Stats::constant( + Network::MessageSizeType_to_int(MessageSizeType(type))); } - out << endl; } void -Switch::clearStats() +Switch::resetStats() { m_perfect_switch->clearStats(); for (int i = 0; i < m_throttles.size(); i++) { - if (m_throttles[i] != NULL) - m_throttles[i]->clearStats(); + m_throttles[i]->clearStats(); + } +} + +void +Switch::collateStats() +{ + m_perfect_switch->collateStats(); + for (int i = 0; i < m_throttles.size(); i++) { + m_throttles[i]->collateStats(); } } |