0
$\begingroup$

I have a question about predication and branch prediction.

I've emailed my professor regarding this and he replied me that predication has a less instructions than branch prediction.

So I tried making an example of my on but I'm not sure if this is right..

I've assumed for predication it has 'if' and 'else' each having 100 instructions. Then either right or wrong, it will waste 100 instructions.

For prediction(since this has more instructions), I've assumed it has 'if' and 'else' each having 300 instructions doing exactly the same thing as the predication above.

My questions is..

  1. Is it even possible to make 300 instructions to 100??

  2. In above case, if predication has to win over the benefit of branch prediction, accuracy of prediction should be below 66.6%. (300*0.3333=100) Is this correct?

  3. If so, when deciding which would be better off than which, does it has to be based on accuracy of a prediction or the size? Reason why I am mentioning size is because during the lecture, I remember my professor saying "use predication in small size loops..."

Thanks in advance..

$\endgroup$
1
$\begingroup$

You are absolutely, completely on the wrong path here.

Predicated instructions are used to avoid branching. A predicated instruction avoids the cost of a branch plus possible penalty for a mispredicted branch.

If you have 100 instructions on the if and the else side, then you would need 200 predicated instructions instead of 100 unpredicated instructions to save a branch and possible mispredicted branch penalty. 200 vs. 100. That's not going to save you anything.

What on earth makes you think you would have 200 predicated instructions, and 300 unpredicated instructions on each path? I'd say you are completely misunderstanding what your professor is saying there.

I strongly suggest that you download an Intel or ARM instruction manual and study what predicated instructions are doing, because right now I have the impression that you are operating blindly without any understanding.

Maybe it would help if you wrote down how you would (in an assembly language of your choice, or an invented one) translate "if x > 0 then y = 1 else z = 2" using a conditional branch, and using predicated instructions.

$\endgroup$
  • $\begingroup$ Thank you for your reply! But could you help me one more time? Predicated instructions are used to avoid branching yes. But we need to run both instructions for the predicated execution..(!cond) and (cond)..this both. Am I wrong in this point? Mind my English..Maybe I am not delivering my intentions properly $\endgroup$ – kyung sub Song Apr 22 '18 at 12:50

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.