Skip to content

Commit

Permalink
cpu-o3: delete pending wake events if cancel
Browse files Browse the repository at this point in the history
If this instruction is cancelled, the associated wake event should be descheduled.

Change-Id: Ib4c325f42de5874c4cc8c40c4389b9c8985df9f3
  • Loading branch information
happy-lx committed Jan 11, 2025
1 parent 79cacc0 commit cf13024
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
21 changes: 17 additions & 4 deletions src/cpu/o3/issue_queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ IssueQue::checkScoreboard(const DynInstPtr& inst)
if (!scheduler->bypassScoreboard[src->flatIndex()]) [[unlikely]] {
auto dst_inst = scheduler->getInstByDstReg(src->flatIndex());
if (!dst_inst || !dst_inst->isLoad()) {
panic("dst is not load");
panic("dst[sn:%llu] is not load", dst_inst->seqNum);
}
scheduler->loadCancel(dst_inst);
DPRINTF(Schedule, "[sn:%llu] %s can't get data from bypassNetwork, dst inst: %s\n", inst->seqNum,
Expand Down Expand Up @@ -606,15 +606,16 @@ IssueQue::doSquash(const InstSeqNum seqNum)
}
}

Scheduler::SpecWakeupCompletion::SpecWakeupCompletion(const DynInstPtr& inst, IssueQue* to)
: Event(Stat_Event_Pri, AutoDelete), inst(inst), to_issue_queue(to)
Scheduler::SpecWakeupCompletion::SpecWakeupCompletion(const DynInstPtr& inst, IssueQue* to, Scheduler* scheduler)
: Event(Stat_Event_Pri, AutoDelete), inst(inst), scheduler(scheduler), to_issue_queue(to)
{
}

void
Scheduler::SpecWakeupCompletion::process()
{
to_issue_queue->wakeUpDependents(inst, true);
scheduler->specWakeEvents.erase(this);
}

const char*
Expand Down Expand Up @@ -913,7 +914,9 @@ Scheduler::specWakeUpDependents(const DynInstPtr& inst, IssueQue* from_issue_que
}
}
} else {
auto wakeEvent = new SpecWakeupCompletion(inst, to);
auto wakeEvent = new SpecWakeupCompletion(inst, to, this);
// track these pending events
specWakeEvents.insert(wakeEvent);
cpu->schedule(wakeEvent, cpu->clockEdge(Cycles(wakeDelay)) - 1);
}
}
Expand Down Expand Up @@ -983,6 +986,16 @@ Scheduler::loadCancel(const DynInstPtr& inst)
while (!dfs.empty()) {
auto top = dfs.top();
dfs.pop();
// clear pending wake events scheduled by top
for (auto it = specWakeEvents.begin(); it != specWakeEvents.end();) {
auto e = *it;
if (e->inst == top) {
cpu->deschedule(e);
it = specWakeEvents.erase(it);
} else {
it++;
}
}
for (int i = 0; i < top->numDestRegs(); i++) {
auto dst = top->renamedDestIdx(i);
if (dst->isFixedMapping()) {
Expand Down
8 changes: 6 additions & 2 deletions src/cpu/o3/issue_queue.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <cstdint>
#include <list>
#include <string>
#include <unordered_set>

#include <boost/compute/detail/lru_cache.hpp>
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
Expand Down Expand Up @@ -193,11 +194,12 @@ class Scheduler : public SimObject
friend class IssueQue;
class SpecWakeupCompletion : public Event
{
public:
DynInstPtr inst;
Scheduler* scheduler;
IssueQue* to_issue_queue = nullptr;

public:
SpecWakeupCompletion(const DynInstPtr& inst, IssueQue* to);
SpecWakeupCompletion(const DynInstPtr& inst, IssueQue* to, Scheduler* scheduler);
void process() override;
const char* description() const override;
};
Expand Down Expand Up @@ -245,6 +247,8 @@ class Scheduler : public SimObject
void specWakeUpDependents(const DynInstPtr& inst, IssueQue* from_issue_queue);

public:
std::unordered_set<SpecWakeupCompletion*> specWakeEvents;

Scheduler(const SchedulerParams& params);
void setCPU(CPU* cpu);
void resetDepGraph(uint64_t numPhysRegs);
Expand Down

0 comments on commit cf13024

Please sign in to comment.