Hello all,
I have been working with gem5 for a while now. I'm trying to generate statistics for the TLM example given in the util/systemc/systemc_within_gem5/systemc_gem5_tlm example.
Since there were no in-built stats available for the sc_tlm_target.{cc,hh}, I tried to create few of my own using the mechanism given in the documentation. I'll add my code snippets below.
#include<>
....
struct TargetParams: public SimObjectParams{
};
class Target: public sc_module, public gem5::SimObject
{
public:
..........
struct StatGroup : public gem5::statistics::Group {
gem5::statistics::Scalar testingVariable1;
gem5::statistics::Scalar testingVariable2;
gem5::statistics::Scalar testingVariable3;
StatGroup(gem5::statistics::Group *parent);
}stats;
........
public:
PARAMS(Target);
SC_HAS_PROCESS(Target);
Target(sc_module_name name, const Params &p) :
sc_module(name),
SimObject(p),
tSocket("tSocket"),
wrapper(tSocket, std::string(name) + ".tlm", InvalidPortID),
stats(this)
{
.........
}
.............
};
Target::StatGroup::StatGroup(gem5::statistics::Group *parent)
: gem5::statistics::Group(parent),
ADD_STAT(testingVariable1, gem5::statistics::units::Count::get(), "Variable1 for testing"),
ADD_STAT(testingVariable2, gem5::statistics::units::Count::get(), "Variable2 for testing"),
ADD_STAT(testingVariable3, gem5::statistics::units::Count::get(), "Variable3 for testing")
{
}
My current gem5 version is gem5v23.1. I'm working on WSL. Please feel ask any more questions if needed.
Thank you and hoping to listen from you soon.
Best Regards,
Ananth Pai J
Infineon Technologies IN
DES PTS TI EA SME
Phone: +91 7349045724
Ananth.PaiJ@infineon.commailto:Ananth.PaiJ@infineon.com
Hi PaiJ,
Is the stats.txt file in m5out folder is empty? If yes, I think the root cause is that gem5-tlm is using cxx_manager class to register each objects while the registering of stat is missing.
My solution is adding a new method at CxxConfigManager::instantiate(bool build_all){} . This method will iterate through all the simObjects and add their stats into gem5::statistics::statsList().
Due to work reasons, I can't give you the code directly. Hope this can give you a hint.
Thanks + Regards,
Ziyang
From: Ananth.PaiJ--- via gem5-users gem5-users@gem5.org
Sent: Tuesday, January 9, 2024 11:53 AM
To: gem5-users@gem5.org
Cc: Ananth.PaiJ@infineon.com
Subject: [gem5-users] Assistance required: Stats not generated for TLM examples
Hello all,
I have been working with gem5 for a while now. I'm trying to generate statistics for the TLM example given in the util/systemc/systemc_within_gem5/systemc_gem5_tlm example.
Since there were no in-built stats available for the sc_tlm_target.{cc,hh}, I tried to create few of my own using the mechanism given in the documentation. I'll add my code snippets below.
#include<>
....
struct TargetParams: public SimObjectParams{
};
class Target: public sc_module, public gem5::SimObject
{
public:
..........
struct StatGroup : public gem5::statistics::Group {
gem5::statistics::Scalar testingVariable1;
gem5::statistics::Scalar testingVariable2;
gem5::statistics::Scalar testingVariable3;
StatGroup(gem5::statistics::Group *parent);
}stats;
........
public:
PARAMS(Target);
SC_HAS_PROCESS(Target);
Target(sc_module_name name, const Params &p) :
sc_module(name),
SimObject(p),
tSocket("tSocket"),
wrapper(tSocket, std::string(name) + ".tlm", InvalidPortID),
stats(this)
{
.........
}
.............
};
Target::StatGroup::StatGroup(gem5::statistics::Group *parent)
: gem5::statistics::Group(parent),
ADD_STAT(testingVariable1, gem5::statistics::units::Count::get(), "Variable1 for testing"),
ADD_STAT(testingVariable2, gem5::statistics::units::Count::get(), "Variable2 for testing"),
ADD_STAT(testingVariable3, gem5::statistics::units::Count::get(), "Variable3 for testing")
{
}
My current gem5 version is gem5v23.1. I'm working on WSL. Please feel ask any more questions if needed.
Thank you and hoping to listen from you soon.
Best Regards,
Ananth Pai J
Infineon Technologies IN
DES PTS TI EA SME
Phone: +91 7349045724
Ananth.PaiJ@infineon.commailto:Ananth.PaiJ@infineon.com