1

I am wondering if it is possible to force a cache flush within c using linux x86. I have read several answers answering how to do this within the shell or using asm/cache.h (requiring me to write a linux module...)

I am using the PAPI library which allows me to get very close to the exact number of clock cycles that a given block of code takes to execute. However, since I want to time some extremely short functions I need to run the functions many times for accurate statistics (the timing function call takes longer than the code within the blocks takes to execute). By running the code multiple times the cache is speeding up the execution of successive calls of the same block of code and I would like to prevent this!

4

1 回答 1

0

除了将其他内容加载到缓存之外,我不知道任何标准方法可以做到这一点。我通常的解决方法是简单地处理一些足够大的东西来“冷却”缓存,比如矩阵乘法。

于 2014-02-10T16:17:57.153 回答