乱序执行与推测性执行 [英] Out-of-order execution vs. speculative execution

查看:409
本文介绍了乱序执行与推测性执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了有关乱序执行的维基百科页面,并且投机执行.

I have read the wikipedia page about out-of-order execution and speculative exectution.

尽管有相同点和不同点,但我没弄清楚.在我看来,推测性执行在未确定条件值​​的情况下会使用乱序执行.

What I fail to understant though are the similarities and differences. It seems to me that speculative execution uses out-of-order execution when it has not determined the value of a condition for example.

当我阅读Meltdown和Spectre的论文并进行其他研究时,感到困惑. Meltdown文件中指出,Meltdown基于无序执行,而其他一些资源包括有关专门执行的Wiki页面,其中指出Meltdown基于推测执行.

The confusion came when I read the papers of Meltdown and Spectre and did additional research. It is stated in the Meltdown paper that Meltdown is based on out-of-order execution, while some other resources including the wiki page about sepeculative execution state that Meltdown is based on speculative execution.

我想对此做些澄清.

推荐答案

推测性执行和无序执行是正交的.可以按此OoO设计一个处理器,但不是按推测的或按推测的而是按顺序设计的. OoO执行是一种执行模型,其中可以按照可能与程序顺序不同的顺序执行指令.但是,指令仍然按程序顺序退役,因此程序观察到的行为与程序员直观地期望的行为相同. (尽管可以设计一种以某些约束限制以不自然的顺序撤消指令的OoO处理器.有关此思想的基于仿真的研究,请参见:

Speculative execution and out-of-order execution are orthogonal. One could design a processor this OoO but not speculative or speculative but in-order. OoO execution is an execution model in which instructions can be executed in an order that is potentially different from the program order. However, the instructions are still retired in program order so that the program's observed behavior is the same as the one intuitively expected by the programmer. (Although it's possible to design an OoO processor that retires instructions in some unnatural order with certain constraints. See the simulation-based study on this idea: Maximizing Limited Resources: a Limit-Based Study and Taxonomy of Out-of-Order Commit).

广义上讲,推测执行是一种执行模型,在该模型中,即使不知道是否确实需要执行指令(根据程序的控制流程),也可以提取指令并进入管道,甚至开始执行. .该术语通常还用于专门指代管道执行阶段中的推测性执行. Meltdown文件确实在第3页上定义了这些术语:

Speculative execution, broadly speaking, is an execution model in which instructions can be fetched and enter the pipeline and even begin execution without even knowing for sure that they will indeed be required to execute (according to the control flow of the program). The term is also often used to specifically refer to speculative execution in the execution stage of the pipeline. The Meltdown paper does define these terms on page 3:

在本文中,我们更多地涉及投机执行 受限制的含义,指的是指令序列 跟随分支,并使用术语乱序执行来指代 以任何方式在处理器执行操作之前执行操作 提交了所有先前说明的结果.

In this paper, we refer to speculative execution in a more restricted meaning, where it refers to an instruction sequence following a branch, and use the term out-of-order execution to refer to any way of getting an operation executed before the processor has committed the results of all prior instructions.

请注意,指令可以推测性执行,但可以按顺序执行.当流水线的解码阶段识别出条件分支指令时,它可以推测分支及其目标,并从预测的目标位置获取指令.但是,指令也可以按顺序执行.但是,请注意,一旦推测的条件分支指令和从预测路径(或两条路径)中提取的指令到达发布阶段,在所有较早的指令都退出之前,不会发出任何指令.发生这种情况时,处理器将知道预测是否正确,否则将刷新管道.

Note that instructions can be executed speculatively, yet in-order. When the decoding stage of the pipeline identifies a conditional branch instruction, it can speculate on the branch and its target and fetch instructions from the predicted target location. But still, instructions can also be executed in-order. However, note that once the speculated conditional branch instruction and the instructions fetched from the predicted path (or both paths) reach the issue stage, none of them will be issued until all earlier instructions retire. When that happens, the processor would know whether the prediction was correct and flush the pipeline otherwise.

旨在执行简单任务并在嵌入式系统或IoT设备中使用的处理器通常既不是投机也不是OoO.台式机和服务器处理器都是推测性的,也是OoO.在计算领域(移动电话和微控制器)的中间,您可以找到是OoO但不是投机性的处理器(例如

Processors designed to carry out simple tasks and used in embedded systems or IoT devices are typically neither speculative nor OoO. Desktop and server processors are both speculative and OoO. In the middle of the computing spectrum (mobile phones and microcontrollers), you can find processors that are OoO, but not speculative (such as the ARM Cortex-A9). The Intel Bonnell microarchitecture is speculative, but in-order. Speculative execution is particularly beneficial when used with OoO.

当我阅读Meltdown和Spectre的论文时 做了更多的研究.在Meltdown论文中指出 崩溃基于无序执行,而其他一些 包括有关分离执行状态的Wiki页面的资源 Meltdown是基于投机执行的.

The confusion came when I read the papers of Meltdown and Spectre and did additional research. It is stated in the Meltdown paper that Meltdown is based on out-of-order execution, while some other resources including the wiki page about sepeculative execution state that Meltdown is based on speculative execution.

本文所述的Meltdown漏洞需要投机和无序执行.但是,由于存在许多不同的投机和无序执行实现,因此这有点含糊不清. Meltdown不适用于任何类型的OoO或投机执行.例如, ARM11 (在Raspberry Pis中使用)支持某些有限的OoO和推测性执行,但不支持易受攻击.

The Meltdown vulnerability as described in the paper requires both speculative and out-of-order execution. However, this is somewhat a vague statement since there are many different speculative and out-of-order execution implementations. Meltdown doesn't work with just any type of OoO or speculative execution. For example, ARM11 (used in Raspberry Pis) supports some limited OoO and speculative execution, but it's not vulnerable.

请参阅Peter的答案以了解有关Meltdown及其他的其他

See Peter's answer for more details on Meltdown and his other answer.

相关: Superscalar和OoO执行之间有什么区别?.

这篇关于乱序执行与推测性执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