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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM