Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

About Branch Prediction of i7

I want to know how Intel i7 processor's branch prediction works?

Currenly, I know the predictor called "dynamic branch prediction".

For 1-bit predictor: The hardware always predicts a branch instruction to take the same direction it took the last time it was executed.

A refined version working better in practice is the 2-bit predictor. In order to further improve the prediction accuracy, 2-bit prediction schemes were introduced. In these schemes the prediction must be wrong twice before it is changed.

Does i7 have the same predictor as the above?

like image 957
Fan Zhang Avatar asked Jun 30 '12 06:06

Fan Zhang


People also ask

What is branch prediction CPU?

Branch prediction is a technique used in CPU design that attempts to guess the outcome of a conditional operation and prepare for the most likely result. A digital circuit that performs this operation is known as a branch predictor. It is an important component of modern CPU architectures, such as the x86.

What is meant by branch prediction?

Branch prediction is an approach to computer architecture that attempts to mitigate the costs of branching. Branch predication speeds up the processing of branch instructions with CPUs using pipelining. The technique involves only executing certain instructions if certain predicates are true.

How fast is branch prediction?

on M1 the predicted-taken branch generally takes 3 cycles and unpredicted but taken has varying cost, depending on jmp length.


1 Answers

Most of what we know about the branch predictor comes from testing. Intel has not released much in the way of details. The misprediction penalty is about 18 clock cycles, so accurate branch prediction is important.

Intel uses a two level branch predictor. The inner level is believed to be unchanged from the Core 2 CPUs.

The outer level is more sophisticated and can even correctly predict loops with fixed counts up to 64. Two 18-bit global history buffers are used. One contains all jumps that have been taken at least once. The other contains the most important jumps. (The number of entries in these buffers is unknown.)

Note that indirect jumps and calls have their own predictor.

like image 67
David Schwartz Avatar answered Oct 23 '22 17:10

David Schwartz