cpu: Access inst events through ThreadContext instead of the CPU.
authorGabe Black <gabeblack@google.com>
Mon, 14 Oct 2019 22:31:26 +0000 (15:31 -0700)
committerGabe Black <gabeblack@google.com>
Fri, 25 Oct 2019 22:42:31 +0000 (22:42 +0000)
Also delete the CPU interface.

Change-Id: I62a6b0a9a303d672f4083bdedf393f9f6d07331f
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22109
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/base/remote_gdb.cc
src/cpu/base.cc
src/cpu/base.hh
src/cpu/kvm/base.cc
src/cpu/minor/execute.cc
src/cpu/o3/cpu.cc
src/cpu/o3/probe/elastic_trace.cc
src/cpu/simple/base.cc

index b45ef103732974dfd949e1c4260052b6d15c15c6..9a1f7bf2bbacbdc55b2b6015b47af99c3e3e5b5e 100644 (file)
@@ -753,18 +753,16 @@ BaseRemoteGDB::setTempBreakpoint(Addr bkpt)
 void
 BaseRemoteGDB::scheduleInstCommitEvent(Event *ev, int delta)
 {
-    auto *cpu = tc->getCpuPtr();
     // Here "ticks" aren't simulator ticks which measure time, they're
     // instructions committed by the CPU.
-    cpu->scheduleInstCountEvent(tc->threadId(), ev,
-            cpu->getCurrentInstCount(tc->threadId()) + delta);
+    tc->scheduleInstCountEvent(ev, tc->getCurrentInstCount() + delta);
 }
 
 void
 BaseRemoteGDB::descheduleInstCommitEvent(Event *ev)
 {
     if (ev->scheduled())
-        tc->getCpuPtr()->descheduleInstCountEvent(tc->threadId(), ev);
+        tc->descheduleInstCountEvent(ev);
 }
 
 std::map<char, BaseRemoteGDB::GdbCommand> BaseRemoteGDB::command_map = {
index 7040cb7ea0e08af7e34969a6b6ccdd99e3c3b676..e8927dfcd3b28534af054c809b52139634530726 100644 (file)
@@ -314,8 +314,8 @@ BaseCPU::init()
         *counter = numThreads;
         for (ThreadID tid = 0; tid < numThreads; ++tid) {
             Event *event = new CountedExitEvent(cause, *counter);
-            scheduleInstCountEvent(
-                    tid, event, params()->max_insts_all_threads);
+            threadContexts[tid]->scheduleInstCountEvent(
+                    event, params()->max_insts_all_threads);
         }
     }
 
@@ -725,7 +725,7 @@ BaseCPU::scheduleInstStop(ThreadID tid, Counter insts, const char *cause)
     const Tick now(getCurrentInstCount(tid));
     Event *event(new LocalSimLoopExitEvent(cause, 0));
 
-    scheduleInstCountEvent(tid, event, now + insts);
+    threadContexts[tid]->scheduleInstCountEvent(event, now + insts);
 }
 
 Tick
index d73f4a2d563a57af8be6c65b028ff4bfc26b291d..cb23cb1ba72cf2a00d57a1c7e67bcebb7ef81c68 100644 (file)
@@ -465,30 +465,6 @@ class BaseCPU : public ClockedObject
      */
     uint64_t getCurrentInstCount(ThreadID tid);
 
-    Tick
-    nextInstEventCount(ThreadID tid)
-    {
-        return threadContexts[tid]->nextInstEventCount();
-    }
-
-    void
-    serviceInstCountEvents(ThreadID tid, Tick count)
-    {
-        threadContexts[tid]->serviceInstCountEvents(count);
-    }
-
-    void
-    scheduleInstCountEvent(ThreadID tid, Event *event, Tick count)
-    {
-        threadContexts[tid]->scheduleInstCountEvent(event, count);
-    }
-
-    void
-    descheduleInstCountEvent(ThreadID tid, Event *event)
-    {
-        threadContexts[tid]->descheduleInstCountEvent(event);
-    }
-
   public:
     /**
      * @{
index 384abb0eb7479e7678a331631a20f887a721dcad..da3e87ee422d8f3497a920f8e4d44e49c1d7e271 100644 (file)
@@ -630,7 +630,7 @@ BaseKvmCPU::tick()
 
       case RunningServiceCompletion:
       case Running: {
-          const uint64_t nextInstEvent(nextInstEventCount(0));
+          const uint64_t nextInstEvent(tc->nextInstEventCount());
           // Enter into KVM and complete pending IO instructions if we
           // have an instruction event pending.
           const Tick ticksToExecute(
@@ -686,7 +686,7 @@ BaseKvmCPU::tick()
           // Service any pending instruction events. The vCPU should
           // have exited in time for the event using the instruction
           // counter configured by setupInstStop().
-          serviceInstCountEvents(0, ctrInsts);
+          tc->serviceInstCountEvents(ctrInsts);
 
           if (tryDrain())
               _status = Idle;
@@ -1346,7 +1346,7 @@ BaseKvmCPU::ioctlRun()
 void
 BaseKvmCPU::setupInstStop()
 {
-    Tick next = nextInstEventCount(0);
+    Tick next = tc->nextInstEventCount();
     if (next == MaxTick) {
         setupInstCounter(0);
     } else {
index 9317f61f4e37fe4ce7589718e88bb6029c5a917b..0e83db3cb2f4ce05b47d34744afe57bb821f64bf 100644 (file)
@@ -870,7 +870,8 @@ Execute::doInstCommitAccounting(MinorDynInstPtr inst)
         cpu.system->totalNumInsts++;
 
         /* Act on events related to instruction counts */
-        cpu.serviceInstCountEvents(inst->id.threadId, thread->numInst);
+        cpu.getContext(inst->id.threadId)->
+            serviceInstCountEvents(thread->numInst);
     }
     thread->numOp++;
     thread->numOps++;
index e49d4997e6e6b32b6febe3fa57ecbc82eb1f6060..bb3f0c30153f92a697c978cb434eb885586f6cfc 100644 (file)
@@ -1521,7 +1521,7 @@ FullO3CPU<Impl>::instDone(ThreadID tid, const DynInstPtr &inst)
         system->totalNumInsts++;
 
         // Check for instruction-count-based events.
-        serviceInstCountEvents(tid, thread[tid]->numInst);
+        thread[tid]->tc->serviceInstCountEvents(thread[tid]->numInst);
     }
     thread[tid]->numOp++;
     thread[tid]->numOps++;
index 586688600900f6598d41d40904d6531abb2004f2..3e98e5a1984bf3063b80da32308aebcf6aee10eb 100644 (file)
@@ -109,8 +109,8 @@ ElasticTrace::regProbeListeners()
     } else {
         // Schedule an event to register all elastic trace probes when
         // specified no. of instructions are committed.
-        cpu->scheduleInstCountEvent(
-                0, &regEtraceListenersEvent, startTraceInst);
+        cpu->getContext(0)->scheduleInstCountEvent(
+                &regEtraceListenersEvent, startTraceInst);
     }
 }
 
index fc07fedc0f634322af6f753e0e1616c46ed4c5e2..f45165b9ebb282bec189cdf33a1cd5b411fcb0b2 100644 (file)
@@ -500,7 +500,7 @@ BaseSimpleCPU::preExecute()
     t_info.setMemAccPredicate(true);
 
     // check for instruction-count-based events
-    serviceInstCountEvents(curThread, t_info.numInst);
+    thread->getTC()->serviceInstCountEvents(t_info.numInst);
 
     // decode the instruction
     inst = gtoh(inst);