【性能分析】使用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:ui

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

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

相關文章
相關標籤/搜索