CLFLUSH()的酷睿i3或者i7处理器 [英] clflush() in i3 or i7 processors
问题描述
是否有可能使用的i3 / i7处理器的指令CLFLUSH /功能清空缓存并检查是否缓存为空或不?如果是这样的 - 请建议用法的正确格式(在C直接或内联汇编在C)
Is it possible to use the clflush instruction/function in i3/i7 processors to the flush the cache and check if the cache is empty or not?? If so - please suggest a correct format of usage (in C directly or inline assembly in C)
有人告诉我,CLFLUSH不正常工作超越Core 2 Duo处理器。
我从这个链接(如下)已经被重定向后,说明了这个问题------->
I was told that clflush does work properly beyond core 2 duo processors. I am stating this question after having been redirected from this link (below) ------->
¨<一个href=\"http://stackoverflow.com/questions/6041271/is-there-a-way-to-check-whether-the-processor-cache-has-been-flushed-recently\">Is有没有办法来检查是否处理器高速缓存最近被刷新?¨
我的结果不匹配。这是我得到的结果:
my results are not matching as expected. This is what I am getting these results:
83花蜱
的花了66蜱的
的刷新:52花蜱的
用了45蜱
-------------------> cpu的怎么能少取蜱已经清空缓存后? (参考线2条,而且我已经得到的结果3)
-------------------> how can the cpu take less ticks after having flushed the cache? (refer to line 2 and 3 of the results that i have gotten)
推荐答案
RDTSC
不是序列化指令,因为这样的测量结果不准确。作为一个快速黑客可以插入 CPUID
通话,照顾太多更新撞列表:
rdtsc
isn't a serializing instruction, as such the measurement is not accurate. As a quick hack you can insert a cpuid
call, taking care to update the clobber list too:
asm volatile ("cpuid; rdtsc" : "=a" (a), "=d" (d) : : "ebx", "ecx");
至少对我来说,改变了输出以符合预期。
At least for me, that changed the output to match expectations.
这篇关于CLFLUSH()的酷睿i3或者i7处理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!