首页 > 其他 > 详细

计算机系统结构总结_Branch prediction

时间:2019-11-05 00:14:51      阅读:151      评论:0      收藏:0      [点我收藏+]

 Textbook:
《计算机组成与设计——硬件/软件接口》    HI
《计算机体系结构——量化研究方法》           QR


Branch Prediction

对于下面的指令:

i1:    r1 := r2 / r3
i2:    r2 := r1 / r3
i3:    r3 := r2 - r3
i4:    beq r3, 100        //if r3==0 then GOTO 100

前面i1, i2, i3都是有依赖的,计算起来就很慢。如果在i4的分支语句中使用了branch prediction,就可以不用等r3算出来,直接提前prefetch target instruction了。这在循环中会很有用。

分支预测要做到下面几点:

  • Determine whether it is a branch instruction
  • Predict whether it will be taken or not
  • Predict the target address if taken

那么如何实现branch prediction呢?有下面几种方法:

1. A branch will do exactly what it did last time

就是搞一个hash table,instruction address的least significant bit作为index,该指令有没有跳转作为value。每次新分支指令执行之前,去hash table查找一下对应的value,作为预测结果。

 

 

 

2. 

 

 

 

 

 

 

...

计算机系统结构总结_Branch prediction

原文:https://www.cnblogs.com/pdev/p/11795676.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!