David Kanter 非常出色的英特尔 Sandybridge 文章涵盖了 the memory subsystem and cache architecture:L1D 是英特尔常用的回写,而每个内核的 L2 也是回写。 L3 也是如此(这是一个由芯片上所有内核共享的大型包容性缓存)。
另请参阅Which cache mapping technique is used in intel core i7 processor?,了解有关各代 Intel CPU 的更多详细信息。
AMD 采用了截然不同的方法:Their L1 cache is write-through, but with a tiny 4k write-combining-cache. 在 AMD 上不断重写大于 4k 的缓冲区将在(慢)L2 而不是 L1 上出现瓶颈。
Agner 博客上的帖子中的一张海报声称 BD 的 L2 也是直写的,但 Paul Clayton 的 cmets 对此答案不同意。 (我倾向于相信保罗。)
AMD Ryzen 幸运的是使用了普通的回写 32kiB 8 路 L1D,带有私有回写 512kiB L2。 L3 是共享的 8MB 受害者缓存。它是回写的,但受害者缓存意味着数据仅在从 L1/L2 驱逐时才进入它,而不是直接用于加载/预取。每个 4 核的核心集群(CCX 模块)都有自己的 8MB L3,以及latency/bandwidth between cores in different clusters is bad。
关于缓存层次结构的意义远不止回写与直写,尽管大多数差异对于单线程程序并不重要。 (除非操作系统的进程调度程序在 Ryzen 上的集群之间移动它们,在这种情况下它很糟糕。)
在我的 SnB 系统上:
sudo dmidecode
产生的输出包括:
Handle 0x0005, DMI type 7, 19 bytes
Cache Information
Socket Designation: L1-Cache
Configuration: Enabled, Not Socketed, Level 1
Operational Mode: Write Back
Location: Internal
Installed Size: 32 kB
Maximum Size: 32 kB
Supported SRAM Types:
Other
Installed SRAM Type: Other
Speed: Unknown
Error Correction Type: None
System Type: Unified
Associativity: 8-way Set-associative
所以缓存是回写的事实至少在 BIOS 中,如果这是值得信赖的。我很好奇它在 AMD CPU 上显示了什么,或者 BIOS 编写者是否倾向于“编造一些东西”,有时会在那里输入错误的值。
正如this question 指出的那样,L2 的信息有点虚假:它总计私有 256k-per-core L2:
Handle 0x0006, DMI type 7, 19 bytes
Cache Information
Socket Designation: L2-Cache
Configuration: Enabled, Not Socketed, Level 2
Operational Mode: Varies With Memory Address
Location: Internal
Installed Size: 1024 kB
Maximum Size: 1024 kB
Supported SRAM Types:
Other
Installed SRAM Type: Other
Speed: Unknown
Error Correction Type: None
System Type: Unified
Associativity: 8-way Set-associative
Handle 0x0007, DMI type 7, 19 bytes
Cache Information
Socket Designation: L3-Cache
Configuration: Enabled, Not Socketed, Level 3
Operational Mode: Unknown
Location: Internal
Installed Size: 6144 kB
Maximum Size: 6144 kB
Supported SRAM Types:
Other
Installed SRAM Type: Other
Speed: Unknown
Error Correction Type: None
System Type: Unified
Associativity: Other
这是在 i5-2500k(四核 SnB 和 6MiB 的 L3)上