mem-ruby: Update stats style for SimpleNetwork

Change-Id: I7d54ed02d01a3811b41dce794e308b8b77576c92
Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38055
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Hoa Nguyen
2020-11-26 05:04:45 -08:00
parent fa81ca4988
commit 0badfdb207
6 changed files with 118 additions and 61 deletions

View File

@@ -57,7 +57,8 @@ using namespace std;
SimpleNetwork::SimpleNetwork(const Params &p)
: Network(p), m_buffer_size(p.buffer_size),
m_endpoint_bandwidth(p.endpoint_bandwidth),
m_adaptive_routing(p.adaptive_routing)
m_adaptive_routing(p.adaptive_routing),
networkStats(this)
{
// record the routers
for (vector<BasicRouter*>::const_iterator i = p.routers.begin();
@@ -144,24 +145,29 @@ SimpleNetwork::regStats()
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)
networkStats.m_msg_counts[(unsigned int) type] =
new Stats::Formula(&networkStats,
csprintf("msg_count.%s", MessageSizeType_to_string(type)).c_str());
networkStats.m_msg_counts[(unsigned int) type]
->flags(Stats::nozero)
;
m_msg_bytes[(unsigned int) type]
.name(name() + ".msg_byte." + MessageSizeType_to_string(type))
.flags(Stats::nozero)
networkStats.m_msg_bytes[(unsigned int) type] =
new Stats::Formula(&networkStats,
csprintf("msg_byte.%s", MessageSizeType_to_string(type)).c_str());
networkStats.m_msg_bytes[(unsigned int) 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] +=
*(networkStats.m_msg_counts[(unsigned int) type]) +=
sum(m_switches[i]->getMsgCount(type));
}
m_msg_bytes[(unsigned int) type] =
m_msg_counts[(unsigned int) type] * Stats::constant(
Network::MessageSizeType_to_int(type));
*(networkStats.m_msg_bytes[(unsigned int) type]) =
*(networkStats.m_msg_counts[(unsigned int) type]) *
Stats::constant(Network::MessageSizeType_to_int(type));
}
}
@@ -213,3 +219,10 @@ SimpleNetwork::functionalWrite(Packet *pkt)
}
return num_functional_writes;
}
SimpleNetwork::
NetworkStats::NetworkStats(Stats::Group *parent)
: Stats::Group(parent)
{
}

View File

@@ -90,9 +90,15 @@ class SimpleNetwork : public Network
const int m_endpoint_bandwidth;
const bool m_adaptive_routing;
//Statistical variables
Stats::Formula m_msg_counts[MessageSizeType_NUM];
Stats::Formula m_msg_bytes[MessageSizeType_NUM];
struct NetworkStats : public Stats::Group
{
NetworkStats(Stats::Group *parent);
//Statistical variables
Stats::Formula* m_msg_counts[MessageSizeType_NUM];
Stats::Formula* m_msg_bytes[MessageSizeType_NUM];
} networkStats;
};
inline std::ostream&

View File

@@ -52,8 +52,9 @@ using namespace std;
using m5::stl_helpers::operator<<;
Switch::Switch(const Params &p)
: BasicRouter(p), perfectSwitch(m_id, this, p.virt_nets),
m_num_connected_buffers(0)
: BasicRouter(p),
perfectSwitch(m_id, this, p.virt_nets), m_num_connected_buffers(0),
switchStats(this)
{
m_port_buffers.reserve(p.port_buffers.size());
for (auto& buffer : p.port_buffers) {
@@ -108,32 +109,35 @@ Switch::regStats()
BasicRouter::regStats();
for (auto& throttle : throttles) {
throttle.regStats(name());
throttle.regStats();
}
m_avg_utilization.name(name() + ".percent_links_utilized");
for (const auto& throttle : throttles) {
m_avg_utilization += throttle.getUtilization();
switchStats.m_avg_utilization += throttle.getUtilization();
}
m_avg_utilization /= Stats::constant(throttles.size());
switchStats.m_avg_utilization /= Stats::constant(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)
switchStats.m_msg_counts[type] = new Stats::Formula(&switchStats,
csprintf("msg_count.%s",
MessageSizeType_to_string(MessageSizeType(type))).c_str());
switchStats.m_msg_counts[type]
->flags(Stats::nozero)
;
m_msg_bytes[type]
.name(name() + ".msg_bytes." +
MessageSizeType_to_string(MessageSizeType(type)))
.flags(Stats::nozero)
switchStats.m_msg_bytes[type] = new Stats::Formula(&switchStats,
csprintf("msg_bytes.%s",
MessageSizeType_to_string(MessageSizeType(type))).c_str());
switchStats.m_msg_bytes[type]
->flags(Stats::nozero)
;
for (const auto& throttle : throttles) {
m_msg_counts[type] += throttle.getMsgCount(type);
*(switchStats.m_msg_counts[type]) += throttle.getMsgCount(type);
}
m_msg_bytes[type] = m_msg_counts[type] * Stats::constant(
*(switchStats.m_msg_bytes[type]) =
*(switchStats.m_msg_counts[type]) * Stats::constant(
Network::MessageSizeType_to_int(MessageSizeType(type)));
}
}
@@ -183,3 +187,11 @@ Switch::functionalWrite(Packet *pkt)
}
return num_functional_writes;
}
Switch::
SwitchStats::SwitchStats(Stats::Group *parent)
: Stats::Group(parent),
m_avg_utilization(this, "percent_links_utilized")
{
}

View File

