Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/52084 )

Change subject: cpu: Create a virtual BaseCPU::htmSendAbortSignal method.
......................................................................

cpu: Create a virtual BaseCPU::htmSendAbortSignal method.

This virtual method can trivially be shared among different CPUs, making
it unnecessary to cast from a BaseCPU pointer to some more specific CPU
class. The existing similar functions which implement this functionality
are only trivially different, and can be merged into overloads of this
common method.

Noteably this method is not implemented for the MinorCPU which uses the
SimpleThread class, typedef-ed to be MinorThread. If the previous
version of this method had been called on that CPU, it would have
crashed the simulator since a dynamic_cast would have failed. This
doesn't provide an implementation for the MinorCPU, but it also doesn't
make the problem worse, and provides a way to actually implement it some
day.

Change-Id: I23399ea6bbbbabd87e6c8bf7a66d48902745d2cf
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52084
Reviewed-by: Giacomo Travaglini <[email protected]>
Maintainer: Giacomo Travaglini <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/cpu/simple_thread.cc
M src/cpu/o3/cpu.hh
M src/cpu/simple/timing.cc
M src/cpu/simple/timing.hh
M src/cpu/base.hh
M src/cpu/simple/atomic.hh
M src/cpu/simple/base.hh
7 files changed, 54 insertions(+), 20 deletions(-)

Approvals:
  Giacomo Travaglini: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/cpu/base.hh b/src/cpu/base.hh
index 1ac174e..afee236 100644
--- a/src/cpu/base.hh
+++ b/src/cpu/base.hh
@@ -47,12 +47,14 @@
 // Before we do anything else, check if this build is the NULL ISA,
 // and if so stop here
 #include "config/the_isa.hh"
+
 #if IS_NULL_ISA
 #error Including BaseCPU in a system without CPU support
 #else
 #include "arch/generic/interrupts.hh"
 #include "base/statistics.hh"
 #include "debug/Mwait.hh"
+#include "mem/htm.hh"
 #include "mem/port_proxy.hh"
 #include "sim/clocked_object.hh"
 #include "sim/eventq.hh"
@@ -622,6 +624,21 @@

     Cycles syscallRetryLatency;

+    /** This function is used to instruct the memory subsystem that a
+     * transaction should be aborted and the speculative state should be
+ * thrown away. This is called in the transaction's very last breath in + * the core. Afterwards, the core throws away its speculative state and + * resumes execution at the point the transaction started, i.e. reverses
+     * time.  When instruction execution resumes, the core expects the
+     * memory subsystem to be in a stable, i.e. pre-speculative, state as
+     * well. */
+    virtual void
+    htmSendAbortSignal(ThreadID tid, uint64_t htm_uid,
+                       HtmFailureFaultCause cause)
+    {
+        panic("htmSendAbortSignal not implemented");
+    }
+
   // Enables CPU to enter power gating on a configurable cycle count
   protected:
     void enterPwrGating();
diff --git a/src/cpu/o3/cpu.hh b/src/cpu/o3/cpu.hh
index d7d660a..792ffdb 100644
--- a/src/cpu/o3/cpu.hh
+++ b/src/cpu/o3/cpu.hh
@@ -708,7 +708,7 @@
   public:
     // hardware transactional memory
     void htmSendAbortSignal(ThreadID tid, uint64_t htm_uid,
-                            HtmFailureFaultCause cause);
+                            HtmFailureFaultCause cause) override;
 };

 } // namespace o3
diff --git a/src/cpu/simple/atomic.hh b/src/cpu/simple/atomic.hh
index 74d4868..3eb24fa 100644
--- a/src/cpu/simple/atomic.hh
+++ b/src/cpu/simple/atomic.hh
@@ -231,10 +231,11 @@
     }

     void
-    htmSendAbortSignal(HtmFailureFaultCause cause) override
+    htmSendAbortSignal(ThreadID tid, uint64_t htm_uid,
+                       HtmFailureFaultCause cause) override
     {
         panic("htmSendAbortSignal() is for timing accesses, and should "
-              "never be called on AtomicSimpleCPU.\n");
+              "never be called on AtomicSimpleCPU.");
     }

     Fault writeMem(uint8_t *data, unsigned size,
diff --git a/src/cpu/simple/base.hh b/src/cpu/simple/base.hh
index 4e94e5c..8c84ff9 100644
--- a/src/cpu/simple/base.hh
+++ b/src/cpu/simple/base.hh
@@ -190,16 +190,6 @@
* neither really (true) loads nor stores. For this reason the interface * is extended and initiateHtmCmd() is used to instigate the command. */
     virtual Fault initiateHtmCmd(Request::Flags flags) = 0;
-
-    /** This function is used to instruct the memory subsystem that a
-     * transaction should be aborted and the speculative state should be
- * thrown away. This is called in the transaction's very last breath in - * the core. Afterwards, the core throws away its speculative state and - * resumes execution at the point the transaction started, i.e. reverses
-     * time.  When instruction execution resumes, the core expects the
-     * memory subsystem to be in a stable, i.e. pre-speculative, state as
-     * well. */
-    virtual void htmSendAbortSignal(HtmFailureFaultCause cause) = 0;
 };

 } // namespace gem5
diff --git a/src/cpu/simple/timing.cc b/src/cpu/simple/timing.cc
index 8e9f34c..f05b7c4 100644
--- a/src/cpu/simple/timing.cc
+++ b/src/cpu/simple/timing.cc
@@ -1259,9 +1259,10 @@
 }

 void
-TimingSimpleCPU::htmSendAbortSignal(HtmFailureFaultCause cause)
+TimingSimpleCPU::htmSendAbortSignal(ThreadID tid, uint64_t htm_uid,
+                                    HtmFailureFaultCause cause)
 {
-    SimpleExecContext& t_info = *threadInfo[curThread];
+    SimpleExecContext& t_info = *threadInfo[tid];
     SimpleThread* thread = t_info.thread;

     const Addr addr = 0x0ul;
diff --git a/src/cpu/simple/timing.hh b/src/cpu/simple/timing.hh
index 252e6d1..5a21c0e 100644
--- a/src/cpu/simple/timing.hh
+++ b/src/cpu/simple/timing.hh
@@ -327,7 +327,8 @@
     /** hardware transactional memory **/
     Fault initiateHtmCmd(Request::Flags flags) override;

-    void htmSendAbortSignal(HtmFailureFaultCause) override;
+    void htmSendAbortSignal(ThreadID tid, uint64_t htm_uid,
+                            HtmFailureFaultCause) override;

   private:

diff --git a/src/cpu/simple_thread.cc b/src/cpu/simple_thread.cc
index 67756b4..c8a79e3 100644
--- a/src/cpu/simple_thread.cc
+++ b/src/cpu/simple_thread.cc
@@ -171,10 +171,7 @@
 void
SimpleThread::htmAbortTransaction(uint64_t htm_uid, HtmFailureFaultCause cause)
 {
-    BaseSimpleCPU *baseSimpleCpu = dynamic_cast<BaseSimpleCPU*>(baseCpu);
-    assert(baseSimpleCpu);
-
-    baseSimpleCpu->htmSendAbortSignal(cause);
+    baseCpu->htmSendAbortSignal(threadId(), htm_uid, cause);

     // these must be reset after the abort signal has been sent
     htmTransactionStarts = 0;

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/52084
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I23399ea6bbbbabd87e6c8bf7a66d48902745d2cf
Gerrit-Change-Number: 52084
Gerrit-PatchSet: 3
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to