Branch Prediction and Pipeline Recovery

Explain why a processor predicts control flow and estimate a workload’s average cycle cost from misprediction rate and recovery cost.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Predict to keep the front of the pipeline busy
  2. Model the penalty per committed instruction

Predict to keep the front of the pipeline busy

Before a conditional branch resolves, fetching can continue on a predicted next path. If the prediction is right, that work can remain useful. If it is wrong, the processor discards work from the wrong path and restarts from the correct location according to its architecture. A simple predictor can remember recent outcomes, or maintain a small saturating tendency to avoid changing direction on every isolated anomaly.

Model the penalty per committed instruction

If 20 percent of committed instructions are branches, five percent of those are mispredicted, and each misprediction costs ten cycles, the independent additive estimate is \(0.2\cdot0.05\cdot10=0.1\) extra cycles per instruction. Actual costs can overlap other stalls. Pipeline throughput supplies the unperturbed baseline. Speculation security describes defensive guarantees that must consider effects beyond the retired architectural instructions.[1][2]

References

  1. RISC-V International, The RISC-V Instruction Set Manual: Unprivileged Architecture ↩
  2. MIT OpenCourseWare, Computation Structures ↩