assembly - x86-64:缓存加载和驱逐指令

标签 assembly x86 x86-64 cpu-cache

对于 x86-64 架构,是否有可以将给定内存地址的数据加载到缓存的指令?同样,是否有一条指令可以在给定与该缓存行对应的内存地址(或类似于缓存行标识符)的情况下驱逐该缓存行?

最佳答案

预取数据到缓存中(不加载到寄存器中):

PREFETCHT0 [address]
PREFETCHT1 [address]
PREFETCHT2 [address]

内在:void _mm_prefetch (char const* p, int hint)

insn ref manual和其他指南,了解不同接近提示的含义。 ( 标签 wiki 上的其他链接)。

著名的What Every Programmer Should Know About Memory文章是在 P4 时写的。当前的 CPU 具有更智能的硬件预取器,超线程不仅仅用于运行预取线程。预取线程是一个死主意。除此之外,关于缓存的优秀文章;我用 a modern review 写了一个 SO 答案Ulrich 的原作中发生了哪些变化以及哪些内容仍然相关。搜索其他 SO 帖子和内容以决定何时实际预取。

不要不要过度使用英特尔 IvyBridge 上的软件预取。该特定微架构存在性能错误,只能停用 one prefetch per 43 clocks .


刷新包含给定地址的缓存行:

clflush [address]
clflushopt [address]   ; Newer CPUs only.  Weakly ordered, with higher throughput.

内在:void _mm_clflushopt(void const * p)

有一个 recent question about its performance .

关于assembly - x86-64:缓存加载和驱逐指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36563277/

相关文章:

assembly - 如何在 x86 实模式下正确设置 SS、BP 和 SP?

gcc - 未通过带有 __attribute__((fastcall)) 的寄存器获取从 asm 传递到 C 的函数参数

assembly - 将常量字节值移动到 %ebx 时出错

assembly - HLT 指令导致 QEMU 中的一般保护错误

c - 68HC11 上使用 4 字节数字的斐波那契数列

x86 - 关于 IO-APIC 82093AA

x86 - uop 的引用资料?

assembly - 英特尔 x86_64 程序集 : What is good way to convert 32bit integer to 64bit int?

linux - Linux 上的 Masm32 : Why does mov [bx], ax 可以工作,但 mov [ax], bx (或 mov [bl], al)不行?

assembly - 检查内存访问 x86-64 程序集