Sunday, January 28, 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

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...