Branch Prediction Flashcards
What is Not Taken prediction?
Always predict that the branch is not taken - every processor uses at lease this since it is an easy performance gain
What is the BTB?
Branch Target Buffer - keeps track of where we went to last time we took this branch. Update this table after we’ve determined if we’ve taken the branch or not. Can be used as a predictor or in coordination with one.
What is the structure of the BTB?
Want to keep it small, so maintaining an entry for each instruction is unrealistic. Use least significant bits to index into BTB
What is a 1-bit predictor?
Has a branch history table that keeps track of whether we took this branch last time or not. If taken, has BTB to check where we are going.
What is a 1-bit predictor good and bad for?
Good for when we always (or almost always) are T or NT. Terrible at random N/NT
What is a 2-bit predictor (2BP, 2BC)?
Have a prediction bit and hysteresis (conviction bit). Improvement from 1-bit predictor. Initialization state doesn’t matter much
3+ Bit Predictors
More costly than 2BP, and only improve things when ‘anomalous’ decisions come in streaks. Usually better to stay with 2BP
What aspect of bit-predictors do history predictors aim to improve upon?
Having a higher performance on pattern based behavior
What is a 1-Bit History Predictor?
BHT has 1 bit for the history and 2-2BC. If the history is 0, we look at the first BC, if it’s one, we look at the second. When updating, we update the BC for the history, then change the history to what we observed
What is a 2-Bit History Predictor?
BHT has 2 bits for the history and 4-2BC.
What is an N-Bit History Predictor? What will is predict correctly? What is the cost?
N Bits of history, 2^N-2BC. Will correctly predict all patterns with length <= N+1. Most counters are not used. Cost is (N+2*2^N) bits for each address
What is a PShared predictor?
History with Shared Counters Predictor. P == private history, shared == shared counters. Aims to solve the waste of the n-bit predictor
How is a PShared predictor structured?
- Pattern history table (PHT) - contains just the history bits for each address
- Use PC to index into PHT, XOR address offset with PHT history -> index into BHT (single 2BP)
What are the pros/cons for a PShared predictor?
(+) Allows for many bits in the history table without a counter for each one
(-) possible collisions in BHT
Good for patterns and 8-iteration loop
What is a GShared Predictor?
A predictor with global history and shared predictors. Use a single history to predict all branches (XOR PC with global history)