From 65f63e7b69cdd906e1fc48056bb365bd687c3e44 Mon Sep 17 00:00:00 2001 From: Daniel Gerzhoy Date: Tue, 3 Nov 2020 15:28:18 -0500 Subject: [PATCH] cpu-o3: Fixed halt assertion failure Halting the O3 CPU would cause an assertion failure because instructions were not finished being squashed in the ROB. Change-Id: I8b8c375d0e520861af3657249de987de2451b6f1 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/37676 Reviewed-by: Jason Lowe-Power Reviewed-by: Bobby R. Bruce Maintainer: Bobby R. Bruce Tested-by: kokoro --- src/cpu/o3/cpu.cc | 18 ++++++++++++++++++ src/cpu/o3/rob_impl.hh | 12 +++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/cpu/o3/cpu.cc b/src/cpu/o3/cpu.cc index c910cc487..4068b306d 100644 --- a/src/cpu/o3/cpu.cc +++ b/src/cpu/o3/cpu.cc @@ -717,6 +717,15 @@ FullO3CPU::haltContext(ThreadID tid) deactivateThread(tid); removeThread(tid); + // If this was the last thread then unschedule the tick event. + if (activeThreads.size() == 0) { + if (tickEvent.scheduled()) + { + unscheduleTickEvent(); + } + lastRunningCycle = curCycle(); + _status = Idle; + } updateCycleCounters(BaseCPU::CPU_STATE_SLEEP); } @@ -795,6 +804,15 @@ FullO3CPU::removeThread(ThreadID tid) rename.clearStates(tid); iew.clearStates(tid); + // Flush out any old data from the time buffers. + for (int i = 0; i < timeBuffer.getSize(); ++i) { + timeBuffer.advance(); + fetchQueue.advance(); + decodeQueue.advance(); + renameQueue.advance(); + iewQueue.advance(); + } + // at this step, all instructions in the pipeline should be already // either committed successfully or squashed. All thread-specific // queues in the pipeline must be empty. diff --git a/src/cpu/o3/rob_impl.hh b/src/cpu/o3/rob_impl.hh index d4a02b598..73c8a4bff 100644 --- a/src/cpu/o3/rob_impl.hh +++ b/src/cpu/o3/rob_impl.hh @@ -338,8 +338,18 @@ ROB::doSquash(ThreadID tid) bool robTailUpdate = false; + unsigned int numInstsToSquash = squashWidth; + + // If the CPU is exiting, squash all of the instructions + // it is told to, even if that exceeds the squashWidth. + // Set the number to the number of entries (the max). + if (cpu->isThreadExiting(tid)) + { + numInstsToSquash = numEntries; + } + for (int numSquashed = 0; - numSquashed < squashWidth && + numSquashed < numInstsToSquash && squashIt[tid] != instList[tid].end() && (*squashIt[tid])->seqNum > squashedSeqNum[tid]; ++numSquashed) -- 2.30.2