Google Benchmark负面配置计数器

发布于 2025-01-27 21:47:02 字数 1334 浏览 2 评论 0原文

我正在将Google/Benchmark用于一个项目,而我刚刚开始使用-benchmark_perf_counters flag。显然,我做错了什么,因为perf柜台通常是负面的。我假设这是一个带溢出的问题,但是我仍然不太了解计数器如何起作用。

例如,第一个基准测试中的高速缓存0是如何,然后在第二个基准上进行-372k?这些价值对我来说都不是有意义的。

(两个基准的参数非常相似,并且运行时)

我在Ubuntu上运行18.04 W/ Intel(R)Xeon(R)Gold 6138 CPU。 Google基准版本为1.6.1,我安装了libpfm4-dev。我正在调用我的基准二进制w/ - benchmark_perf_counters =循环,说明,cach-misses

-----------------------------------------------------------------------------------------------------
Benchmark                                           Time             CPU   Iterations UserCounters...
-----------------------------------------------------------------------------------------------------
bit::shift_left (small) (AA)                     3.15 ns         3.15 ns    221185726 CACHE-MISSES=0 CYCLES=11.0005 INSTRUCTIONS=15
bit::shift_left (small) (UU)                     2.65 ns         2.65 ns    254254663 CACHE-MISSES=-372.709k CYCLES=553.131k INSTRUCTIONS=372.709k
boost::shift_left (small) (AA)                   2.71 ns         2.71 ns    258007443 CACHE-MISSES=-367.288k CYCLES=-367.288k INSTRUCTIONS=3.87586n
std::shift_left (small)                          23.5 ns         23.5 ns     29812478 CACHE-MISSES=-3.17853M CYCLES=-102.703 INSTRUCTIONS=-972.747n

I'm using Google/benchmark for a project, and I just started playing around with the --benchmark_perf_counters flag. Clearly I'm doing something wrong, since the perf counters are often negative. I'm assuming it's an issue w/ overflow, but I still don't quite understand how the counters work to begin with.

For example, how is CACHE-MISSES 0 on the first benchmark, and then -372k on the second? Neither of those values make sense to me.

(the two benchmarks have very similar parameters and runtime)

I'm running on Ubuntu 18.04 w/ an Intel(R) Xeon(R) Gold 6138 CPU. Google benchmark version is 1.6.1 and I have libpfm4-dev installed. I'm calling my benchmark binary w/ --benchmark_perf_counters=CYCLES,INSTRUCTIONS,CACH-MISSES

-----------------------------------------------------------------------------------------------------
Benchmark                                           Time             CPU   Iterations UserCounters...
-----------------------------------------------------------------------------------------------------
bit::shift_left (small) (AA)                     3.15 ns         3.15 ns    221185726 CACHE-MISSES=0 CYCLES=11.0005 INSTRUCTIONS=15
bit::shift_left (small) (UU)                     2.65 ns         2.65 ns    254254663 CACHE-MISSES=-372.709k CYCLES=553.131k INSTRUCTIONS=372.709k
boost::shift_left (small) (AA)                   2.71 ns         2.71 ns    258007443 CACHE-MISSES=-367.288k CYCLES=-367.288k INSTRUCTIONS=3.87586n
std::shift_left (small)                          23.5 ns         23.5 ns     29812478 CACHE-MISSES=-3.17853M CYCLES=-102.703 INSTRUCTIONS=-972.747n

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫瑾少女 2025-02-03 21:47:02

我也有同样的问题!升级到最新版本的Google Benchmark(1.7.0)修复了它,现在我的Perf Counter结果很有意义。

I had this same problem! Upgrading to the latest version of Google Benchmark (1.7.0) fixed it and now my perf counter results make sense.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文