@@ -73,7 +73,7 @@ class Switch : public BasicRouter
void collateStats();
void regStats();
const Stats::Formula & getMsgCount(unsigned int type) const
{ return m_msg_counts[type]; }
{ return *(switchStats.m_msg_counts[type]); }
void print(std::ostream& out) const;
void init_net_ptr(SimpleNetwork* net_ptr) { m_network_ptr = net_ptr; }
@@ -93,10 +93,17 @@ class Switch : public BasicRouter
unsigned m_num_connected_buffers;
std::vector<MessageBuffer*> m_port_buffers;
// Statistical variables
Stats::Formula m_avg_utilization;
Stats::Formula m_msg_counts[MessageSizeType_NUM];
Stats::Formula m_msg_bytes[MessageSizeType_NUM];
public:
struct SwitchStats : public Stats::Group
{
SwitchStats(Stats::Group *parent);
// Statistical variables
Stats::Formula m_avg_utilization;
Stats::Formula* m_msg_counts[MessageSizeType_NUM];
Stats::Formula* m_msg_bytes[MessageSizeType_NUM];
} switchStats;
};
inline std::ostream&

View File

@@ -51,8 +51,10 @@ static int network_message_to_size(Message* net_msg_ptr);
Throttle::Throttle(int sID, RubySystem *rs, NodeID node, Cycles link_latency,
int link_bandwidth_multiplier, int endpoint_bandwidth,
Switch *em)
: Consumer(em), m_switch_id(sID), m_switch(em), m_node(node),
m_ruby_system(rs)
: Consumer(em),
m_switch_id(sID), m_switch(em), m_node(node),
m_ruby_system(rs),
throttleStats(em, node)
{
m_vnets = 0;
@@ -122,7 +124,8 @@ Throttle::operateVnet(int vnet, int &bw_remaining, bool &schedule_wakeup,
m_switch->cyclesToTicks(m_link_latency));
// Count the message
m_msg_counts[net_msg_ptr->getMessageSize()][vnet]++;
(*(throttleStats.
m_msg_counts[net_msg_ptr->getMessageSize()]))[vnet]++;
DPRINTF(RubyNetwork, "%s\n", *out);
}
@@ -200,26 +203,27 @@ Throttle::wakeup()
}
void
Throttle::regStats(string parent)
Throttle::regStats()
{
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(Network::getNumberOfVirtualNetworks())
.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))
throttleStats.m_msg_counts[(unsigned int)type] =
new Stats::Vector(&throttleStats,
csprintf("msg_count.%s", MessageSizeType_to_string(type)).c_str());
throttleStats.m_msg_counts[(unsigned int)type]
->init(Network::getNumberOfVirtualNetworks())
.flags(Stats::nozero)
;
m_msg_bytes[(unsigned int) type] = m_msg_counts[type] * Stats::constant(
throttleStats.m_msg_bytes[(unsigned int) type] =
new Stats::Formula(&throttleStats,
csprintf("msg_bytes.%s", MessageSizeType_to_string(type)).c_str());
throttleStats.m_msg_bytes[(unsigned int) type]
->flags(Stats::nozero)
;
*(throttleStats.m_msg_bytes[(unsigned int) type]) =
*(throttleStats.m_msg_counts[type]) * Stats::constant(
Network::MessageSizeType_to_int(type));
}
}
@@ -236,7 +240,8 @@ Throttle::collateStats()
double time_delta = double(m_ruby_system->curCycle() -
m_ruby_system->getStartCycle());
m_link_utilization = 100.0 * m_link_utilization_proxy / time_delta;
throttleStats.m_link_utilization =
100.0 * m_link_utilization_proxy / time_delta;
}
void
@@ -259,3 +264,11 @@ network_message_to_size(Message *net_msg_ptr)
return size;
}
Throttle::
ThrottleStats::ThrottleStats(Stats::Group *parent, const NodeID &nodeID)
: Stats::Group(parent, csprintf("throttle%02i", nodeID).c_str()),
m_link_utilization(this, "link_utilization")
{
}

View File

@@ -66,9 +66,9 @@ class Throttle : public Consumer
// The average utilization (a fraction) since last clearStats()
const Stats::Scalar & getUtilization() const
{ return m_link_utilization; }
{ return throttleStats.m_link_utilization; }
const Stats::Vector & getMsgCount(unsigned int type) const
{ return m_msg_counts[type]; }
{ return *(throttleStats.m_msg_counts[type]); }
int getLinkBandwidth() const
{ return m_endpoint_bandwidth * m_link_bandwidth_multiplier; }
@@ -77,7 +77,7 @@ class Throttle : public Consumer
void clearStats();
void collateStats();
void regStats(std::string name);
void regStats();
void print(std::ostream& out) const;
private:
@@ -105,12 +105,18 @@ class Throttle : public Consumer
int m_endpoint_bandwidth;
RubySystem *m_ruby_system;
// Statistical variables
Stats::Scalar m_link_utilization;
Stats::Vector m_msg_counts[MessageSizeType_NUM];
Stats::Formula m_msg_bytes[MessageSizeType_NUM];
double m_link_utilization_proxy;
struct ThrottleStats : public Stats::Group
{
ThrottleStats(Stats::Group *parent, const NodeID &nodeID);
// Statistical variables
Stats::Scalar m_link_utilization;
Stats::Vector* m_msg_counts[MessageSizeType_NUM];
Stats::Formula* m_msg_bytes[MessageSizeType_NUM];
} throttleStats;
};
inline std::ostream&