分析 C++ 多线程应用程序
您是否使用过诸如 Intel Vtune 分析器之类的分析工具?
您对 Linux 和 Windows 上的 C++ 多线程应用程序有何建议? 我主要对缓存未命中、内存使用、内存泄漏和 CPU 使用感兴趣。
我使用 valgrind(仅在 UNIX 上),但主要用于查找内存错误和泄漏。
Have you used any profiling tool like Intel Vtune analyzer?
What are your recommendations for a C++ multi threaded application on Linux and windows? I am primarily interested in cache misses, memory usage, memory leaks and CPU usage.
I use valgrind (only on UNIX), but mainly for finding memory errors and leaks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
以下是多线程应用程序的好工具。 您可以尝试评估副本。
- 内存验证器,此处
- AQTime,此处
编辑:英特尔线程检查器可用于诊断数据争用、死锁、停滞线程、废弃锁等。请耐心分析结果,因为很容易混淆。
一些提示:
Following are the good tools for multithreaded applications. You can try evaluation copy.
- Memory Validator, here
- AQTime , here
EDIT: Intel thread checker can be used to diagnose Data races, Deadlocks, Stalled threads, abandoned locks etc. Please have lots of patience in analyzing the results as it is easy to get confused.
Few tips:
在 Linux 上,尝试 oprofile。
它支持各种性能计数器。
在 Windows 上,AMD 的 CodeAnalyst(免费,与 VTune 不同)值得一看。
但它仅支持 AMD 硬件上的事件分析
(在 Intel CPU 上,它只是一个方便的基于计时器的分析器)。
一位同事最近尝试了英特尔 Parallel Studio(测试版)并评价它有利地
(它在某些代码中发现了一些有趣的并行性相关问题)。
On Linux, try oprofile.
It supports various performance counters.
On Windows, AMD's CodeAnalyst (free, unlike VTune) is worth a look.
It only supports event profiling on AMD hardware though
(on Intel CPUs it's just a handy timer-based profiler).
A colleague recently tried Intel Parallel Studio (beta) and rated it favourably
(it found some interesting parallelism-related issues in some code).
VTune 为您提供了有关处理器正在执行的操作的大量详细信息,有时我发现很难只见树木。 VTune 不会报告内存泄漏。 为此,您需要 purify plus,或者如果您可以在 Linux 机器上运行,则 valgrind 可以很好地解决内存泄漏问题,而且价格也很优惠。
VTune 显示两种视图,一种是有用的表格视图,另一种我认为只是供销售人员给人们留下深刻印象,但没有那么有用。
对于快速且便宜的选择,我会选择 valgrind。 Valgrind 也有一个缓存研磨部分,但我没有使用它,但怀疑它也非常好。
干杯,
马丁.
VTune give you a lot of details on what the processor is doing and sometimes I find it hard to see the wood for the trees. VTune will not report on memory leaks. You'll need purify plus for that, or if you can run on a Linux box valgrind is good for memory leaks at a great price.
VTune shows two views, one is useful the tabular one, the other I think is just for sales men to impress people with but not that useful.
For quick and cheap option I'd go with valgrind. Valgrind also has a cache grind part to it but i've not used it, but suspect its very good also.
cheers,
Martin.
您可以尝试 AMD CodeXL 的 CPU 分析器。 它是免费的,适用于 Windows 和 Linux。
AMD CodeXL 的 CPU 分析器取代了不再支持的 CodeAnalyst 工具(timday 的上述答案中提到了该工具)。
如需了解更多信息和下载链接,请访问:AMD CodeXL 网页。
You can try out AMD CodeXL's CPU profiler. It is free and available for both Windows and Linux.
AMD CodeXL's CPU profiler replaces the no longer supported CodeAnalyst tool (which was mentioned in an answer above given by timday).
For more information and download links, visit: AMD CodeXL web page.
我将为 valgrind 提供另一个答案,尤其是带有 UI 的 callgrind 部分。 它可以通过分析每个线程的缓存未命中等来处理多个线程。他们还有一个名为 helgrind 的多线程错误检查器,但我从未使用过它,也不知道它有多好。
I'll put in another answer for valgrind, especially the callgrind portion with the UI. It can handle multiple threads by profiling each thread for cache misses, etc. They also have a multi-thread error checker called helgrind, but I've never used it and don't know how good it is.
Rational PurifyPlus 套件包括经过充分验证的泄漏检测器和非常好的分析器。 不过,我不确定它是否会降低到缓存未命中的程度 - 您可能需要 VTune。
PurifyPlus 可在各种 Unices 和 Windows 上使用,因此它应该可以满足您的要求,但不幸的是,与 Valgrind 相比,它不是免费的。
The Rational PurifyPlus suite includes both a well-proven leak detector and pretty good profiler. I'm not sure if it does go down to the level of cache misses, though - you might need VTune for that.
PurifyPlus is available both on various Unices and Windows so it should cover your requirements, but unfortunately in contrast to Valgrind, it isn't free.
对于简单的分析 gprof 非常好..
For simple profiling gprof is pretty good..