7

Suppose that I choose perf events instructions, LLC-load-misses, LLC-store-misses. Suppose further that I test a program prog varying its input. Is valgrind supposed to give me the "same" functional results for the same input and the same counter? That is, if one value in perf goes up, the one in valgrind should always do the same? Is there any impact in valgrind being a simulation that I should be aware of during profiling my code?

EDIT: BTW, before people grill me for not experimenting myself, I have to say that I (kinda) have, the problem is that I have a Sandybridge processor, and perf has a "bug" that prevents me from measuring LLC-* events. There is a patch, but I don't feel like recompiling my kernel...

4

1 回答 1

6

好吧,Cachegrind 是一个缓存模拟器。即使它试图模仿您的某些硬件特性(缓存大小、关联性等),它也不会模拟您系统的每一个特性和行为。因此,在某些情况下,您可能会看到一些差异。

例如,Valgrind 的文档指出“Cachegrind 模拟分支预测器,旨在成为 2004 年左右主流桌面/服务器处理器的典型代表”。Sandy Bridge 处理器于 2011 年首次出现,您可以猜测分支预测器自 2004 年以来已经有了很大的改进。

话虽如此,Valgrind 仍然是您工具箱中的绝佳工具。

Sandy Bridge 处理器上 perf 的 LLC 事件有什么问题?我每天在我的 Sandy Bridge 笔记本电脑上使用这些事件,它按预期工作(archlinux 64bits,linux 3.6)。

于 2013-01-10T18:46:52.970 回答