[英]How to find the miss rate in a cache friendly code?
int sumarrayrows(int a[M][N])
{
int i, j, sum = 0;
for (i = 0; i < M; i++)
for (j = 0; j < N; j++)
sum += a[i][j];
return sum;
}
I was wondering how to find the miss rate of any cache friendly code and does measure the size of a cache or a cache block if so how to find the size of it. 我想知道如何找到任何缓存友好代码的未命中率,并测量缓存或缓存块的大小,如果是这样,如何找到它的大小。
Update I figured out how to find the miss rate 更新我想出了如何找到未命中率
Since this uses 4 bytes there will be a 25% chance of a miss rate a[0] = M a[1] = H a[2] = H a[3] = H 由于这使用4个字节,因此将有25%的几率失分率a [0] = M a [1] = H a [2] = H a [3] = H
Depends on your platform. 取决于您的平台。 Most modern CPUs have hardware performance counters which could potentially be used to count cache-misses, but access to these may be awkward.
大多数现代CPU都有硬件性能计数器,这些计数器可能用于计算缓存未命中数,但访问这些可能很尴尬。 Windows, for example, generally expects you to write a kernel-mode driver.
例如,Windows通常希望您编写内核模式驱动程序。
You might be better off getting some decent performance analysis software and running your code through that. 你可能最好得到一些不错的性能分析软件并运行你的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.