Reputation: 25
I'm looking to use gem5 with some of my work, and have a very general question regarding its features.
My question is, using gem5, can I get statistics on behavior / system resource usage of individual threads, either in SE or FS mode. For example, if I have 2 threads running in my application, can I see that Thread 1 uses X cycles on CPU 1, Y cycles on CPU 2 etc, and Thread 2 uses Z cycles on CPU 3 etc. If this is possible, does it also extend to cache usage, memory usage etc?
I saw the following questions: Accessing logical (software) thread ID in gem5, but I think just using hardware thread statistics would work for our use case.
I see that the ThreadState class in src/cpu/thread_state.hh has the following feilds:
/** Number of instructions committed. */
Counter numInst;
/** Stat for number instructions committed. */
Stats::Scalar numInsts;
/** Number of ops (including micro ops) committed. */
Counter numOp;
/** Stat for number ops (including micro ops) committed. */
Stats::Scalar numOps;
/** Stat for number of memory references. */
Stats::Scalar numMemRefs;
This looks like something I could use. Would anyone know if these stats can be easily output per thread in the stats file?
Thanks!
Upvotes: 2
Views: 698
Reputation: 4073
I haven't done this myself, but I will make the following educated guesses:
se.py: SE has a limitation that it can only run one thread per core, so I suspect that this will show directly on the per core stats
fs.py: the definition of thread is OS dependent, so you would need some kind of guest support.
In the context of ARM Linux kernel tracing for example, CONFIG_PID_IN_CONTEXTIDR
shows on logs: How to access logical software user thread ID of a Linux process in gem5? but not sure how easy it will be to get the stats out
So likely se.py will be the easier approach.
--enable-context-switch-stats-dump
I just came across this option while reading some source:
parser.add_option("--enable-context-switch-stats-dump", \
action="store_true", help="Enable stats dump at context "\
"switches and dump tasks file (required for Streamline)")
It appears to hook then the PC hits the __switch_to
kernel symbol address:
void
FsLinux::startup()
{
FsWorkload::startup();
if (enableContextSwitchStatsDump) {
if (getArch() == Loader::Arm64)
dumpStats = addKernelFuncEvent<DumpStats64>("__switch_to");
else
dumpStats = addKernelFuncEvent<DumpStats>("__switch_to");
so this should dump per thread for each context switch!
I haven't tested it however, and I wonder how easy it will be to correlate which thread is what.
Upvotes: 1