4 ms·
Is this correct? "Without branch prediction, we then expect the “average” instruction to take branch_pct * 1 + non_branch_pct * 20 = 0.8 * 1 + 0.2 * 20 = 0.8 +
by seedragons 9y ago
Is this correct? "Without branch prediction, we then expect the “average” instruction to take branch_pct * 1 + non_branch_pct * 20 = 0.8 * 1 + 0.2 * 20 = 0.8 + 4 = 4.8 cycles"
other than branch_pct and non_branch_pct being reversed, this seems to be assuming that 100% of branches are guessed incorrectly. Shouldn't something like 50% be used, to assume a random guess? ie 0.8 * 1 + 0.2 * (0.5 * 20 + 0.8 * 1)=2.96
- 0xffff2 9y agoIt's correct if you take "without branch prediction" to include any pipelining of instructions after a branch. The very first branch prediction algorithm ("predict taken") is to simply enable pipelining by assuming the generally more likely branch. >...this seems to be assuming that 100% of branches are guessed incorrectly... Rather, it's assuming that 100% of branches are not guessed at all.
- seedragons 9y agoAh I see, I assumed it was a penalty for only mis-guessed, not the number of cycles required to evaluate the statement. Thanks!
- simcop2387 9y agoThis is talking about the case where there is no branch prediction. So every branch incurs the penalty of a bad prediction because it never tries to do the favorable action, instead it stalls and waits on the result to do the branch.