Skip to content

Commit 4bb4bc6

Browse files
Yakkhiniboran-xu
andcommitted
cpu-o3: ideal 2-taken implementation
Change-Id: I39d54a0621d139cc00a156b02a6d7d888d9b15f0 Co-authored-by: Xu Boran <xuboran@bosc.ac.cn>
1 parent a1d519e commit 4bb4bc6

File tree

2 files changed

+40
-31
lines changed

2 files changed

+40
-31
lines changed

src/cpu/pred/btb/decoupled_bpred.cc

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -136,44 +136,51 @@ DecoupledBPUWithBTB::tick()
136136
return;
137137
}
138138

139-
// 1. Request new prediction if FSQ not full and we are idle
140-
if (bpuState == BpuState::IDLE && !streamQueueFull()) {
141-
if (blockPredictionPending) {
142-
DPRINTF(Override, "Prediction blocked to prioritize resolve update\n");
143-
dbpBtbStats.predictionBlockedForUpdate++;
144-
blockPredictionPending = false;
145-
} else {
146-
requestNewPrediction();
147-
bpuState = BpuState::PREDICTOR_DONE;
139+
int predsRemainsToBeMade = enableTwoTaken ? 2 : 1;
140+
unsigned tempNumOverrideBubbles = 0;
141+
142+
while (predsRemainsToBeMade > 0) {
143+
// 1. Request new prediction if FSQ not full and we are idle
144+
if (bpuState == BpuState::IDLE && !streamQueueFull()) {
145+
if (blockPredictionPending) {
146+
DPRINTF(Override, "Prediction blocked to prioritize resolve update\n");
147+
dbpBtbStats.predictionBlockedForUpdate++;
148+
blockPredictionPending = false;
149+
} else {
150+
requestNewPrediction();
151+
bpuState = BpuState::PREDICTOR_DONE;
152+
}
148153
}
149-
}
150154

151-
// 2. Handle pending prediction if available
152-
if (bpuState == BpuState::PREDICTOR_DONE) {
153-
DPRINTF(Override, "Generating final prediction for PC %#lx\n", s0PC);
154-
numOverrideBubbles = generateFinalPredAndCreateBubbles();
155-
bpuState = BpuState::PREDICTION_OUTSTANDING;
155+
// 2. Handle pending prediction if available
156+
if (bpuState == BpuState::PREDICTOR_DONE) {
157+
DPRINTF(Override, "Generating final prediction for PC %#lx\n", s0PC);
158+
numOverrideBubbles = generateFinalPredAndCreateBubbles();
159+
bpuState = BpuState::PREDICTION_OUTSTANDING;
156160

157-
// Clear each predictor's output
158-
for (int i = 0; i < numStages; i++) {
159-
predsOfEachStage[i].btbEntries.clear();
161+
// Clear each predictor's output
162+
for (int i = 0; i < numStages; i++) {
163+
predsOfEachStage[i].btbEntries.clear();
164+
}
160165
}
161-
}
162166

163-
if (bpuState == BpuState::PREDICTION_OUTSTANDING && numOverrideBubbles > 0) {
164-
tage->dryRunCycle(s0PC);
165-
}
167+
if (bpuState == BpuState::PREDICTION_OUTSTANDING && numOverrideBubbles > 0) {
168+
tage->dryRunCycle(s0PC);
169+
}
166170

167-
// check if:
168-
// 1. FSQ has space
169-
// 2. there's no bubble
170-
// 3. PREDICTION_OUTSTANDING
171-
if (validateFSQEnqueue()) {
172-
// Create new FSQ entry with the current prediction
173-
processNewPrediction();
171+
// check if:
172+
// 1. FSQ has space
173+
// 2. there's no bubble
174+
// 3. PREDICTION_OUTSTANDING
175+
if (validateFSQEnqueue()) {
176+
// Create new FSQ entry with the current prediction
177+
processNewPrediction();
174178

175-
DPRINTF(Override, "FSQ entry enqueued, prediction state reset\n");
176-
bpuState = BpuState::IDLE;
179+
DPRINTF(Override, "FSQ entry enqueued, prediction state reset\n");
180+
bpuState = BpuState::IDLE;
181+
}
182+
183+
predsRemainsToBeMade--;
177184
}
178185

179186
// Decrement override bubbles counter

src/cpu/pred/btb/decoupled_bpred.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ class DecoupledBPUWithBTB : public BPredUnit
146146

147147
unsigned numOverrideBubbles{0};
148148

149+
bool enableTwoTaken{true};
150+
149151
bool validateFSQEnqueue();
150152

151153
void processNewPrediction();

0 commit comments

Comments
 (0)