From 1f82eb1a03ede681eae258f1de16586e0cd9d5bd Mon Sep 17 00:00:00 2001 From: Brad Beckmann Date: Fri, 20 Aug 2010 11:46:12 -0700 Subject: ruby: Added consolidated network msg stats --- src/mem/ruby/network/simple/SimpleNetwork.cc | 58 ++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'src/mem') diff --git a/src/mem/ruby/network/simple/SimpleNetwork.cc b/src/mem/ruby/network/simple/SimpleNetwork.cc index 3e9056437..956b85f1d 100644 --- a/src/mem/ruby/network/simple/SimpleNetwork.cc +++ b/src/mem/ruby/network/simple/SimpleNetwork.cc @@ -26,6 +26,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include + #include "base/stl_helpers.hh" #include "mem/protocol/MachineType.hh" #include "mem/protocol/Protocol.hh" @@ -34,6 +36,7 @@ #include "mem/ruby/common/NetDest.hh" #include "mem/ruby/network/simple/SimpleNetwork.hh" #include "mem/ruby/network/simple/Switch.hh" +#include "mem/ruby/network/simple/Throttle.hh" #include "mem/ruby/network/simple/Topology.hh" #include "mem/ruby/profiler/Profiler.hh" #include "mem/ruby/system/System.hh" @@ -234,6 +237,61 @@ SimpleNetwork::printStats(ostream& out) const out << "Network Stats" << endl; out << "-------------" << endl; out << endl; + + // + // Determine total counts before printing out each switch's stats + // + std::vector total_msg_counts; + total_msg_counts.resize(MessageSizeType_NUM); + for (MessageSizeType type = MessageSizeType_FIRST; + type < MessageSizeType_NUM; + ++type) { + total_msg_counts[type] = 0; + } + + for (int i = 0; i < m_switch_ptr_vector.size(); i++) { + const std::vector* throttles = + m_switch_ptr_vector[i]->getThrottles(); + + for (int p = 0; p < throttles->size(); p++) { + + const std::vector >& message_counts = + ((*throttles)[p])->getCounters(); + + for (MessageSizeType type = MessageSizeType_FIRST; + type < MessageSizeType_NUM; + ++type) { + + const std::vector &mct = message_counts[type]; + int sum = accumulate(mct.begin(), mct.end(), 0); + total_msg_counts[type] += uint64(sum); + } + } + } + uint64 total_msgs = 0; + uint64 total_bytes = 0; + for (MessageSizeType type = MessageSizeType_FIRST; + type < MessageSizeType_NUM; + ++type) { + + 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)) + << endl; + + total_msgs += total_msg_counts[type]; + + total_bytes += total_msg_counts[type] * + uint64(RubySystem::getNetwork()->MessageSizeType_to_int(type)); + + } + } + + out << "total_msgs: " << total_msgs + << " total_bytes: " << total_bytes << endl; + + out << endl; for (int i = 0; i < m_switch_ptr_vector.size(); i++) { m_switch_ptr_vector[i]->printStats(out); } -- cgit v1.2.3