运行算法时检测 CPU 缓存未命中的最佳方法是什么?
我们的算法性能不佳,我们认为这是因为 CPU 缓存未命中。然而,我们无法证明这一点,因为我们没有任何方法来检测它们。有没有办法知道算法产生了多少 CPU 缓存未命中?我们可以将其移植到任何可以让我们检测到它们的语言。
提前致谢。
We have an algorithm which is performing poorly and we believe it's because of CPU cache misses. Nevertheless, we can't prove it because we don't have any way of detecting them. Is there any way to tell how many CPU cache misses an algorithm produces? We can port it to any language which could allow us to detect them.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
找出此类问题的最简单方法是使用分析器并收集与缓存相关的性能计数器。
我建议检查以下工具:
是否可以看到你的算法的整体结构(如果不是太长的话)?
Easiest way to find out such kind of issues is to use profilers and collect cache related performance counters.
I would recommend to check following tools:
Is it possible to see the overall structure of your algorithm (if it is not too long)?
Intel CPU 保留性能计数器,您可以使用一些汇编指令提取这些计数器。
您能否 (1) 静态系统上的基线缓存未命中,(2) 运行程序并进行比较?
请参阅 Intel 指令集参考 第 18 节第 15 页 (18-15),了解您必须编写的汇编程序。
Intel CPUs keep performance counters that you can extract with some assembler instructions.
Could you (1) baseline cache misses on a quiescent system, (2) run the program and compare?
See Volume 3B of the Intel Instruction Set Reference Section 18 Page 15 (18-15) for the assembler you would have to write up.