Sunday, 28 January 2018

cpu architecture - When will dynamic branch prediction be useful?




For static branch prediction one always assume that the branch is not taken, while for dynamic branch prediction if the branch is taken before then it is more likely to be taken again. But I cannot come up with a situation that this is useful? What application will benefit from this? Why not just use static branch prediction?


Answer



    boolean b = compute something;
:
for (int j=0; j<1000000; j++)
if (b) one statement;
else another statement;



The if will cause a conditional branch with the same taken/not taken result each time, but that may vary from one run to the next.



(I know one could write that code a little better with the if controlling a couple of if-free for-loops, but that's not the point here)


No comments:

Post a Comment

casting - Why wasn&#39;t Tobey Maguire in The Amazing Spider-Man? - Movies &amp; TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...