changeset d6c8016a9a03 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=d6c8016a9a03
description:
        cpu: Query CPU for inst executed from Python

        This patch adds the ability for the simulator to query the number of
        instructions a CPU has executed so far per hw-thread. This can be used
        to enable more flexible periodic events such as taking checkpoints
        starting 1s into simulation and X instructions thereafter.

diffstat:

 src/cpu/BaseCPU.py |  1 +
 src/cpu/base.cc    |  6 ++++++
 src/cpu/base.hh    |  9 +++++++++
 3 files changed, 16 insertions(+), 0 deletions(-)

diffs (46 lines):

diff -r cfad34a15729 -r d6c8016a9a03 src/cpu/BaseCPU.py
--- a/src/cpu/BaseCPU.py        Fri Apr 01 16:38:16 2016 -0700
+++ b/src/cpu/BaseCPU.py        Tue Apr 05 05:29:02 2016 -0500
@@ -101,6 +101,7 @@
     Counter totalInsts();
     void scheduleInstStop(ThreadID tid, Counter insts, const char *cause);
     void scheduleLoadStop(ThreadID tid, Counter loads, const char *cause);
+    uint64_t getCurrentInstCount(ThreadID tid);
 ''')
 
     @classmethod
diff -r cfad34a15729 -r d6c8016a9a03 src/cpu/base.cc
--- a/src/cpu/base.cc   Fri Apr 01 16:38:16 2016 -0700
+++ b/src/cpu/base.cc   Tue Apr 05 05:29:02 2016 -0500
@@ -691,6 +691,12 @@
     comInstEventQueue[tid]->schedule(event, now + insts);
 }
 
+uint64_t
+BaseCPU::getCurrentInstCount(ThreadID tid)
+{
+    return Tick(comInstEventQueue[tid]->getCurTick());
+}
+
 AddressMonitor::AddressMonitor() {
     armed = false;
     waiting = false;
diff -r cfad34a15729 -r d6c8016a9a03 src/cpu/base.hh
--- a/src/cpu/base.hh   Fri Apr 01 16:38:16 2016 -0700
+++ b/src/cpu/base.hh   Tue Apr 05 05:29:02 2016 -0500
@@ -465,6 +465,15 @@
      */
     void scheduleLoadStop(ThreadID tid, Counter loads, const char *cause);
 
+    /**
+     * Get the number of instructions executed by the specified thread
+     * on this CPU. Used by Python to control simulation.
+     *
+     * @param tid Thread monitor
+     * @return Number of instructions executed
+     */
+    uint64_t getCurrentInstCount(ThreadID tid);
+
   public:
     /**
      * @{
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to