mcpField
I
intel-vtune-amd-uprof

intel-vtune-amd-uprof

github.com/mohitmishra786開発269480 回インストール18 週間前に更新
リポジトリ

intel-vtune-amd-uprof について

Intel VTune と AMD uProf で CPU マイクロアーキテクチャを分析するためのエージェント向けガイドです。ホットスポットやパイプライン、メモリー、スレッド、I/O、ルーフライン分析で性能ボトルネックを調べます。

主な機能

  1. 01ホットスポットと CPU 時間の分析
  2. 02マイクロアーキテクチャとパイプライン停止の診断
  3. 03キャッシュ、DRAM 帯域幅、NUMA の分析
  4. 04スレッドと I/O 性能の分析
  5. 05ルーフラインモデルによる評価

活用シーン

  1. 01CPU 時間を多く使う関数の特定
  2. 02コード内のパイプライン停止の診断
  3. 03メモリー帯域幅とキャッシュアクセスの確認
  4. 04HPC コードの演算・メモリー制約の評価

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill intel-vtune-amd-uprof

インストール後、Claude Code で/intel-vtune-amd-uprofを入力して読み込まれたか確認します。

詳細

Intel VTune & AMD uProf

目的

Intel VTune Profiler(無料の Community Edition)と AMD uProf を使った CPU マイクロアーキテクチャプロファイリングをエージェントに案内します。ホットスポットの特定、マイクロアーキテクチャ分析、メモリアクセスパターンの最適化、パイプラインストールの診断、ルーフラインモデル分析を扱います。

トリガー

  • 「Intel VTune を使ってコードをプロファイリングするにはどうすればよいですか?」
  • 「パイプラインストールとは何ですか?どうすれば減らせますか?」
  • 「VTune でメモリ帯域幅を分析するにはどうすればよいですか?」
  • 「ルーフラインモデルとは何ですか?どう使えばよいですか?」
  • 「VTune の無料の代替として AMD uProf を使うにはどうすればよいですか?」
  • 「コードのキャッシュヒット率は高いのに、まだ遅いです」

ワークフロー

1. VTune のセットアップ(無料の Community Edition)
# Download Intel VTune Profiler (Community Edition — free)
# https://www.intel.com/content/www/us/en/developer/tools/oneapi/vtune-profiler.html

# Install on Linux
source /opt/intel/oneapi/vtune/latest/env/vars.sh

# CLI usage
vtune -collect hotspots ./prog
vtune -collect microarchitecture-exploration ./prog
vtune -collect memory-access ./prog

# View results in GUI
vtune-gui &
# File → Open Result → select .vtune directory

# Or use amplxe-cl (legacy CLI)
amplxe-cl -collect hotspots ./prog
amplxe-cl -report hotspots -r result/
2. 分析の種類
分析検出する内容使用するタイミング
ホットスポットCPU バウンドの関数最初のステップ — どこで時間が使われているかを特定します
マイクロアーキテクチャ探索IPC、パイプラインストール、リタイアした命令ホットスポット特定後 — なぜホットスポットが遅いのかを調べます
メモリアクセスキャッシュミス、DRAM 帯域幅、NUMAメモリバウンドのコード
スレッド化ロック競合、並列効率マルチスレッドコード
HPC パフォーマンスベクトル化、メモリ、ルーフラインHPC/科学技術計算コード
I/OディスクおよびネットワークのボトルネックI/O バウンドのコード
3. ホットスポット分析
# Collect and report hotspots
vtune -collect hotspots -result-dir hotspots_result ./prog

# Report top functions by CPU time
vtune -report hotspots -r hotspots_result -format csv | head -20

# CLI output example:
# Function       CPU Time  Module
# compute_fft    4.532s    libfft.so
# matrix_mult    2.108s    prog
# parse_input    0.234s    prog

意味のあるシンボルを得るには、デバッグ情報を付けてビルドします。

gcc -O2 -g ./prog.c -o prog     # symbols visible in VTune
gcc -O2 -g -gsplit-dwarf -fno-omit-frame-pointer ./prog.c -o prog  # better stacks
4. マイクロアーキテクチャ探索 — パイプラインストール
vtune -collect microarchitecture-exploration -r micro_result ./prog
vtune -report summary -r micro_result

