cpu: Make the ThreadContext a PCEventScope.
authorGabe Black <gabeblack@google.com>
Thu, 10 Oct 2019 04:32:11 +0000 (21:32 -0700)
committerGabe Black <gabeblack@google.com>
Fri, 25 Oct 2019 22:42:31 +0000 (22:42 +0000)
Both the thread and system's PCEventQueue are checked when appropriate.

Change-Id: I16c371339c91a37b5641860d974e546a30e23e13
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22105
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/arm/fastmodel/iris/thread_context.hh
src/cpu/checker/cpu_impl.hh
src/cpu/checker/thread_context.hh
src/cpu/minor/execute.cc
src/cpu/o3/commit_impl.hh
src/cpu/o3/thread_context.hh
src/cpu/o3/thread_state.hh
src/cpu/simple/base.cc
src/cpu/simple_thread.hh
src/cpu/thread_context.hh

index 5be5e71f6c2cb7913dc954f7a32bcbf31fe91d2f..13ab29c468a77bdb28dd90a843fb7f70572defbd 100644 (file)
@@ -93,6 +93,9 @@ class ThreadContext : public ::ThreadContext
                   const std::string &iris_path);
     virtual ~ThreadContext();
 
+    bool schedule(PCEvent *e) override { return false; }
+    bool remove(PCEvent *e) override { return false; }
+
     virtual Counter
     totalInsts()
     {
index 95ea3f7bb71f5030a9edc2076f83e5e7856eaa10..81bf4c100b0ce77ec06bc34c3059bc8d7978d3ed 100644 (file)
@@ -413,6 +413,7 @@ Checker<Impl>::verify(const DynInstPtr &completed_inst)
             do {
                 oldpc = thread->instAddr();
                 system->pcEventQueue.service(oldpc, tc);
+                thread->pcEventQueue.service(oldpc, tc);
                 count++;
             } while (oldpc != thread->instAddr());
             if (count > 1) {
index 2e5f31d770f6cfe84f6c2bce7ca292cf99b4dce5..a7199d16802c90aa8ed6f3ecf03ad701c09ce176 100644 (file)
@@ -89,6 +89,8 @@ class CheckerThreadContext : public ThreadContext
     CheckerCPU *checkerCPU;
 
   public:
+    bool schedule(PCEvent *e) override { return actualTC->schedule(e); }
+    bool remove(PCEvent *e) override { return actualTC->remove(e); }
 
     BaseCPU *getCpuPtr() override { return actualTC->getCpuPtr(); }
 
index a9d51b71792ccb5388436e8a9a9868e31f51a972..5bf3120c2a7735729f2a8e2ba4d01ff7355e460d 100644 (file)
@@ -842,6 +842,7 @@ Execute::tryPCEvents(ThreadID thread_id)
     do {
         oldPC = thread->instAddr();
         cpu.system->pcEventQueue.service(oldPC, thread);
+        cpu.threads[thread_id]->pcEventQueue.service(oldPC, thread);
         num_pc_event_checks++;
     } while (oldPC != thread->instAddr());
 
index df439454b5fef50b3e5029421874947f2f93fd7c..23f10fe2ab67b280af6496595cea8dde31d71330 100644 (file)
@@ -1114,6 +1114,8 @@ DefaultCommit<Impl>::commitInsts()
                         oldpc = pc[tid].instAddr();
                         cpu->system->pcEventQueue.service(
                                 oldpc, thread[tid]->getTC());
+                        thread[tid]->pcEventQueue.service(
+                                oldpc, thread[tid]->getTC());
                         count++;
                     } while (oldpc != pc[tid].instAddr());
                     if (count > 1) {
index 9029aba3e9bc40b1246f67c473df8f56b16e1fc1..2ec559f2de3b282d8daaa124c18b2984c1a18071 100644 (file)
@@ -75,6 +75,17 @@ class O3ThreadContext : public ThreadContext
    /** Pointer to the CPU. */
     O3CPU *cpu;
 
+    bool
+    schedule(PCEvent *e) override
+    {
+        return thread->pcEventQueue.schedule(e);
+    }
+    bool
+    remove(PCEvent *e) override
+    {
+        return thread->pcEventQueue.remove(e);
+    }
+
     /** Pointer to the thread state that this TC corrseponds to. */
     O3ThreadState<Impl> *thread;
 
index 4b4f51e8faeee0c6f307aecd097e16cce290a9ba..b2c9296f466596b0c0fb1391302a8a531704850e 100644 (file)
@@ -72,7 +72,10 @@ struct O3ThreadState : public ThreadState {
   private:
     /** Pointer to the CPU. */
     O3CPU *cpu;
+
   public:
+    PCEventQueue pcEventQueue;
+
     /* This variable controls if writes to a thread context should cause a all
      * dynamic/speculative state to be thrown away. Nominally this is the
      * desired behavior because the external thread context write has updated
index df3d981adc2467fcdd02bb530599a7995df54f11..8cecf70e4f5e994236abfbb2aff5c57ce23120d7 100644 (file)
@@ -145,6 +145,8 @@ BaseSimpleCPU::checkPcEventQueue()
     do {
         oldpc = pc;
         system->pcEventQueue.service(oldpc, threadContexts[curThread]);
+        threadInfo[curThread]->thread->pcEventQueue.service(
+                oldpc, threadContexts[curThread]);
         pc = threadInfo[curThread]->thread->instAddr();
     } while (oldpc != pc);
 }
index 301e18d5439ef17a67a04160beddcf76e6375d69..86d31b2352dbb1c9e8d0004e5cb392420253253c 100644 (file)
@@ -126,6 +126,8 @@ class SimpleThread : public ThreadState, public ThreadContext
         return csprintf("%s.[tid:%i]", baseCpu->name(), threadId());
     }
 
+    PCEventQueue pcEventQueue;
+
     System *system;
 
     BaseTLB *itb;
@@ -188,6 +190,9 @@ class SimpleThread : public ThreadState, public ThreadContext
      * ThreadContext interface functions.
      ******************************************/
 
+    bool schedule(PCEvent *e) override { return pcEventQueue.schedule(e); }
+    bool remove(PCEvent *e) override { return pcEventQueue.remove(e); }
+
     BaseCPU *getCpuPtr() override { return baseCpu; }
 
     int cpuId() const override { return ThreadState::cpuId(); }
index 0bd29302bf28a2df5af2b2b6fd75df4ef634d219..749b4ca90a1cfba671d71dbecaecfbed6a7e3017 100644 (file)
@@ -51,6 +51,7 @@
 #include "arch/types.hh"
 #include "base/types.hh"
 #include "config/the_isa.hh"
+#include "cpu/pc_event.hh"
 #include "cpu/reg_class.hh"
 
 // @todo: Figure out a more architecture independent way to obtain the ITB and
@@ -88,7 +89,7 @@ namespace Kernel {
  * interface; the ExecContext is a more implicit interface that must
  * be implemented so that the ISA can access whatever state it needs.
  */
-class ThreadContext
+class ThreadContext : public PCEventScope
 {
   protected:
     typedef TheISA::MachInst MachInst;