architecture - 了解分支预测

标签 architecture arm branch-prediction

有一些关于分支预测的问题我无法自信地弄清楚。假设我必须使用静态分支预测器。

  1. At which stage of the pipeline should branch prediction happen?
  2. How to know that a prediction has gone wrong? How does the datapath come to know that a misprediction has happened?
  3. If it comes to know that a misprediction has happened, how does it send the signal to take up the not-taken branch?
  4. After it has gone wrong, I have to take up that address that was not taken earlier. In the meanwhile, what if some memory-write or register-write has happened? How to prevent it from happening?

即使建议了一些包含数据路径的适当引用,这也会非常有帮助。提前致谢。

最佳答案

我想可能有很多不同的机制,但有一些快速的答案:

  1. 分支预测当然需要在指令解码之前,在获取阶段发生。否则,您将解码不正确的指令。
  2. 你通常会用预测的分支指令给出额外的信息,比如预测的目标。分支将被执行,如果实际目标与预测目标不匹配,则需要冲洗管道。
  3. 这实际上取决于实现。如果分支被执行,你可以使用真正的目标,就像一个没有被预测到的分支。
  4. 你当然需要一种机制来恢复,或者等待分支解决,直到你写出结果。这会浪费一些时间,但不会像未预测到的分支那么多。

关于architecture - 了解分支预测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36484034/

相关文章:

c# - asp.net mvc 和 Controller 服务架构

php - 当成员也是分层结构时,如何构建类结构?

iPhone/iPad 主动架构?它是什么?为什么它在那里?谁需要它?

arm - 试图了解STM32L4的ADC

cpu - 为什么不只预测两个分支?

c++ - 典型现代 CPU 的分支预测缓冲区有多大?

php - 在MVC中应该如何构建模型?

perl - 与 Perl 的按需进程间通信

embedded - 在用户空间处理 GPIO ARM9 嵌入式 Linux AM1808

c++ - 最小化 C++ 中的分支 - 如果值不为零则递增