Explore essential concepts of branch prediction techniques and their accuracy in modern processors with this quiz. Understand static and dynamic predictors, accuracy factors, and real-world examples to solidify your grasp of computer architecture fundamentals.
Which of the following best describes the main purpose of branch prediction in computer processors?
Explanation: Branch prediction helps processors guess upcoming branch outcomes to keep the instruction pipeline full and efficient, especially in conditional statements. Reducing program size and controlling power consumption are unrelated to branch prediction. Selecting registers pertains to instruction scheduling, not branch prediction.
What is a key difference between static and dynamic branch prediction techniques?
Explanation: Static prediction applies set rules, like always predicting branches as taken or not taken, regardless of actual runtime data. Dynamic prediction uses past execution history to adapt its predictions. Whether they are faster or use more hardware depends on the design; dynamic predictors may need more hardware, not static.
An always-taken static branch predictor assumes that every branch will be taken. In a simple loop such as 'for (i = 0; i u003C 10; i++)', how accurately will this predictor behave?
Explanation: The always-taken predictor will be accurate for all iterations except when the loop finishes and the branch should not be taken. It does not fail every time or only predict one iteration correctly. Thus, most predictions are correct except the last branch evaluation.
What is the main advantage of using a two-bit saturating counter in dynamic branch prediction?
Explanation: A two-bit counter requires two wrong predictions to switch its direction, filtering out mispredictions due to rare changes. It does not affect execution speed or branch target buffer size directly, nor does it replace fetch units.
What is the primary function of a Branch History Table (BHT) in dynamic branch prediction?
Explanation: A BHT records the history of branch results, enabling more accurate future branch predictions. It is not meant for variable storage, power monitoring, or data cache indexing; those are unrelated to its predictive purpose.
Which branch prediction method is most accurate for highly predictable, repetitive branch patterns such as simple 'if' conditions always evaluating true?
Explanation: For branches that consistently behave the same way, a static predictor set to match the observed behavior gives optimal accuracy. Random guessing and alternating predictors would mispredict frequently, while never predicting and always stalling wastes resources.
How does a correlating (or two-level) branch predictor improve over a basic bimodal predictor?
Explanation: Correlating predictors factor in the outcomes of several recent branches to make more informed predictions, unlike bimodal predictors which focus on the local history of one branch. They do not eliminate the BHT, strictly use static decisions, or always predict not-taken.
What is the main role of the Branch Target Buffer (BTB) in branch prediction systems?
Explanation: A BTB supplies the next instruction address for predicted-taken branches, facilitating quick jumps during execution. It does not affect compilation speed, track data instructions, or count all program branches.
Which factor most directly increases the accuracy of dynamic branch predictors?
Explanation: When branches follow consistent patterns, dynamic predictors can learn and predict more accurately. Random guesses reduce accuracy, and main memory size or clock speed do not directly affect branch prediction performance.
What is a likely consequence if a branch predictor frequently mispredicts branches in a pipelined processor?
Explanation: Frequent mispredictions disrupt the instruction flow, requiring pipeline stalls or flushes, which hurt overall performance. They do not alter processor size, power supply, or change the instruction set architecture automatically.