【性能分析】使用Intel VTune Amplifier

本文转自 https://software.intel.com/zh-cn/blogs/2010/11/10/amplxe-cl/
版权归原作者所有,如原作者有任何不允许转载之理由,本文将自行删除。

Intel® VTune™ Amplifier XE 2011 是新一代的性能分析工具,含图形界面以方便分析结果。但有时我们基于二点原因需要使用命令行来收集性能数据和进行分析:

1.含图形界面的工具自身消耗系统的资源

2.用户需要做自动(回溯)性能收集和分析的工作(Run Script),及产生报告

准备工作:

Windows环境下:Command Prompt > $Amplifier XE 2011\ampxe-vars.bat

Linux环境下:source  $vtune_amplifier_xe/amplxe-vars.sh

命令行句法

amplxe-cl <action-option> [modifier-options] 

解释

<action-option> 表示动作的类型,可以是下列之一:collect, collect-list, command, finalize, help, import, knob-list, report, report-list, version。常用的如“-collect” , “-report”, “-collect-list”

[modifier-option] 可以是以下一个或多个选项: allow-multiple-runs, callee-attribution-mode, csv-delimiter, cumulative-threshold-percent, data-limit, [no-]discard-raw-data, quiet, duration, filter, [no-]follow-child,  format, group-by, knob, limit, mrte-mode, report-output, result-dir,  resume-after, search-dir, start-paused, target-duration-type,  target-pid, target-process, user-data-dir, verbose

<target> 表示被分析的应用程序

[target options] 是指应用程序的参数

应用实例

1.列出本机所有支持的分析类型

amplxe-cl –collect-list

amplxe-cl –report-list; 可支持的报告类型

2.输入、分析VTune(TM)Performance Analyzer 的结果

如:amplxe-cl -import tbsf141.tb5 -r r001

如:amplxe-cl -report pmu-events -r r001 -group-by function

3.热点收集

amplxe-cl -collect hotspots -result-dir r0001hs -- ./gsexample2a datafile.txt

amplxe-cl -collect concurrency -r r0002cc -search-dir all:rp=/home/ompPrimes -- ./ompPrime1.icc

amplxe-cl -collect locksandwaits -user-data-dir /tmp -r r0003lw -- ./ompPrime1.icc

amplxe-cl -collect lightweight-hotspots -r r0004lh -- ./primes.gcc

amplxe-cl -collect nehalem_memory-access -duration 10; 系统热点收集

amplxe-cl -collect lightweight-hotspots -target-process gnome-power-manager -duration 10; 对象应用程序的性能数据收集

【注】如果目标对象是Service Application,建议手工加载程序,然后用Attach-to-process

amplxe-cl -collect concurrency -duration n -target-process program,或

amplxe-cl -collect concurrency -duration n -target-pid pid

特别的,最好使用“detach”去终止它(Duration可以设的长一点)

如:amplxe-cl -command detach -r r003hs

4.热点分析

4.a amplxe-cl -report hotspots -result-dir r001hs -group-by function -filter module=gsexample2a ; 仅列出模块gsexample2a相关的热点函数

4.b amplxe-cl -report hotspots -result-dir r001hs -call-stack-mode=all -group-by function; 列出所有的热点函数,包含链接库的

4.c amplxe-cl -report perf-detail -r r000hs -cumulative-threshold-percent 80; 列出占处理器时间80%的函数(模块)信息

4.d  amplxe-cl -report perf -csv-delimiter="," -r r000hs; 结果中加入分隔符

5.并行分析

5.a  amplxe-cl -report summary -r r0002cc; 显示汇总信息

5.b  amplxe-cl -report hotspots -r r0002cc -group-by function; 显示热点函数的并行度

5.c amplxe-cl -report hotspots -r r0002cc -format text -limit 1; 输出格式为text, 仅显示 Top 1

5.d amplxe-cl -report hotspots -r r0002cc -call-stack-mode=all -group-by function; 显示所有函数

6.锁和等待分析

6.1 amplxe-cl -report summary -user-data-dir /tmp -r r0003lw; 显示汇总结果

6.2 amplxe-cl -report hotspots -r r0003lw -group-by function-sync-obj;sync objects 的等待分析

7.Lowweight(轻量级)的热点及基于PMU Event分析

amplxe-cl -report hw-events -r r0004lh -group-by function -csv-delimiter=","

8.系统热点分析

amplxe-cl -report hw-events -r r007ma -group-by process

amplxe-cl -report hw-events -r r007ma -filter module=Xvnc -group-by function

9.目标模块的分析(要求目标模块带调试信息)

amplxe-cl -report hw-events -r r010lh -group-by function -filter module=gnome-power-manager

另:

1. 命令行上直接设定PMU的Events(不使用预定义的分析类型),进行性能数据收集,参看这篇文章

2. 热点分析中,自定义采样时间间隔,参看这篇文章

3. 如果工作目录不含 :执行文件,符号文件 和 源代码,需要对结果重新处理。如:Using “amplxe-cl -finalize --search-dir all:rp=new-dir -r result-dir” to solve this problem. You could use "bin", "sym", "src" instead of "all" if you only need to do one of them.

4. Now XE 2013 supports stack-sampling with hardware event-based sampling, add options "-knob enable-stack-collection=true -knob enable-call-counts=true"

5. Since XE 2013 Update 10, the user can know hot addresses or hot addresses with basic block from report. See this example:

# amplxe-cl -collect advanced-hotspots -- ./primes.icc

# amplxe-cl -report hw-events -filter module=primes.icc -source-object function=findPrimes -group-bybasic-block,address

posted @ 2015-09-09 14:48  赵子清  阅读(5485)  评论(0编辑  收藏  举报