CPU 架构是否使用元数据?

Do any CPU architectures use Metadata?

我最近一直在研究一个名为 Mill 的 CPU 架构的概念。

The Mill(虽然它可能是 vaporware)uses metadata 用于 CPU 中的各种事物,例如软件推测负载产生标记为 的值不是结果NaR)。如果后面的指令试图以非推测方式存储该结果,硬件会检测到并出错。

我想知道是否有其他 CPU 在架构中使用元数据方面与此相似。

我所知道的一些随机示例,当然不是详尽无遗的列表。 IDK 如果有任何使用元数据来处理 Mill 所做的所有事情。 Mill 所做的一些事情是独一无二的,但一些想法已经以类似的形式出现在其他 ISA 中。


是的,出于与 Mill 相同的软件推测原因,IA-64 Itanium 也有 not-a-thing 加载结果,如果您阅读它们会出错。它的架构师将其描述为 EPIC ISA。 (EPIC = 显式并行指令计算,与 CISC 或 RISC 相对。它也是 VLIW。)From Wikipedia:

The architecture implements a large number of registers:

  • 128 general integer registers, which are 64-bit plus one trap bit ("NaT", which stands for "not a thing") used for speculative execution. 32 of these are static, the other 96 are stacked using variably-sized register windows, or rotating for pipelined loops. gr0 always reads 0.

  • 128 floating point registers. The floating point registers are 82 bits long to preserve precision for intermediate results. Instead of a dedicated "NaT" trap bit like the integer registers, floating point registers have a trap value called "NaTVal" ("Not a Thing Value"), similar to (but distinct from) NaN. These also have 32 static registers and 96 windowed or rotating registers. fr0 always reads +0.0, and fr1 always reads +1.0.

所以对于整数,确实有单独的元数据。对于 FP,元数据是带内编码的。


其他与软件可见推测相关的元数据示例包括:

x87 FPU 有 8 个架构寄存器,但普通指令将它们作为寄存器堆栈访问,其中 st(0) 的底层寄存器由 x87 状态字中的字段确定。 (即元数据在架构上是可见的,可以使用 fincstp to rotate the "revolver barrel".) See http://www.ray.masmcode.com/tutorial/fpuchap1.htm for a good diagram and intro to the x87 design. Also, x87 has a free / in-use flag for each register; trying to load into an already in use register produces an FP exception (and a NaN if exceptions are masked). Normally the in-use flag is cleared by "popping" the register stack with fstp to store and pop, or whatever, but there's also ffree 修改以将任何 x87 寄存器标记为免费。


微架构(仅性能效果):

显然,微体系结构必须保留有关正在运行的指令的大量信息,例如它们是否已完成执行。但是至少有一个关于 data 的元数据的有趣案例,而不是代码:

在 AMD Bulldozer 系列和 Bobcat/Jaguar 中,SIMD FPU 显然保留了一些额外的元数据以及实际的架构寄存器值。 As Agner Fog explains in his microarchitecture PDF, (Bulldozer-family) 19.11 不同执行域之间的数据延迟:

There is a large penalty when the output of a floating point calculation is input to a floating point calculation with a different precision, for example if the output of a double precision floating point addition is input to a single precision addition. This has hardly any practical significance since such a sequence is most likely to be a programming error, but it indicates that the processor stores extra information about floating point numbers beyond the 128 bits in an XMM register. This effect is not seen on Intel processors.

这可能与以下事实有关:当从 FMA 单元指令转发到另一条 FMA 指令时,Bulldozer 的 FP 延迟降低了 1 个周期,例如 mulps 转发到 addps 而没有 sqrtpsxorps 介于两者之间。

此外,各种 AMD uarches 在 L1 I-cache 中标记了指令边界,减少了重复解码/延迟。英特尔 Silvermont 也这样做。

有许多标记的架构,主要是研究项目。有些具有最少的标记,例如 Tera MTA,它支持每个 64 位字四个额外位——一个 "full/empty" 位、一个 "indirection" 位和两个 "trap" 位。 "full/empty" 位是最重要的,它允许比缓存系统更高效的生产者-消费者事务。

我见过的最先进的标记架构还在开发中。 它最初是由 BAE 系统公司在 DARPA 资助下开发的,在 "CRASH-SAFE" 项目下有许多重要且有趣的 developments/papers:

这是一种 "tag rich" 方法,每 64 个数据位有 64 个标记位,并且能够在需要时将 64 个标记位用作指向任意大标记结构的指针。该方法为 "data" 和 "tag" 提供了几乎完全独立的流水线,"security pipeline" 将来自输入数据的标签与输入指令类型相结合,以确定执行是否有效,如果有效, 输出标签应该是什么。

在 Crash-Safe 项目(~2015 年)结束后,Draper Industries 接手了该项目,将其转变为 "Dover Inherently Secure Processor"(https://www.draper.com/explore-solutions/inherently-secure-processor). In 2017, Draper spun off https://www.dovermicrosystems.com/,该技术将继续为名为 "CoreGuard" 的各种架构。我感兴趣的两个项目是:

第一个很有趣,因为它将想法推向了 RISC-V 开源处理器社区,第二个是因为行业重量级 (Cadence) 和 link 的支持(在-赞赏)Tensilica架构。

这种方法背后的动机是安全性,一旦您意识到这在安全领域的作用 "fix" 就很难理解为什么您甚至会 尝试 以任何其他方式制造计算机。但它不仅限于安全性——标签对于非常高级的数据类型化方法非常有用,例如 "dimensional analysis" 或用于多维数组的不同维度的单独索引变量类型。