Skip to content

Commit d5537bd

Browse files
committed
cpu-pred: smt support for decoupled bpu
1 parent 10ff8c0 commit d5537bd

File tree

10 files changed

+427
-332
lines changed

10 files changed

+427
-332
lines changed

src/cpu/o3/fetch.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,8 @@ Fetch::processCacheCompletion(PacketPtr pkt)
629629
}
630630

631631
// Verify fetchBufferPC alignment with the supplying FSQ entry.
632-
if (fetchBuffer[tid].valid && dbpbtb->ftqHasHead()) {
633-
const auto &stream = dbpbtb->ftqHead();
632+
if (fetchBuffer[tid].valid && dbpbtb->ftqHasFetching(0)) {
633+
const auto &stream = dbpbtb->ftqFetchingTarget(0);
634634
if (fetchBuffer[tid].startPC != stream.startPC) {
635635
panic("fetchBufferPC %#x should be aligned with FSQ startPC %#x",
636636
fetchBuffer[tid].startPC, stream.startPC);
@@ -782,8 +782,8 @@ Fetch::lookupAndUpdateNextPC(const DynInstPtr &inst, PCStateBase &next_pc)
782782
// Decoupled+BTB-only: compute next PC directly from the supplying FSQ entry.
783783
ThreadID tid = inst->threadNumber;
784784
assert(dbpbtb);
785-
assert(dbpbtb->ftqHasHead());
786-
const auto &stream = dbpbtb->ftqHead();
785+
assert(dbpbtb->ftqHasFetching(0));
786+
const auto &stream = dbpbtb->ftqFetchingTarget(0);
787787

788788
const Addr curr_pc = next_pc.instAddr();
789789
assert(stream.startPC <= curr_pc && curr_pc < stream.predEndPC);
@@ -1542,11 +1542,11 @@ Fetch::handleIEWSignals()
15421542
if (!resolveQueue.empty()) {
15431543
auto &entry = resolveQueue.front();
15441544
unsigned int stream_id = entry.resolvedFTQId;
1545-
dbpbtb->prepareResolveUpdateEntries(stream_id);
1545+
dbpbtb->prepareResolveUpdateEntries(stream_id, 0);
15461546
for (const auto resolvedInstPC : entry.resolvedInstPC) {
1547-
dbpbtb->markCFIResolved(stream_id, resolvedInstPC);
1547+
dbpbtb->markCFIResolved(stream_id, resolvedInstPC, 0);
15481548
}
1549-
bool success = dbpbtb->resolveUpdate(stream_id);
1549+
bool success = dbpbtb->resolveUpdate(stream_id, 0);
15501550
if (success) {
15511551
dbpbtb->notifyResolveSuccess();
15521552
resolveQueue.pop_front();
@@ -1565,7 +1565,7 @@ Fetch::handleCommitSignals(ThreadID tid)
15651565
if (fromCommit->commitInfo[tid].doneFtqId) {
15661566
DPRINTF(DecoupleBP, "Commit stream Id: %lu\n", fromCommit->commitInfo[tid].doneFtqId);
15671567
assert(dbpbtb);
1568-
dbpbtb->update(fromCommit->commitInfo[tid].doneFtqId, tid);
1568+
dbpbtb->commit(fromCommit->commitInfo[tid].doneFtqId, tid);
15691569
}
15701570
return false;
15711571
}
@@ -1700,8 +1700,8 @@ Fetch::buildInst(ThreadID tid, StaticInstPtr staticInst,
17001700
instruction->isMov());
17011701
assert(dbpbtb);
17021702
DPRINTF(DecoupleBP, "Set instruction %lu with fetch id %lu\n",
1703-
instruction->seqNum, dbpbtb->ftqHeadId());
1704-
instruction->setFtqId(dbpbtb->ftqHeadId());
1703+
instruction->seqNum, dbpbtb->ftqHeadId(0));
1704+
instruction->setFtqId(dbpbtb->ftqHeadId(0));
17051705

17061706
#if TRACING_ON
17071707
if (trace) {
@@ -1757,7 +1757,7 @@ bool
17571757
Fetch::checkDecoupledFrontend(ThreadID tid)
17581758
{
17591759
assert(dbpbtb);
1760-
if (!isTraceMode() && !dbpbtb->ftqHasHead()) {
1760+
if (!isTraceMode() && !dbpbtb->ftqHasFetching(0)) {
17611761
dbpbtb->addFtqNotValid();
17621762
DPRINTF(Fetch, "Skip fetch when FSQ head is not available\n");
17631763
setAllFetchStalls(StallReason::FTQBubble);
@@ -2051,7 +2051,7 @@ Fetch::sendNextCacheRequest(ThreadID tid, const PCStateBase &pc_state) {
20512051
}
20522052

20532053
assert(dbpbtb);
2054-
const auto &stream = dbpbtb->ftqHead();
2054+
const auto &stream = dbpbtb->ftqFetchingTarget(0);
20552055
const Addr start_pc = stream.startPC;
20562056
fetchBuffer[tid].startPC = start_pc;
20572057

src/cpu/o3/fetch.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ class Fetch
968968

969969
// Decoupled+BTB-only: fetch consumes the supplying FSQ entry directly.
970970
// If no head is available, fetch stalls (no extra "supply" state machine).
971-
bool ftqEmpty() const { return !dbpbtb || !dbpbtb->ftqHasHead(); }
971+
bool ftqEmpty() const { return !dbpbtb || !dbpbtb->ftqHasFetching(0); }
972972

973973
// Number of dynamic instructions fetched within the current FTQ entry.
974974
// Used to explicitly notify the BPU when an entry is consumed (Phase5 prep).

src/cpu/o3/trace/TraceFetch.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,8 @@ TraceFetch::chooseWrongPathNopSize(ThreadID tid, Addr pc)
536536
bool taken = false;
537537
if (fetch.isBTBPred()) {
538538
assert(fetch.dbpbtb);
539-
if (fetch.dbpbtb->ftqHasHead()) {
540-
const auto &stream = fetch.dbpbtb->ftqHead();
539+
if (fetch.dbpbtb->ftqHasFetching(tid)) {
540+
const auto &stream = fetch.dbpbtb->ftqFetchingTarget(tid);
541541
block_end = stream.predEndPC;
542542
taken_pc = stream.predBranchInfo.pc;
543543
taken = stream.predTaken;

src/cpu/pred/SConscript

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Source('btb/btb_mgsc.cc')
105105
Source('btb/folded_hist.cc')
106106
Source('btb/ras.cc')
107107
Source('btb/btb_ubtb.cc')
108+
Source('btb/ftq.cc')
108109
# Source('btb/uras.cc')
109110
Source('general_arch_db.cc')
110111
DebugFlag('FreeList')

src/cpu/pred/btb/common.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ struct FetchTarget
451451
*/
452452
struct FullBTBPrediction
453453
{
454+
ThreadID tid;
454455
Addr bbStart;
455456
std::vector<BTBEntry> btbEntries; // for BTB, only assigned when hit, sorted by inst order
456457
// for conditional branch predictors, mapped with lowest bits of branches

0 commit comments

Comments
 (0)