From a2286fe344f0fd6484f232329a56e9f07e2136de Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Mon, 23 Sep 2019 18:18:28 +0100 Subject: [PATCH] mem: Use new-style stats in the XBar models Migrate to new-world stats with an explicit hierarchy in all of the XBar models. Change-Id: I18b6746a1303ca415638e6d382fb4757607f1123 Signed-off-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21141 Tested-by: kokoro Reviewed-by: Daniel Carvalho Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris --- src/mem/coherent_xbar.cc | 41 +++++++++------------------- src/mem/noncoherent_xbar.cc | 19 +++---------- src/mem/noncoherent_xbar.hh | 5 +--- src/mem/xbar.cc | 54 ++++++++++++++++--------------------- src/mem/xbar.hh | 8 +++--- 5 files changed, 43 insertions(+), 84 deletions(-) diff --git a/src/mem/coherent_xbar.cc b/src/mem/coherent_xbar.cc index a339500a8..713c6421b 100644 --- a/src/mem/coherent_xbar.cc +++ b/src/mem/coherent_xbar.cc @@ -62,7 +62,11 @@ CoherentXBar::CoherentXBar(const CoherentXBarParams *p) maxOutstandingSnoopCheck(p->max_outstanding_snoops), maxRoutingTableSizeCheck(p->max_routing_table_size), pointOfCoherency(p->point_of_coherency), - pointOfUnification(p->point_of_unification) + pointOfUnification(p->point_of_unification), + + snoops(this, "snoops", "Total snoops (count)"), + snoopTraffic(this, "snoopTraffic", "Total snoop traffic (bytes)"), + snoopFanout(this, "snoop_fanout", "Request fanout histogram") { // create the ports based on the size of the master and slave // vector ports, and the presence of the default port, the ports @@ -72,9 +76,9 @@ CoherentXBar::CoherentXBar(const CoherentXBarParams *p) MasterPort* bp = new CoherentXBarMasterPort(portName, *this, i); masterPorts.push_back(bp); reqLayers.push_back(new ReqLayer(*bp, *this, - csprintf(".reqLayer%d", i))); + csprintf("reqLayer%d", i))); snoopLayers.push_back( - new SnoopRespLayer(*bp, *this, csprintf(".snoopLayer%d", i))); + new SnoopRespLayer(*bp, *this, csprintf("snoopLayer%d", i))); } // see if we have a default slave device connected and if so add @@ -85,10 +89,10 @@ CoherentXBar::CoherentXBar(const CoherentXBarParams *p) MasterPort* bp = new CoherentXBarMasterPort(portName, *this, defaultPortID); masterPorts.push_back(bp); - reqLayers.push_back(new ReqLayer(*bp, *this, csprintf(".reqLayer%d", + reqLayers.push_back(new ReqLayer(*bp, *this, csprintf("reqLayer%d", defaultPortID))); snoopLayers.push_back(new SnoopRespLayer(*bp, *this, - csprintf(".snoopLayer%d", + csprintf("snoopLayer%d", defaultPortID))); } @@ -98,7 +102,7 @@ CoherentXBar::CoherentXBar(const CoherentXBarParams *p) QueuedSlavePort* bp = new CoherentXBarSlavePort(portName, *this, i); slavePorts.push_back(bp); respLayers.push_back(new RespLayer(*bp, *this, - csprintf(".respLayer%d", i))); + csprintf("respLayer%d", i))); snoopRespPorts.push_back(new SnoopRespPort(*bp, *this)); } } @@ -1104,30 +1108,9 @@ CoherentXBar::forwardPacket(const PacketPtr pkt) void CoherentXBar::regStats() { - // register the stats of the base class and our layers BaseXBar::regStats(); - for (auto l: reqLayers) - l->regStats(); - for (auto l: respLayers) - l->regStats(); - for (auto l: snoopLayers) - l->regStats(); - - snoops - .name(name() + ".snoops") - .desc("Total snoops (count)") - ; - - snoopTraffic - .name(name() + ".snoopTraffic") - .desc("Total snoop traffic (bytes)") - ; - - snoopFanout - .init(0, snoopPorts.size(), 1) - .name(name() + ".snoop_fanout") - .desc("Request fanout histogram") - ; + + snoopFanout.init(0, snoopPorts.size(), 1); } CoherentXBar * diff --git a/src/mem/noncoherent_xbar.cc b/src/mem/noncoherent_xbar.cc index 730c2b226..0de953306 100644 --- a/src/mem/noncoherent_xbar.cc +++ b/src/mem/noncoherent_xbar.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, 2018 ARM Limited + * Copyright (c) 2011-2015, 2018-2019 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -65,7 +65,7 @@ NoncoherentXBar::NoncoherentXBar(const NoncoherentXBarParams *p) MasterPort* bp = new NoncoherentXBarMasterPort(portName, *this, i); masterPorts.push_back(bp); reqLayers.push_back(new ReqLayer(*bp, *this, - csprintf(".reqLayer%d", i))); + csprintf("reqLayer%d", i))); } // see if we have a default slave device connected and if so add @@ -76,7 +76,7 @@ NoncoherentXBar::NoncoherentXBar(const NoncoherentXBarParams *p) MasterPort* bp = new NoncoherentXBarMasterPort(portName, *this, defaultPortID); masterPorts.push_back(bp); - reqLayers.push_back(new ReqLayer(*bp, *this, csprintf(".reqLayer%d", + reqLayers.push_back(new ReqLayer(*bp, *this, csprintf("reqLayer%d", defaultPortID))); } @@ -86,7 +86,7 @@ NoncoherentXBar::NoncoherentXBar(const NoncoherentXBarParams *p) QueuedSlavePort* bp = new NoncoherentXBarSlavePort(portName, *this, i); slavePorts.push_back(bp); respLayers.push_back(new RespLayer(*bp, *this, - csprintf(".respLayer%d", i))); + csprintf("respLayer%d", i))); } } @@ -317,14 +317,3 @@ NoncoherentXBarParams::create() { return new NoncoherentXBar(this); } - -void -NoncoherentXBar::regStats() -{ - // register the stats of the base class and our layers - BaseXBar::regStats(); - for (auto l: reqLayers) - l->regStats(); - for (auto l: respLayers) - l->regStats(); -} diff --git a/src/mem/noncoherent_xbar.hh b/src/mem/noncoherent_xbar.hh index 4f72cef4d..d8f35e4e1 100644 --- a/src/mem/noncoherent_xbar.hh +++ b/src/mem/noncoherent_xbar.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015 ARM Limited + * Copyright (c) 2011-2015, 2019 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -187,9 +187,6 @@ class NoncoherentXBar : public BaseXBar NoncoherentXBar(const NoncoherentXBarParams *p); virtual ~NoncoherentXBar(); - - void regStats() override; - Stats::Scalar totPktSize; }; #endif //__MEM_NONCOHERENT_XBAR_HH__ diff --git a/src/mem/xbar.cc b/src/mem/xbar.cc index 16f0e21dd..5efb2c947 100644 --- a/src/mem/xbar.cc +++ b/src/mem/xbar.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, 2018 ARM Limited + * Copyright (c) 2011-2015, 2018-2019 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -64,8 +64,15 @@ BaseXBar::BaseXBar(const BaseXBarParams *p) gotAddrRanges(p->port_default_connection_count + p->port_master_connection_count, false), gotAllAddrRanges(false), defaultPortID(InvalidPortID), - useDefaultRange(p->use_default_range) -{} + useDefaultRange(p->use_default_range), + + transDist(this, "trans_dist", "Transaction distribution"), + pktCount(this, "pkt_count", + "Packet count per connected master and slave (bytes)"), + pktSize(this, "pkt_size", + "Cumulative packet size per connected master and slave (bytes)") +{ +} BaseXBar::~BaseXBar() { @@ -133,9 +140,20 @@ BaseXBar::calcPacketTiming(PacketPtr pkt, Tick header_delay) template BaseXBar::Layer::Layer(DstType& _port, BaseXBar& _xbar, const std::string& _name) : - port(_port), xbar(_xbar), _name(_name), state(IDLE), - waitingForPeer(NULL), releaseEvent([this]{ releaseLayer(); }, name()) + Stats::Group(&_xbar, _name.c_str()), + port(_port), xbar(_xbar), _name(xbar.name() + "." + _name), state(IDLE), + waitingForPeer(NULL), releaseEvent([this]{ releaseLayer(); }, name()), + ADD_STAT(occupancy, "Layer occupancy (ticks)"), + ADD_STAT(utilization, "Layer utilization (%)") { + occupancy + .flags(Stats::nozero); + + utilization + .precision(1) + .flags(Stats::nozero); + + utilization = 100 * occupancy / simTicks; } template @@ -527,8 +545,6 @@ BaseXBar::regStats() transDist .init(MemCmd::NUM_MEM_CMDS) - .name(name() + ".trans_dist") - .desc("Transaction distribution") .flags(nozero); // get the string representation of the commands @@ -540,14 +556,10 @@ BaseXBar::regStats() pktCount .init(slavePorts.size(), masterPorts.size()) - .name(name() + ".pkt_count") - .desc("Packet count per connected master and slave (bytes)") .flags(total | nozero | nonan); pktSize .init(slavePorts.size(), masterPorts.size()) - .name(name() + ".pkt_size") - .desc("Cumulative packet size per connected master and slave (bytes)") .flags(total | nozero | nonan); // both the packet count and total size are two-dimensional @@ -581,26 +593,6 @@ BaseXBar::Layer::drain() } } -template -void -BaseXBar::Layer::regStats() -{ - using namespace Stats; - - occupancy - .name(name() + ".occupancy") - .desc("Layer occupancy (ticks)") - .flags(nozero); - - utilization - .name(name() + ".utilization") - .desc("Layer utilization (%)") - .precision(1) - .flags(nozero); - - utilization = 100 * occupancy / simTicks; -} - /** * Crossbar layer template instantiations. Could be removed with _impl.hh * file, but since there are only two given options (MasterPort and diff --git a/src/mem/xbar.hh b/src/mem/xbar.hh index 8de7af46f..1ec846d62 100644 --- a/src/mem/xbar.hh +++ b/src/mem/xbar.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, 2018 ARM Limited + * Copyright (c) 2011-2015, 2018-2019 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -90,7 +90,7 @@ class BaseXBar : public ClockedObject * ports, whereas a response layer holds master ports. */ template - class Layer : public Drainable + class Layer : public Drainable, public Stats::Group { public: @@ -116,7 +116,7 @@ class BaseXBar : public ClockedObject */ DrainState drain() override; - const std::string name() const { return xbar.name() + _name; } + const std::string name() const { return _name; } /** @@ -166,8 +166,6 @@ class BaseXBar : public ClockedObject */ void recvRetry(); - void regStats(); - protected: /** -- 2.30.2