確認する主なメトリクス:

メトリクス意味良好な値
IPC(Instructions Per Clock)1 サイクルあたりにリタイアする命令数x86:> 2.0 を目指します
CPI(Clocks Per Instruction)IPC の逆数低いほど良好です
不適切な投機実行分岐予測ミス< 5%
フロントエンドバウンド命令デコードのボトルネック< 15%
バックエンドバウンド実行ユニットまたはメモリのストール< 30%
リタイア有用な処理の割合理想値は > 70%
メモリバウンドメモリ待ちに費やすサイクルの割合< 20%
Pipeline Analysis (Top-Down Methodology):
├── Retiring (good, useful work)
├── Bad Speculation (branch mispredictions)
├── Front-End Bound
│   ├── Fetch Latency (I-cache misses, branch mispredicts)
│   └── Fetch Bandwidth
└── Back-End Bound
    ├── Memory Bound
    │   ├── L1 Bound → L1 cache misses
    │   ├── L2 Bound → L2 cache misses
    │   ├── L3 Bound → L3 cache misses
    │   └── DRAM Bound → main memory bandwidth limited
    └── Core Bound → ALU/compute bound
5. メモリアクセス分析
# Collect memory access profile
vtune -collect memory-access -r mem_result ./prog

# Key output sections:
# - Memory Bound: % time waiting for memory
# - LLC (Last Level Cache) Miss Rate
# - DRAM Bandwidth: GB/s achieved vs theoretical peak
# - NUMA: cross-socket accesses (for multi-socket systems)

DRAM 帯域幅の読み取り:

DRAM Bandwidth: 18.4 GB/s
Peak Theoretical: 51.2 GB/s
Utilization: 36% — likely not DRAM-bound

DRAM バウンドの場合:データレイアウトを最適化し(AoS → SoA)、ワーキングセットを縮小し、空間的局所性を向上させます。

6. AMD uProf — AMD CPU 向けの無料の代替ツール
# Download AMD uProf
# https://www.amd.com/en/developer/uprof.html

# CLI profiling
AMDuProfCLI collect --config tbp ./prog          # time-based profiling
AMDuProfCLI collect --config assess ./prog       # microarchitecture assessment
AMDuProfCLI collect --config memory ./prog       # memory access

# Generate report
AMDuProfCLI report -i /tmp/uprof_result/ -o report.html

# Open GUI
AMDuProf &

AMD uProf のメトリクスと VTune の相当項目:

  • Retired Instructions → IPC 分析
  • Branch Mispredictions → 不適切な投機実行
  • L1/L2/L3 Cache Misses → メモリバウンドの各レベル
  • Data Cache Accesses → キャッシュ効率
7. ルーフラインモデル

ルーフラインモデルは、達成したパフォーマンスをハードウェアの上限と比較し、コードが演算バウンドかメモリバウンドかを示します。

Performance (GFLOPS/s)
     |                    _______________
Peak |                 /
Perf |              /  compute bound
     |           /
     |        /
     |     /  memory bandwidth bound
     |  /
     +------------------------------→
        Arithmetic Intensity (FLOPS/Byte)
# VTune roofline collection
vtune -collect hpc-performance -r roofline_result ./prog
# Then: VTune GUI → Roofline view

# For manual calculation:
# Arithmetic Intensity = FLOPS / memory_bytes_accessed
# Peak FLOPS = CPUs × cores × freq × FLOPS_per_cycle_per_core
# Peak BW = from hardware spec (e.g., 51.2 GB/s for DDR4-3200 dual channel)

# likwid-perfctr for manual roofline data (Linux)
likwid-perfctr -C 0 -g FLOPS_DP ./prog          # double-precision FLOPS
likwid-perfctr -C 0 -g MEM ./prog               # memory bandwidth

関連スキル

  • perf stat で生の PMU イベントを収集するには skills/profilers/hardware-counters を使用します
  • Linux で perf ベースのプロファイリングを行うには skills/profilers/linux-perf を使用します
  • メモリアクセスパターンを最適化するには skills/low-level-programming/cpu-cache-opt を使用します
  • FLOPS を増やすためにベクトル化するには skills/low-level-programming/simd-intrinsics を使用します

コメント