Branch Prediction Theory Flashcards

1
Q

What is branch prediction?

A

It is a method for solving a branch hazard that assumes a given outcome for the branch and proceeds speculatively from that assumption rather than waiting to certify the actual branch outcome

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

What are the two branch prediction techniques?

A

The static branch prediction and the dynamic branch prediction

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

What is the static branch prediction?

A

The action taken or untaken for a branch prediction is fixed at comp time for each branch during the entire execution

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

What is dynamic branch prediction?

A

The actions taken or untaken for a branch prediction can change at run time during the program execution

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

What are the static branch prediction techniques?

A

Branch always not taken (predicted – not – taken)

Branch always taken (predicted – taken)

Backward taken forward not taken

Profile – driven prediction

Delayed branch

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

Define the static branch prediction technique, branch always not taken

A

We assume the branche as not taken, thus the sequential instruction flow that we have fetched can continue as if the branch condition was not satisfied.

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

To what case the branch always not taken technique is most suitable to?

A

Suitable for if – then – else conditional statements

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

When do we know that we predicted the branch wrongly and what are the consequences?

A

If the branch outcome at the end of the ID stage will be taken/untaken the prediction might be incorrect (misprediction). In that case we flush the instruction already fetched (it is turned into a NOP) in order to fetch the instruction at the branch target address.

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

Define the branch always taken technique, to what condition is most suitable for, and the main challenge of it

A

In the branch always taken technique we assume every branch as taken. it is most suitable for backward branches (such as do – while loop branches) that are most likely taken. The main challenge of it is that we need to know the branch target address (BTA) to start fetching and executing instructions at the target.

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

How do we deal with the challenge of the branch always taken technique

A

We need to add in the iF stage a branch target buffer, cache where to store the predicted target address based on the previous branch behavior

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

Define the backward taken forward not taken technique for static branch prediction

A

The prediction is based on the branch direction. Backward – going branches are predicted as taken (such as do – while loops) .While forward – going branches are predicted as not taken (such as IF – then – else conditional statements)

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

Define the profile – driven prediction technique

A

In this case, we assume to have a profile of the behavior of the target application application program by several early runs by using different data set. The branch prediction is based the profiled information. The profile – driven prediction method requires compiler hint bits included in the branch instruction format

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

Define the delay branch technique

A

It is a shadowing technique. The compiler statically schedules an independent instruction in the branch delay the slot

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

What are the four ways to schedule an instruction in the branch delays lot?

A

From before, from after, from target, from fall through

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

Define the delayed branch technique, using a from before approach

A

The branch Village lot is scheduled with an independent instruction from before the branch. The instruction in the branch delays lot is always executed, whether the branch will be taken or not taken.

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

Define the delayed branch technique, using a from target approach, describe also what happens in case of a miss prediction and when this technique is preferred

A

The branch delays lot is scheduled with one instruction from the target of the branch (branch taken). This technique is preferred when the branch is taken with high probability. If the branch is untaken (misprediction) the instruction in the delays slot needs to be flushed, or it must be OK to execute when the branch goes in the unexpected direction.

17
Q

Describe the delayed branch technique, using a from fall – through approach

A

The branch delay slot is scheduled with one instruction from the fall - through path (branch not taken)

18
Q

How are the four dynamic branch prediction techniques interconnected?

A

We need to have a mechanism to decide whether to take or not the branch (branch outcome predictor), which corresponds to BHD, CBP, and two level adaptive branch predictors, we also need a buffer to store the branch target address (branch target predictor), which corresponds to the branch target buffer (BTB).

19
Q

Describe the 1-bit branch history table

A

It is a table containing one bit for each entry that says whether the branch was recently taken or not taken. This table is indexed by the lower portion K – bit off the address of the branch instruction.

20
Q

Describe the 1-bit branch history table mechanism

A

If the prediction turns out to be wrong, the prediction bit is inverted and stored back

21
Q

Describe the 2-bit branch history table

A

It is a 2-bit branch history table used to encode four stages in order to change the prediction after two miss predictions

22
Q

Describe the 2-bit branch history table mechanism

A

Supposing that a branch history table is in the strongly taken prediction stage, once a branch output is miss predicted, The stage is changed to weekly taken. Another miss prediction leads to a strongly not taken prediction, while a correct prediction changes the state back to strongly taken. Finally, when in strongly not taken stage, a miss predict lead to a weekly not taken stage, while a correct prediction maintains the mechanism in its current strongly not taken stage.

23
Q

Describe the correlating branch predictor

A

In the branch history table method we used only the recent behavior of a single branched to predict the future behavior of that branch. In these method, otherwise, we use the recent behavior of other branches to predict the current branch behavior.

The rational is that we try to exploit the correlation existing amount different branches

24
Q

Define the two – level adaptive branch predictor

A

There is a two level history, a Global (branch history, register, BHR), and a local (pattern history table, BHT).the first one is used to index the first one.

The branch history register is a k-bit shift register, which records the outcomes of the k most recent branches

25
Q

What is the difference between a GA predictor and a GShare predictor

A

In the GA predictor the indexation of the PHT he done exclusively by the BHR, while for the GShare predictor we aim to correlate the branch instruction address with the Global history by XORing the low – order 4-bit off the branch address with the BHR to index the PHT

26
Q

Define the branch target buffer

A

Branch target buffer or branch target predictor is a cashe storing the predicted target address for taken – branch instructions

27
Q

Describe the branch target buffer mechanism

A

The BTB is accessed in the IF stage by using the address of the fetched branch instruction to index the cache, then tags are used for the associative look up