SimpleNetwork.cc (9859:1bd310386038) SimpleNetwork.cc (9863:9483739f83ee)
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 192 unchanged lines hidden (view full) ---

201{
202 assert(id >= 0);
203 assert(id < m_nodes);
204 assert(m_endpoint_switches[id] != NULL);
205 return m_endpoint_switches[id]->getThrottles();
206}
207
208void
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 192 unchanged lines hidden (view full) ---

201{
202 assert(id >= 0);
203 assert(id < m_nodes);
204 assert(m_endpoint_switches[id] != NULL);
205 return m_endpoint_switches[id]->getThrottles();
206}
207
208void
209SimpleNetwork::printStats(ostream& out) const
209SimpleNetwork::regStats()
210{
210{
211 out << endl;
212 out << "Network Stats" << endl;
213 out << "-------------" << endl;
214 out << endl;
211 m_msg_counts.resize(MessageSizeType_NUM);
212 m_msg_bytes.resize(MessageSizeType_NUM);
215
213
216 //
217 // Determine total counts before printing out each switch's stats
218 //
219 std::vector<uint64> total_msg_counts;
220 total_msg_counts.resize(MessageSizeType_NUM);
221 for (MessageSizeType type = MessageSizeType_FIRST;
222 type < MessageSizeType_NUM;
223 ++type) {
224 total_msg_counts[type] = 0;
225 }
226
227 for (int i = 0; i < m_switches.size(); i++) {
228 const std::vector<Throttle*>* throttles =
229 m_switches[i]->getThrottles();
230
231 for (int p = 0; p < throttles->size(); p++) {
232
233 const std::vector<std::vector<int> >& message_counts =
234 ((*throttles)[p])->getCounters();
235
236 for (MessageSizeType type = MessageSizeType_FIRST;
237 type < MessageSizeType_NUM;
238 ++type) {
214 for (MessageSizeType type = MessageSizeType_FIRST;
215 type < MessageSizeType_NUM; ++type) {
216 m_msg_counts[(unsigned int) type]
217 .name(name() + ".msg_count." + MessageSizeType_to_string(type))
218 .flags(Stats::nozero)
219 ;
220 m_msg_bytes[(unsigned int) type]
221 .name(name() + ".msg_byte." + MessageSizeType_to_string(type))
222 .flags(Stats::nozero)
223 ;
239
224
240 const std::vector<int> &mct = message_counts[type];
241 int sum = accumulate(mct.begin(), mct.end(), 0);
242 total_msg_counts[type] += uint64(sum);
243 }
225 // Now state what the formula is.
226 for (int i = 0; i < m_switches.size(); i++) {
227 m_msg_counts[(unsigned int) type] +=
228 sum(m_switches[i]->getMsgCount(type));
244 }
229 }
230
231 m_msg_bytes[(unsigned int) type] =
232 m_msg_counts[(unsigned int) type] * Stats::constant(
233 Network::MessageSizeType_to_int(type));
245 }
234 }
246 uint64 total_msgs = 0;
247 uint64 total_bytes = 0;
248 for (MessageSizeType type = MessageSizeType_FIRST;
249 type < MessageSizeType_NUM;
250 ++type) {
251
252 if (total_msg_counts[type] > 0) {
253 out << "total_msg_count_" << type << ": " << total_msg_counts[type]
254 << " " << total_msg_counts[type] *
255 uint64(MessageSizeType_to_int(type))
256 << endl;
257
258 total_msgs += total_msg_counts[type];
259
260 total_bytes += total_msg_counts[type] *
261 uint64(MessageSizeType_to_int(type));
262 }
263 }
264
265 out << "total_msgs: " << total_msgs
266 << " total_bytes: " << total_bytes << endl;
267
268 out << endl;
269 for (int i = 0; i < m_switches.size(); i++) {
270 m_switches[i]->printStats(out);
271 }
272}
273
274void
235}
236
237void
275SimpleNetwork::clearStats()
238SimpleNetwork::collateStats()
276{
277 for (int i = 0; i < m_switches.size(); i++) {
239{
240 for (int i = 0; i < m_switches.size(); i++) {
278 m_switches[i]->clearStats();
241 m_switches[i]->collateStats();
279 }
280}
281
282void
283SimpleNetwork::print(ostream& out) const
284{
285 out << "[SimpleNetwork]";
286}

--- 44 unchanged lines hidden ---
242 }
243}
244
245void
246SimpleNetwork::print(ostream& out) const
247{
248 out << "[SimpleNetwork]";
249}

--- 44 unchanged lines hidden ---