Branch Prediction Theory Flashcards
What is branch prediction?
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
What are the two branch prediction techniques?
The static branch prediction and the dynamic branch prediction
What is the static branch prediction?
The action taken or untaken for a branch prediction is fixed at comp time for each branch during the entire execution
What is dynamic branch prediction?
The actions taken or untaken for a branch prediction can change at run time during the program execution
What are the static branch prediction techniques?
Branch always not taken (predicted – not – taken)
Branch always taken (predicted – taken)
Backward taken forward not taken
Profile – driven prediction
Delayed branch
Define the static branch prediction technique, branch always not taken
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.
To what case the branch always not taken technique is most suitable to?
Suitable for if – then – else conditional statements
When do we know that we predicted the branch wrongly and what are the consequences?
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.
Define the branch always taken technique, to what condition is most suitable for, and the main challenge of it
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 do we deal with the challenge of the branch always taken technique
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
Define the backward taken forward not taken technique for static branch prediction
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)
Define the profile – driven prediction technique
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
Define the delay branch technique
It is a shadowing technique. The compiler statically schedules an independent instruction in the branch delay the slot
What are the four ways to schedule an instruction in the branch delays lot?
From before, from after, from target, from fall through
Define the delayed branch technique, using a from before approach
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.