Branch Prediction Flashcards

1
Q

What is Not Taken prediction?

A

Always predict that the branch is not taken - every processor uses at lease this since it is an easy performance gain

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the BTB?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the structure of the BTB?

A

Want to keep it small, so maintaining an entry for each instruction is unrealistic. Use least significant bits to index into BTB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a 1-bit predictor?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a 1-bit predictor good and bad for?

A

Good for when we always (or almost always) are T or NT. Terrible at random N/NT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a 2-bit predictor (2BP, 2BC)?

A

Have a prediction bit and hysteresis (conviction bit). Improvement from 1-bit predictor. Initialization state doesn’t matter much

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

3+ Bit Predictors

A

More costly than 2BP, and only improve things when ‘anomalous’ decisions come in streaks. Usually better to stay with 2BP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What aspect of bit-predictors do history predictors aim to improve upon?

A

Having a higher performance on pattern based behavior

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a 1-Bit History Predictor?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a 2-Bit History Predictor?

A

BHT has 2 bits for the history and 4-2BC.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is an N-Bit History Predictor? What will is predict correctly? What is the cost?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a PShared predictor?

A

History with Shared Counters Predictor. P == private history, shared == shared counters. Aims to solve the waste of the n-bit predictor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How is a PShared predictor structured?

A
  1. Pattern history table (PHT) - contains just the history bits for each address
  2. Use PC to index into PHT, XOR address offset with PHT history -> index into BHT (single 2BP)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the pros/cons for a PShared predictor?

A

(+) 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a GShared Predictor?

A

A predictor with global history and shared predictors. Use a single history to predict all branches (XOR PC with global history)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a GShared predictor good for?

A

Correlated branches (when one branch depends on the outcome of another)

17
Q

What is a tournament predictor?

A

Contains two good predictors and a 2BC (meta-predictor). 2BC keeps track of which prediction we should use. Outcome is updated for each predictor, and meta is updated based on which one was right (no change if both were right/wrong)

18
Q

What is a hierarchical predictor?

A

Contains a good and okay predictors. Update okay predictor for every branch, update good predictor only when the okay one does poorly (don’t want to use the good one if you don’t have to). Better than tournament predictor

19
Q

What is a RAS Predictor?

A

Return Address Stack. Has a small stack (Return Address Table, “RAT”). When a function is called, its return address is pushed onto the stack. If it becomes full, wrap around to the beginning.

20
Q

How do we know if an instruction is a return instruction (and therefore we should use the RAS predictor)?

A
  1. can use a simple predictor
  2. Can use precoding - when processor fetches instruction from memory, it stores it in the cache as well as whether or not it’s a RET