Question: Consider the following code segment within a loop body: if ( n % 2 == 0 ) // branch 1 a++; if ( n %
Consider the following code segment within a loop body:
if ( n % 2 == 0 ) // branch 1
a++;
if ( n % 10 == 0 ) // branch 2
b++;
Assume that the following list of 10 values of n is to be processed by 10 iterations of this loop: 18, 29, 30, 41, 52, 60, 79, 80, 91, 100
(1) List the predictions for the following branch prediction schemes from (a) to (d)
(2) Calculate the prediction accuracies for each scheme (i.e. (a) to (d))
(a) Always taken.
(b) Always not taken.
(c) 1-bit predictor, initialized to predict taken.
(d) 2-bit predictor, initialized to weakly predict taken.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
