Page 116 - Computer_Science_F5
P. 116

Table 2.7: Branch outcomes with a 2-bit prediction scheme
               Iteration BHT prediction       Actual branch Outcome update
               1         11 (Strongly taken)  Taken          Correct prediction (No update)
               2         11 (Strongly taken)  Taken          Correct prediction (No update)
          FOR ONLINE READING ONLY
               3         11 (Strongly taken)  Taken          Correct prediction (No update)        Chapter Two: Performance and optimisation of computer processor
               4         11 (Strongly taken)  Taken          Correct prediction (No update)

               5         11 (Strongly taken)  Taken          Correct prediction (No update)
               6         11 (Strongly taken)  Taken          Correct prediction (No update)
               7         11 (Strongly taken)  Taken          Correct prediction (No update)
               8         11 (Strongly taken)  Taken          Correct prediction (No update)
               9         11 (Strongly taken)  Not taken      Incorrect prediction (Update to 10
                                                             (Weakly taken))
               10        10 (Weakly taken)    Taken          Correct prediction (Update to 11
                                                             (Strongly taken))



                                                         2.  2-Bit BHT Simulation: Simulate
                   Exercise 2.7                             on paper the behavior of a 2-bit
               1.  You are working on a processor           Branch History Table (BHT) for the
                   design  that  utilizes  dynamic          provided loop. Assume the initial
                   branch prediction. The processor         BHT prediction state is “Strongly
                   encounters the following loop code:      Not Taken” (00)
                   for (int i = 0; i < 10; i++) {            (a)  Create a  table  with  the
                                                                 following columns: Iteration,
                     if (i > 5) {                                Actual Branch, BHT
                      // Code for the second half of the loop    Prediction (before the update),
                     }                                           and Outcome update (after
                                                                 execution).
                   }                                         (b)  Fill out the table for the first
                   (a)  Analyse the loop behavior                five iterations of the loop.
                       and identify how many times       3.  Based on your simulation in
                       the conditional branch (“if (i       question 2, calculate the prediction
                       > 5)”) will be taken during a        accuracy of the 2-bit BHT for the
                       single loop iteration. Explain       first five iterations of the loop.
                       your answer.                      4.  Briefly discuss the impact of branch

                   (b)  Which approach would be             prediction accuracy on processor
                                                            performance. How can improved
                       more suitable for the given          prediction accuracy benefit real-
                       loop, and why?                       world applications?


                                                    107
               Student’s Book  Form Five



     Computer Science Form 5.indd   107                                                     23/07/2024   12:33
   111   112   113   114   115   116   117   118   119   120   121