0
$\begingroup$

Below is a paragraph from a book.

In an ordinary superscalar processor, we would use branch prediction to guess which of the given instructions is to be executed, and go down that path. If the processor guesses wrong, the pipeline must be flushed.

Predication execute all of instructions and once the values of the predicate registers are known, commit only the results of the valid instructions. Thus we make use of additional parallel execution units to avoid the delays due to pipeline flushing.

So each predication and branch prediction has disadvantage each. For predication, we have to WAIT until the values of the predicate registers are known. For branch prediction, if prediction is wrong, the pipeline must be flushed which will cause a DELAY. Seems like both predication and branch prediction needs delay.. But to me.. prediction has a chance to avoid delays when prediction is correct leading to conclusion that prediction is better..Predication always needs waiting.

So how do I tell which one is better?? Under what circumstance should I use predication and branch prediction?

Thank you in advance.

$\endgroup$

2 Answers 2

1
$\begingroup$

The quote from the book doesn't describe how predicated instructions work today. It says that predicated instructions are "executed but only committed if the condition is true". But that would be exactly what branch prediction does, and would lead to exactly the same problems.

Instead, a predicated instruction is implemented as an ordinary instruction which just has one more input. It is always executed and always committed, just the effect of the instruction depends on a condition flag. That means all the mechanism to accelerate execution, out of order execution etc. can be used.

$\endgroup$
0
$\begingroup$

That's not how it works. Modern processors use branch prediction regardless; it's not something you get to choose. When you write a program in assembly language, you get to choose whether to use predicated instructions or not, but branch prediction is not something you choose to use or not use.

Whether it's faster to implement a specific algorithm using predicated instructions or with conditional jumps depends on the specific algorithm and code and architecture. Usually the only way to tell is to try both and measure their performance on a realistic benchmark. It's certainly not something where there is a general answer; it all depends.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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