x86-64:缓存加载和驱逐指令
x86-64: Cache load and eviction instruction
对于x86-64架构,是否有指令可以将给定内存地址的数据加载到缓存中?类似地,是否有一条指令可以在给定与该缓存行对应的内存地址(或类似缓存行标识符的内容)的情况下驱逐缓存行?
将数据预取到缓存中(不将其加载到寄存器中):
PREFETCHT0 [address]
PREFETCHT1 [address]
PREFETCHT2 [address]
内在:void _mm_prefetch (char const* p, int hint)
请参阅 insn ref manual and other guides for what the different nearness hints mean. (Other links at the x86 标签维基。
著名的 What Every Programmer Should Know About Memory article was written when P4 was current. Current CPUs have smarter hardware prefetchers, and hyperthreading is useful for much more than just running prefetch threads. Prefetch threads are a dead idea. Other than that, excellent article about caching; I wrote an SO answer with a modern review Ulrich 原作中的更改内容和仍然相关的内容。搜索其他 SO 帖子和内容以决定何时实际预取。
不要不要在 Intel 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。
对于x86-64架构,是否有指令可以将给定内存地址的数据加载到缓存中?类似地,是否有一条指令可以在给定与该缓存行对应的内存地址(或类似缓存行标识符的内容)的情况下驱逐缓存行?
将数据预取到缓存中(不将其加载到寄存器中):
PREFETCHT0 [address]
PREFETCHT1 [address]
PREFETCHT2 [address]
内在:void _mm_prefetch (char const* p, int hint)
请参阅 insn ref manual and other guides for what the different nearness hints mean. (Other links at the x86 标签维基。
著名的 What Every Programmer Should Know About Memory article was written when P4 was current. Current CPUs have smarter hardware prefetchers, and hyperthreading is useful for much more than just running prefetch threads. Prefetch threads are a dead idea. Other than that, excellent article about caching; I wrote an SO answer with a modern review Ulrich 原作中的更改内容和仍然相关的内容。搜索其他 SO 帖子和内容以决定何时实际预取。
不要不要在 Intel 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。