cpu: Get rid of load count based events.

This was initially added in 2003 and only supported in the simple CPUs.
It's oddly specific since there are no other similar event queues for,
for instance, stores, branches, system calls, etc.

Given that this seems like a historical oddity which is only partially
supported and would be very hard to support on more diverse CPU types
like KVM or fast model which don't generally have hooks for counts of
specific instruction types.

Change-Id: I29209b7ffcf896cf424b71545c9c7546f439e2b9
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21780
Reviewed-by: Brandon Potter <Brandon.Potter@amd.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
diff --git a/src/cpu/BaseCPU.py b/src/cpu/BaseCPU.py
index 0e8c289..85e3777 100644
--- a/src/cpu/BaseCPU.py
+++ b/src/cpu/BaseCPU.py
@@ -122,7 +122,6 @@
         PyBindMethod("flushTLBs"),
         PyBindMethod("totalInsts"),
         PyBindMethod("scheduleInstStop"),
-        PyBindMethod("scheduleLoadStop"),
         PyBindMethod("getCurrentInstCount"),
     ]
 
@@ -196,10 +195,6 @@
         "terminate when any thread reaches this inst count")
     simpoint_start_insts = VectorParam.Counter([],
         "starting instruction counts of simpoints")
-    max_loads_all_threads = Param.Counter(0,
-        "terminate when all threads have reached this load count")
-    max_loads_any_thread = Param.Counter(0,
-        "terminate when any thread reaches this load count")
     progress_interval = Param.Frequency('0Hz',
         "frequency to print out the progress message")
 
diff --git a/src/cpu/base.cc b/src/cpu/base.cc
index 5bc3fe7..7e0e79e 100644
--- a/src/cpu/base.cc
+++ b/src/cpu/base.cc
@@ -195,32 +195,9 @@
         }
     }
 
-    // allocate per-thread load-based event queues
-    comLoadEventQueue = new EventQueue *[numThreads];
-    for (ThreadID tid = 0; tid < numThreads; ++tid)
-        comLoadEventQueue[tid] = new EventQueue("load-based event queue");
-
     //
     // set up instruction-count-based termination events, if any
     //
-    if (p->max_loads_any_thread != 0) {
-        const char *cause = "a thread reached the max load count";
-        for (ThreadID tid = 0; tid < numThreads; ++tid)
-            scheduleLoadStop(tid, p->max_loads_any_thread, cause);
-    }
-
-    if (p->max_loads_all_threads != 0) {
-        const char *cause = "all threads reached the max load count";
-        // allocate & initialize shared downcounter: each event will
-        // decrement this when triggered; simulation will terminate
-        // when counter reaches 0
-        int *counter = new int;
-        *counter = numThreads;
-        for (ThreadID tid = 0; tid < numThreads; ++tid) {
-            Event *event = new CountedExitEvent(cause, *counter);
-            comLoadEventQueue[tid]->schedule(event, p->max_loads_all_threads);
-        }
-    }
 
     functionTracingEnabled = false;
     if (p->function_trace) {
@@ -273,7 +250,6 @@
 BaseCPU::~BaseCPU()
 {
     delete profileEvent;
-    delete[] comLoadEventQueue;
     delete[] comInstEventQueue;
 }
 
@@ -781,15 +757,6 @@
     return false;
 }
 
-void
-BaseCPU::scheduleLoadStop(ThreadID tid, Counter loads, const char *cause)
-{
-    const Tick now(comLoadEventQueue[tid]->getCurTick());
-    Event *event(new LocalSimLoopExitEvent(cause, 0));
-
-    comLoadEventQueue[tid]->schedule(event, now + loads);
-}
-
 
 void
 BaseCPU::traceFunctionsInternal(Addr pc)
diff --git a/src/cpu/base.hh b/src/cpu/base.hh
index dfee21f..383ae81 100644
--- a/src/cpu/base.hh
+++ b/src/cpu/base.hh
@@ -390,13 +390,6 @@
      */
     EventQueue **comInstEventQueue;
 
-    /**
-     * Vector of per-thread load-based event queues.  Used for
-     * scheduling events based on number of loads committed by
-     *a particular thread.
-     */
-    EventQueue **comLoadEventQueue;
-
     System *system;
 
     /**
@@ -464,21 +457,6 @@
     void scheduleInstStop(ThreadID tid, Counter insts, const char *cause);
 
     /**
-     * Schedule an event that exits the simulation loops after a
-     * predefined number of load operations.
-     *
-     * This method is usually called from the configuration script to
-     * get an exit event some time in the future. It is typically used
-     * when the script wants to simulate for a specific number of
-     * loads rather than ticks.
-     *
-     * @param tid Thread monitor.
-     * @param loads Number of load instructions into the future.
-     * @param cause Cause to signal in the exit event.
-     */
-    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.
      *
diff --git a/src/cpu/dummy_checker.cc b/src/cpu/dummy_checker.cc
index c42c8b5..d119d61 100644
--- a/src/cpu/dummy_checker.cc
+++ b/src/cpu/dummy_checker.cc
@@ -48,7 +48,6 @@
     // cpu and therefore any parameters for early exit don't make much
     // sense.
     fatal_if(max_insts_any_thread || max_insts_all_threads ||
-             max_loads_any_thread || max_loads_all_threads ||
              progress_interval, "Invalid checker parameters");
 
     return new DummyChecker(this);
diff --git a/src/cpu/o3/checker.cc b/src/cpu/o3/checker.cc
index 1713da7..fdf7ec6 100644
--- a/src/cpu/o3/checker.cc
+++ b/src/cpu/o3/checker.cc
@@ -55,7 +55,6 @@
     // cpu and therefore any parameters for early exit don't make much
     // sense.
     fatal_if(max_insts_any_thread || max_insts_all_threads ||
-             max_loads_any_thread || max_loads_all_threads ||
              progress_interval, "Invalid checker parameters");
 
     return new O3Checker(this);
diff --git a/src/cpu/simple/base.cc b/src/cpu/simple/base.cc
index b93ae09..461f00f 100644
--- a/src/cpu/simple/base.cc
+++ b/src/cpu/simple/base.cc
@@ -600,7 +600,6 @@
 
     if (curStaticInst->isLoad()) {
         ++t_info.numLoad;
-        comLoadEventQueue[curThread]->serviceEvents(t_info.numLoad);
     }
 
     if (CPA::available()) {