Out of Order Pipelines (Control) Flashcards
What 3 factors do speculative execution consist of?
- Target prediction
- Condition prediction (i.e. taken or not taken)
- Validation and recovery
What does a Branch Target Buffer do?
Stores the target addresses of previously taken branches/jumps
How does a branch target buffer work?
- An entry is added to the BTB when a branch/jump is first taken
- For subsequent branches/jumps, the entry is used early in the pipeline to fetch the predicted path
- Branch/jump is resolved in the EXECUTE stage to verify target and update entry
What is the drawback of target prediction using a branch target buffer?
Indirect jumps - the same jump instruction can have multiple targets which leads to mispredictions
Explain the Return Address Stack (RAS).
The RAS is used to store return addresses from jalr instructions, which are in itself used in function calls. When we reach a function call, push the return address on the stack. If we have a function return, pop the return address from the stack
Describe a drawback of the RAS
Mispredicted calls or returns could potentially corrupt the RAS
How do we integrate RAS with checkpointing?
The RAS top-of-stack-pointer and top-of-stack-content can be added to the branch checkpoint structure
What is a target cache (TC) with reference to target prediction?
A target cache (TC) is a separate branch target buffer used for indirect jumps. It remembers multiple targets per jr instruction.
How does a target cache (with reference to target prediction) work?
The target cache remembers multiple targets per jr instruction. It uses the branch target history to distinguish between likely targets. A Target History Register (THR) shifts in the low-order bits of the last n jump targets. The THR contents is then XOR’d with the PC. The lower bits of the result of the XOR is used to index the TC with the upper bits acting as the tag
List 2 static methods for condition prediction.
- Predict taken if pc-relative offset is negative (since it might be the bottom of a loop); predict not-taken otherwise
- Compiler inserts hint into instruction (maybe in the form of a bit)
What binary values represent strongly not taken, weakly not taken, weakly taken and strongly taken in the pattern history table?
00, 01, 10, 11
If I have a pattern history as follows:
1110 1110 1110…
where 1 indicates taken and 0 indicates not-taken, what will be the 2-bit value stored in the
a. 7th index
b. 11th index
c. 14th index
Assume it has already “warmed up” (run enough times to stabilize and not change)
a. 00
b. 11
c. 11
Explanation: 7 = 4’b0111. We have a 0 after the 3 1’s so we predict SNT = 00
List 2 drawbacks of local predictors.
(Hint: Local predictors store the result of the last n iterations of a branch condition)
- Aliasing can occur based on low-order PC bits
- Aliasing can occur based on same history patterns
What are global branch predictors and how do they differ from local predictors?
Global predictors detect correlated branch behavior (behavior influenced by other branch decisions). They save the last n branch decisions (of any branch instr) which differs from local predictors since those are PC specific
What is the “history table” equivalent in a global branch predictor?
Global history register