标题几乎概括了它。我需要基于每个线程的缓存命中/未命中之类的东西。我如何获得这些信息? Cachegrind 似乎不起作用,基于这样一个事实,即我的顺序程序给出了执行的 X 指令的计数,以及我的并行程序的 Y 指令的计数,除了 X=Y 之外,一切正常。我假设 Cachegrind 不适用于线程?我可以使用任何其他工具吗?谢谢。
最佳答案
您可以使用 perf 从硬件性能计数器中获取您想要的信息。
尝试:
$ perf stat -e cache-misses,cache-references /bin/ls /tmp/
...
Performance counter stats for '/bin/ls /tmp/':
3,534 cache-misses # 16.605 % of all cache refs
21,283 cache-references
0.001649284 seconds time elapsed
关于linux - 如何测量多线程应用程序中的缓存性能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8996884/