From c679c9c1274684393b7e3d1eeaeba17c9037f722 Mon Sep 17 00:00:00 2001 From: Nicholas Mosier Date: Thu, 25 Apr 2024 11:15:14 -0700 Subject: [PATCH] cpu-o3: prioritize exiting threads when committing (#1056) Fix #1055. Prioritize committing from exiting threads before we consider other threads using the specified SMT commit policy. All instructions in the ROB for exiting threads should already have been squashed. Thus, this ensures that the ROB instruction queues for all exiting threads will be empty at the end of the current cycle, avoiding the assertion failure encountered in #1055. Change-Id: Ib0178a1aa6e94bce2b6c49dd87750e82776639dc --- src/cpu/o3/commit.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/cpu/o3/commit.cc b/src/cpu/o3/commit.cc index 8f8c5f095d..84a92997a1 100644 --- a/src/cpu/o3/commit.cc +++ b/src/cpu/o3/commit.cc @@ -1403,6 +1403,24 @@ ThreadID Commit::getCommittingThread() { if (numThreads > 1) { + // If a thread is exiting, we need to ensure that *all* of its + // instructions will be retired in this cycle, because the + // thread will be removed from the CPU at the end of this cycle. + // To ensure this, we prioritize committing from exiting threads + // before we consider other threads using the specified SMT + // commit policy. + for (ThreadID tid : *activeThreads) { + if (cpu->isThreadExiting(tid) && + !rob->isEmpty(tid) && + (commitStatus[tid] == Running || + commitStatus[tid] == Idle || + commitStatus[tid] == FetchTrapPending)) { + assert(rob->isHeadReady(tid) && + rob->readHeadInst(tid)->isSquashed()); + return tid; + } + } + switch (commitPolicy) { case CommitPolicy::RoundRobin: return roundRobin();