0
$\begingroup$

In computer architecture I'm confused between speculative execution & branch prediction. Are the same or different?

$\endgroup$
5
  • $\begingroup$ According to Wikipedia, predictive execution is one type of predictive execution. $\endgroup$ – Yuval Filmus Jan 17 at 8:09
  • 1
    $\begingroup$ Speculation and prediction are not used on their own, but rather as part of more specific terms. What particular terms do you have in mind? $\endgroup$ – Yuval Filmus Jan 17 at 8:10
  • $\begingroup$ They are used to speed up execution. For example, to predict if branch will be taken or not. $\endgroup$ – user836026 Jan 18 at 0:30
  • $\begingroup$ Great, so branch prediction is one term. Which term involves speculation? Is it speculative execution? $\endgroup$ – Yuval Filmus Jan 18 at 21:12
  • $\begingroup$ yes .. it think speculative execution.. how its different from branch prediction, if its different. $\endgroup$ – user836026 Jan 19 at 1:45
1
$\begingroup$

“Branch prediction” will predict whether a particular branch is taken or not. The prediction can be right or wrong; whoever designs the hardware for it will want the prediction to be correct as often as possible.

Starting with a predicted branch, we don’t know if the instructions we execute should actually be executed, so we start with speculative execution. At some point the processor will learn correctly whether the branch should have been taken or not. If the branch was predicted correctly, the speculative execution is turned into non-speculative. If the branch was predicted incorrectly, all the results of speculative execution are thrown away and you continue with the correct branch.

Car analogy: You drive a car, I have the map. I say “I think you need to turn left” = branch prediction. You turn left = speculative execution. Later I tell you if the turn was correct or wrong.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.