Tuan Ta has submitted this change and it was merged. ( https://gem5-review.googlesource.com/c/public/gem5/+/9626 )

Change subject: cpu: fix how branching is handled when a thread is suspended in MinorCPU
......................................................................

cpu: fix how branching is handled when a thread is suspended in MinorCPU

When a thread is suspended, all instructions after the suspension need
to be discarded since the thread will take a different execution stream
when it wakes up.

To do that, in MinorCPU, whenever a thread gets suspended, we change the
current execution stream by updating the current branch with
BranchData::SuspendThread reason.

Change-Id: I7cdcda22c1cf6e8ac8db8800b7d9ec052433fdf3
Reviewed-on: https://gem5-review.googlesource.com/c/9626
Reviewed-by: Jason Lowe-Power <ja...@lowepower.com>
Reviewed-by: Giacomo Gabrielli <giacomo.gabrie...@gmail.com>
Maintainer: Jason Lowe-Power <ja...@lowepower.com>
---
M src/cpu/minor/execute.cc
1 file changed, 9 insertions(+), 3 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  Giacomo Gabrielli: Looks good to me, approved



diff --git a/src/cpu/minor/execute.cc b/src/cpu/minor/execute.cc
index d7cb475..234a233 100644
--- a/src/cpu/minor/execute.cc
+++ b/src/cpu/minor/execute.cc
@@ -248,7 +248,14 @@
             pc_before, target);
     }

-    if (inst->predictedTaken && !force_branch) {
+    if (thread->status() == ThreadContext::Suspended) {
+        /* Thread got suspended */
+        DPRINTF(Branch, "Thread got suspended: branch from 0x%x to 0x%x "
+            "inst: %s\n",
+            inst->pc.instAddr(), target.instAddr(), *inst);
+
+        reason = BranchData::SuspendThread;
+    } else if (inst->predictedTaken && !force_branch) {
         /* Predicted to branch */
         if (!must_branch) {
             /* No branch was taken, change stream to get us back to the
@@ -1054,8 +1061,7 @@
         !branch.isStreamChange() && /* No real branch */
         fault == NoFault && /* No faults */
         completed_inst && /* Still finding instructions to execute */
- num_insts_committed != commitLimit && /* Not reached commit limit */
-        cpu.getContext(thread_id)->status() != ThreadContext::Suspended
+        num_insts_committed != commitLimit /* Not reached commit limit */
         )
     {
         if (only_commit_microops) {

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

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I7cdcda22c1cf6e8ac8db8800b7d9ec052433fdf3
Gerrit-Change-Number: 9626
Gerrit-PatchSet: 10
Gerrit-Owner: Tuan Ta <q...@cornell.edu>
Gerrit-Assignee: Giacomo Gabrielli <giacomo.gabrie...@gmail.com>
Gerrit-Reviewer: Giacomo Gabrielli <giacomo.gabrie...@gmail.com>
Gerrit-Reviewer: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: Tuan Ta <q...@cornell.edu>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to