如何清除L1,L2和L3缓存? [英] How to clear L1, L2 and L3 caches?
问题描述
我正在做一些缓存性能测量,我需要确保缓存在计时之前没有有用的数据。
假设L3缓存是10MB足以创建10M / 4 = 2,500,000个浮点数的向量,遍历整个该向量,对数字求和,并且在遍历向量迭代之前将其中的任何数据的整个缓存清空。
b $ b是的,这应足以刷新有用数据的 L3
缓存。 p>
我已经做过类似的测量,并通过使用英特尔的缓存计数器进行交叉验证,验证我是否产生预期的 L3
在我的测试期间缓存未命中。
如果你想绝对确定,你也应该使用计数器。特别是,您可以通过在大多数英特尔架构中使用事件选择2EH,Umask 41H
来测量最后一级高速缓存未命中。
请参阅 Intel手册。
I am doing some cache performance measuring and I need to ensure the caches are empty of "useful" data before timing.
Assuming an L3 cache is 10MB would it suffice to create a vector of 10M/4 = 2,500,000 floats, iterate through the whole of this vector, sum the numbers and that would empty the whole cache of any data which was in it prior to iterating through the vector?
Yes, that should be sufficient for flushing the L3
cache of useful data.
I have done similar types of measurements and cross-verified by using Intel's cache counters to verify that I incur the expected number of L3
cache misses during my tests.
If you want to absolutely sure, you should also use the counters. In particular, you can measure last-level cache misses by using Event select 2EH, Umask 41H
in most Intel architectures.
See the Intel Manual for details on these counters.
这篇关于如何清除L1,L2和L3缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!