summaryrefslogtreecommitdiff
path: root/src/mem/ruby/network/simple
diff options
context:
space:
mode:
authorNilay Vaish <nilay@cs.wisc.edu>2013-09-06 16:21:35 -0500
committerNilay Vaish <nilay@cs.wisc.edu>2013-09-06 16:21:35 -0500
commit90bfbd9793e64b29d09f4ca4ee610ee08f82ea75 (patch)
treee14b49f9632b25cde8a32b5e5787a36a376e6dff /src/mem/ruby/network/simple
parente9ae8b7d29e83fa2cad55006d2c6dc58115965cc (diff)
downloadgem5-90bfbd9793e64b29d09f4ca4ee610ee08f82ea75.tar.xz
ruby: network: convert to gem5 style stats
Diffstat (limited to 'src/mem/ruby/network/simple')
-rw-r--r--src/mem/ruby/network/simple/PerfectSwitch.cc35
-rw-r--r--src/mem/ruby/network/simple/PerfectSwitch.hh7
-rw-r--r--src/mem/ruby/network/simple/SimpleNetwork.cc87
-rw-r--r--src/mem/ruby/network/simple/SimpleNetwork.hh10
-rw-r--r--src/mem/ruby/network/simple/Switch.cc120
-rw-r--r--src/mem/ruby/network/simple/Switch.hh16
-rw-r--r--src/mem/ruby/network/simple/Throttle.cc65
-rw-r--r--src/mem/ruby/network/simple/Throttle.hh35
8 files changed, 134 insertions, 241 deletions
diff --git a/src/mem/ruby/network/simple/PerfectSwitch.cc b/src/mem/ruby/network/simple/PerfectSwitch.cc
index ecfe12f15..d2f05e1b0 100644
--- a/src/mem/ruby/network/simple/PerfectSwitch.cc
+++ b/src/mem/ruby/network/simple/PerfectSwitch.cc
@@ -102,34 +102,6 @@ PerfectSwitch::addOutPort(const vector<MessageBuffer*>& out,
m_routing_table.push_back(routing_table_entry);
}
-void
-PerfectSwitch::clearRoutingTables()
-{
- m_routing_table.clear();
-}
-
-void
-PerfectSwitch::clearBuffers()
-{
- for (int i = 0; i < m_in.size(); i++){
- for(int vnet = 0; vnet < m_virtual_networks; vnet++) {
- m_in[i][vnet]->clear();
- }
- }
-
- for (int i = 0; i < m_out.size(); i++){
- for(int vnet = 0; vnet < m_virtual_networks; vnet++) {
- m_out[i][vnet]->clear();
- }
- }
-}
-
-void
-PerfectSwitch::reconfigureOutPort(const NetDest& routing_table_entry)
-{
- m_routing_table.push_back(routing_table_entry);
-}
-
PerfectSwitch::~PerfectSwitch()
{
}
@@ -329,16 +301,15 @@ PerfectSwitch::storeEventInfo(int info)
}
void
-PerfectSwitch::printStats(std::ostream& out) const
+PerfectSwitch::clearStats()
{
- out << "PerfectSwitch printStats" << endl;
}
-
void
-PerfectSwitch::clearStats()
+PerfectSwitch::collateStats()
{
}
+
void
PerfectSwitch::print(std::ostream& out) const
{
diff --git a/src/mem/ruby/network/simple/PerfectSwitch.hh b/src/mem/ruby/network/simple/PerfectSwitch.hh
index 2f914f39b..c01c50a3b 100644
--- a/src/mem/ruby/network/simple/PerfectSwitch.hh
+++ b/src/mem/ruby/network/simple/PerfectSwitch.hh
@@ -67,18 +67,15 @@ class PerfectSwitch : public Consumer
void init(SimpleNetwork *);
void addInPort(const std::vector<MessageBuffer*>& in);
void addOutPort(const std::vector<MessageBuffer*>& out,
- const NetDest& routing_table_entry);
- void clearRoutingTables();
- void clearBuffers();
- void reconfigureOutPort(const NetDest& routing_table_entry);
+ const NetDest& routing_table_entry);
int getInLinks() const { return m_in.size(); }
int getOutLinks() const { return m_out.size(); }
void wakeup();
void storeEventInfo(int info);
- void printStats(std::ostream& out) const;
void clearStats();
+ void collateStats();
void print(std::ostream& out) const;
private:
diff --git a/src/mem/ruby/network/simple/SimpleNetwork.cc b/src/mem/ruby/network/simple/SimpleNetwork.cc
index b71631d26..41f587d47 100644
--- a/src/mem/ruby/network/simple/SimpleNetwork.cc
+++ b/src/mem/ruby/network/simple/SimpleNetwork.cc
@@ -206,76 +206,39 @@ SimpleNetwork::getThrottles(NodeID id) const
}
void
-SimpleNetwork::printStats(ostream& out) const
+SimpleNetwork::regStats()
{
- out << endl;
- out << "Network Stats" << endl;
- out << "-------------" << endl;
- out << endl;
-
- //
- // Determine total counts before printing out each switch's stats
- //
- std::vector<uint64> 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_switches.size(); i++) {
- const std::vector<Throttle*>* throttles =
- m_switches[i]->getThrottles();
-
- for (int p = 0; p < throttles->size(); p++) {
-
- const std::vector<std::vector<int> >& message_counts =
- ((*throttles)[p])->getCounters();
-
- for (MessageSizeType type = MessageSizeType_FIRST;
- type < MessageSizeType_NUM;
- ++type) {
-
- const std::vector<int> &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(MessageSizeType_to_int(type))
- << endl;
-
- total_msgs += total_msg_counts[type];
-
- total_bytes += total_msg_counts[type] *
- uint64(MessageSizeType_to_int(type));
+ m_msg_counts.resize(MessageSizeType_NUM);
+ m_msg_bytes.resize(MessageSizeType_NUM);
+
+ for (MessageSizeType type = MessageSizeType_FIRST;
+ type < MessageSizeType_NUM; ++type) {
+ m_msg_counts[(unsigned int) type]
+ .name(name() + ".msg_count." + MessageSizeType_to_string(type))
+ .flags(Stats::nozero)
+ ;
+ m_msg_bytes[(unsigned int) type]
+ .name(name() + ".msg_byte." + MessageSizeType_to_string(type))
+ .flags(Stats::nozero)
+ ;
+
+ // Now state what the formula is.
+ for (int i = 0; i < m_switches.size(); i++) {
+ m_msg_counts[(unsigned int) type] +=
+ sum(m_switches[i]->getMsgCount(type));
}
- }
-
- out << "total_msgs: " << total_msgs
- << " total_bytes: " << total_bytes << endl;
-
- out << endl;
- for (int i = 0; i < m_switches.size(); i++) {
- m_switches[i]->printStats(out);
+
+ m_msg_bytes[(unsigned int) type] =
+ m_msg_counts[(unsigned int) type] * Stats::constant(
+ Network::MessageSizeType_to_int(type));
}
}
void
-SimpleNetwork::clearStats()
+SimpleNetwork::collateStats()
{
for (int i = 0; i < m_switches.size(); i++) {
- m_switches[i]->clearStats();
+ m_switches[i]->collateStats();
}
}
diff --git a/src/mem/ruby/network/simple/SimpleNetwork.hh b/src/mem/ruby/network/simple/SimpleNetwork.hh
index e720d8445..06db20c0b 100644
--- a/src/mem/ruby/network/simple/SimpleNetwork.hh
+++ b/src/mem/ruby/network/simple/SimpleNetwork.hh
@@ -56,8 +56,8 @@ class SimpleNetwork : public Network
int getEndpointBandwidth() { return m_endpoint_bandwidth; }
bool getAdaptiveRouting() {return m_adaptive_routing; }
- void printStats(std::ostream& out) const;
- void clearStats();
+ void collateStats();
+ void regStats();
// returns the queue requested for the given component
MessageBuffer* getToNetQueue(NodeID id, bool ordered, int network_num, std::string vnet_type);
@@ -90,9 +90,7 @@ class SimpleNetwork : public Network
void addLink(SwitchID src, SwitchID dest, int link_latency);
void makeLink(SwitchID src, SwitchID dest,
const NetDest& routing_table_entry, int link_latency);
- SwitchID createSwitch();
void makeTopology();
- void linkTopology();
// Private copy constructor and assignment operator
SimpleNetwork(const SimpleNetwork& obj);
@@ -111,6 +109,10 @@ class SimpleNetwork : public Network
int m_buffer_size;
int m_endpoint_bandwidth;
bool m_adaptive_routing;
+
+ //Statistical variables
+ std::vector<Stats::Formula> m_msg_counts;
+ std::vector<Stats::Formula> m_msg_bytes;
};
inline std::ostream&
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();
}
}
diff --git a/src/mem/ruby/network/simple/Switch.hh b/src/mem/ruby/network/simple/Switch.hh
index f60a31ab3..47f4c0858 100644
--- a/src/mem/ruby/network/simple/Switch.hh
+++ b/src/mem/ruby/network/simple/Switch.hh
@@ -67,12 +67,13 @@ class Switch : public BasicRouter
int bw_multiplier);
const Throttle* getThrottle(LinkID link_number) const;
const std::vector<Throttle*>* getThrottles() const;
- void clearRoutingTables();
- void clearBuffers();
- void reconfigureOutPort(const NetDest& routing_table_entry);
- void printStats(std::ostream& out) const;
- void clearStats();
+ void resetStats();
+ void collateStats();
+ void regStats();
+ const Stats::Formula & getMsgCount(unsigned int type) const
+ { return m_msg_counts[type]; }
+
void print(std::ostream& out) const;
void init_net_ptr(SimpleNetwork* net_ptr) { m_network_ptr = net_ptr; }
@@ -88,6 +89,11 @@ class Switch : public BasicRouter
SimpleNetwork* m_network_ptr;
std::vector<Throttle*> m_throttles;
std::vector<MessageBuffer*> m_buffers_to_free;
+
+ // Statistical variables
+ Stats::Formula m_avg_utilization;
+ std::vector<Stats::Formula> m_msg_counts;
+ std::vector<Stats::Formula> m_msg_bytes;
};
inline std::ostream&
diff --git a/src/mem/ruby/network/simple/Throttle.cc b/src/mem/ruby/network/simple/Throttle.cc
index 88abe4167..4a5616153 100644
--- a/src/mem/ruby/network/simple/Throttle.cc
+++ b/src/mem/ruby/network/simple/Throttle.cc
@@ -79,16 +79,11 @@ Throttle::init(NodeID node, Cycles link_latency,
m_endpoint_bandwidth = endpoint_bandwidth;
m_wakeups_wo_switch = 0;
- clearStats();
-}
-void
-Throttle::clear()
-{
- for (int counter = 0; counter < m_vnets; counter++) {
- m_in[counter]->clear();
- m_out[counter]->clear();
- }
+ m_msg_counts.resize(MessageSizeType_NUM);
+ m_msg_bytes.resize(MessageSizeType_NUM);
+
+ m_link_utilization_proxy = 0;
}
void
@@ -99,14 +94,6 @@ Throttle::addLinks(const std::vector<MessageBuffer*>& in_vec,
for (int i=0; i<in_vec.size(); i++) {
addVirtualNetwork(in_vec[i], out_vec[i]);
}
-
- m_message_counters.resize(MessageSizeType_NUM);
- for (int i = 0; i < MessageSizeType_NUM; i++) {
- m_message_counters[i].resize(in_vec.size());
- for (int j = 0; j<m_message_counters[i].size(); j++) {
- m_message_counters[i][j] = 0;
- }
- }
}
void
@@ -179,7 +166,7 @@ Throttle::wakeup()
m_in[vnet]->pop();
// Count the message
- m_message_counters[net_msg_ptr->getMessageSize()][vnet]++;
+ m_msg_counts[net_msg_ptr->getMessageSize()][vnet]++;
DPRINTF(RubyNetwork, "%s\n", *m_out[vnet]);
}
@@ -208,7 +195,7 @@ Throttle::wakeup()
double ratio = 1.0 - (double(bw_remaining) / double(getLinkBandwidth()));
// If ratio = 0, we used no bandwidth, if ratio = 1, we used all
- linkUtilized(ratio);
+ m_link_utilization_proxy += ratio;
if (bw_remaining > 0 && !schedule_wakeup) {
// We have extra bandwidth and our output buffer was
@@ -225,29 +212,41 @@ Throttle::wakeup()
}
void
-Throttle::printStats(ostream& out) const
+Throttle::regStats(string parent)
{
- out << "utilized_percent: " << getUtilization() << endl;
+ m_link_utilization
+ .name(parent + csprintf(".throttle%i", m_node) + ".link_utilization");
+
+ for (MessageSizeType type = MessageSizeType_FIRST;
+ type < MessageSizeType_NUM; ++type) {
+ m_msg_counts[(unsigned int)type]
+ .init(m_vnets)
+ .name(parent + csprintf(".throttle%i", m_node) + ".msg_count." +
+ MessageSizeType_to_string(type))
+ .flags(Stats::nozero)
+ ;
+ m_msg_bytes[(unsigned int) type]
+ .name(parent + csprintf(".throttle%i", m_node) + ".msg_bytes." +
+ MessageSizeType_to_string(type))
+ .flags(Stats::nozero)
+ ;
+
+ m_msg_bytes[(unsigned int) type] = m_msg_counts[type] * Stats::constant(
+ Network::MessageSizeType_to_int(type));
+ }
}
void
Throttle::clearStats()
{
- m_ruby_start = g_system_ptr->curCycle();
- m_links_utilized = 0.0;
-
- for (int i = 0; i < m_message_counters.size(); i++) {
- for (int j = 0; j < m_message_counters[i].size(); j++) {
- m_message_counters[i][j] = 0;
- }
- }
+ m_link_utilization_proxy = 0;
}
-double
-Throttle::getUtilization() const
+void
+Throttle::collateStats()
{
- return 100.0 * double(m_links_utilized) /
- double(g_system_ptr->curCycle()-m_ruby_start);
+ m_link_utilization = 100.0 * m_link_utilization_proxy
+ / (double(g_system_ptr->curCycle() - g_ruby_start));
}
void
diff --git a/src/mem/ruby/network/simple/Throttle.hh b/src/mem/ruby/network/simple/Throttle.hh
index 2ca474f41..b21af4d64 100644
--- a/src/mem/ruby/network/simple/Throttle.hh
+++ b/src/mem/ruby/network/simple/Throttle.hh
@@ -63,32 +63,29 @@ class Throttle : public Consumer
{ 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);
void wakeup();
- void printStats(std::ostream& out) const;
- void clearStats();
- // The average utilization (a percent) since last clearStats()
- double getUtilization() const;
+ // The average utilization (a fraction) since last clearStats()
+ const Stats::Scalar & getUtilization() const
+ { return m_link_utilization; }
+ const Stats::Vector & getMsgCount(unsigned int type) const
+ { return m_msg_counts[type]; }
+
int getLinkBandwidth() const
{ return m_endpoint_bandwidth * m_link_bandwidth_multiplier; }
Cycles getLatency() const { return m_link_latency; }
- const std::vector<std::vector<int> >&
- getCounters() const
- {
- return m_message_counters;
- }
-
- void clear();
+ void clearStats();
+ void collateStats();
+ void regStats(std::string name);
void print(std::ostream& out) const;
private:
void init(NodeID node, Cycles link_latency, int link_bandwidth_multiplier,
int endpoint_bandwidth);
void addVirtualNetwork(MessageBuffer* in_ptr, MessageBuffer* out_ptr);
- void linkUtilized(double ratio) { m_links_utilized += ratio; }
// Private copy constructor and assignment operator
Throttle(const Throttle& obj);
@@ -96,8 +93,7 @@ class Throttle : public Consumer
std::vector<MessageBuffer*> m_in;
std::vector<MessageBuffer*> m_out;
- std::vector<std::vector<int> > m_message_counters;
- int m_vnets;
+ unsigned int m_vnets;
std::vector<int> m_units_remaining;
int m_sID;
NodeID m_node;
@@ -106,9 +102,12 @@ class Throttle : public Consumer
int m_wakeups_wo_switch;
int m_endpoint_bandwidth;
- // For tracking utilization
- Cycles m_ruby_start;
- double m_links_utilized;
+ // Statistical variables
+ Stats::Scalar m_link_utilization;
+ std::vector<Stats::Vector> m_msg_counts;
+ std::vector<Stats::Formula> m_msg_bytes;
+
+ double m_link_utilization_proxy;
};
inline std::ostream&