prefetching数据缓存为X86-64 [英] Prefetching data to cache for x86-64
问题描述
在我的应用程序,在一个点上,我需要内存中的数据(MBS 100年代)的一个大的连续的块上进行计算。我在想什么是保持prefetching我的计划将在未来的触摸,所以,当我在该部分执行计算,该数据已经在缓存中的块的一部分。
In my application, at one point I need to perform calculations on a large contiguous block of memory data (100s of MBs). What I was thinking was to keep prefetching the part of the block my program will touch in future, so that when I perform calculations on that portion, the data is already in the cache.
有人可以给我如何用gcc来实现一个简单的例子?我读 _mm_ prefetch
地方,但不知道如何正确使用它。另外请注意,我有一个多核系统,但每个核心将并行工作内存的不同区域。
Can someone give me a simple example of how to achieve this with gcc? I read _mm_prefetch
somewhere, but don't know how to properly use it. Also note that I have a multicore system, but each core will be working on a different region of memory in parallel.
推荐答案
GCC
使用内建函数作为低级指令的接口。特别是对于你的情况<一个href=\"http://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Other-Builtins.html#Other-Builtins\"><$c$c>__builtin_$p$pfetch$c$c>.但是,你在访问模式是不容易自动predict情况下使用这种时候只有应该看到一个可测量的差异。
gcc
uses builtin functions as an interface for lowlevel instructions. In particular for your case __builtin_prefetch
. But you only should see a measurable difference when using this in cases where the access pattern is not easy to predict automatically.
这篇关于prefetching数据缓存为X86-64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!