rocprof-compute-roofline

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Roofline analysis

Roofline 分析

A roofline places a kernel's arithmetic intensity against two measured ceilings, peak compute and peak bandwidth, and answers one question: which of the two is the limit.
Run
rocprof-compute profile --help
and
rocprof-compute analyze --help
before choosing flags. Do not open the generated HTML chart. The analyze table carries the same numbers in readable form.
Roofline 将 kernel 的 arithmetic intensity 与两个实测上限——峰值算力和峰值带宽——进行对照,并回答一个问题:两者中哪一个构成了限制。
在选择 flags 之前,运行
rocprof-compute profile --help
和
rocprof-compute analyze --help
。不要打开生成的 HTML 图表。analyze 表格以可读的形式呈现相同的数据。

Before you start

开始之前

If
command -v rocprof-compute
finds the tool and
rocprof-compute analyze --debug-verify-deps
passes, skip this section. On ROCm 10.2, use
--verify-deps
instead of
--debug-verify-deps
.
Otherwise, check that ROCm and a GPU are present:
bash
rocminfo
amd-smi list
If either command fails, ROCm is not installed or no GPU is visible. Stop and point the user to "Install the ROCm Core SDK" in the install guide. Installing rocprof-compute alone does not help.
Check the GPU against compatible accelerators. The table lists product families, so match the
Marketing Name
that
rocminfo
prints, and use the
gfx
name to confirm. If the GPU is not supported, stop and tell the user.
Then follow "Install the analyze mode dependencies" in the install guide, which installs rocprof-compute in a virtual environment of its own. Use the nightly index so the version matches these skills. Activate that environment with
source <venv>/bin/activate
before you run rocprof-compute, and confirm with
rocprof-compute analyze --debug-verify-deps
. If the application is a Python script, note the full path of its Python before you activate, and run the script with that path.
如果
command -v rocprof-compute
找到了该工具,并且
rocprof-compute analyze --debug-verify-deps
执行通过,则跳过本节。 在 ROCm 10.2 上,使用
--verify-deps
代替
--debug-verify-deps
。
否则,检查 ROCm 和 GPU 是否存在:
bash
rocminfo
amd-smi list
如果任一命令失败,说明未安装 ROCm 或看不到 GPU。停止操作,并引导用户查看安装指南中的“Install the ROCm Core SDK”。单独安装 rocprof-compute 不足以解决问题。
根据兼容的加速器检查 GPU。该表列出的是产品系列,因此应匹配
rocminfo
输出的
Marketing Name
,并使用
gfx
名称进行确认。如果不支持该 GPU,停止操作并告知用户。
然后按照安装指南中的“Install the analyze mode dependencies”操作,该步骤会将 rocprof-compute 安装在其独立的 virtual environment 中。使用 nightly index,以确保版本与这些 skills 匹配。运行 rocprof-compute 前,通过
source <venv>/bin/activate
激活该环境,并通过
rocprof-compute analyze --debug-verify-deps
进行确认。如果应用是 Python script,请在激活环境前记下其 Python 的完整路径,并使用该路径运行脚本。

1. Collect

1. 收集

Collect only the roofline block:
bash
rocprof-compute profile --name <workload_name> --roofline -- <application> <args>
On ROCm 10.2 and earlier, use
-b roof
instead of
--roofline
.
Collecting it runs microbenchmarks in addition to profiling the application, which takes extra time. They are skipped when
-b
or
--set
selects blocks that leave out roofline (block 4), or with the deprecated
--no-roof
, so an existing profile collected that way has no roofline data.
MI100 (gfx908) does not support the roofline microbenchmarks. Every other supported architecture does. On MI100 a full profile skips the benchmark and still succeeds, and selecting roofline fails, so a missing roofline there is not a mistake in how the profile was run. Never tell an MI100 user to re-profile to get roofline; use Speed-of-Light and the
rocprof-compute-memory
skill instead. Confirm support for a new architecture against compatible-accelerators.rst.
--roofline-device
selects the GPU for the roofline microbenchmarks. It does not choose which GPU the application runs on; use
HIP_VISIBLE_DEVICES
for that.
See standalone roofline for two more options:
  • --roofline
    selects the roofline block; used alone, it collects only roofline data.
  • --roofline-bench-only
    runs only the microbenchmarks, without an application.
On ROCm 10.2 and earlier, these options are named
--device
,
--roof-only
and
--bench-only
.
仅收集 roofline block:
bash
rocprof-compute profile --name <workload_name> --roofline -- <application> <args>
在 ROCm 10.2 及更早版本上,使用
-b roof
代替
--roofline
。
收集时,除 profiling 应用外还会运行 microbenchmarks,因此会耗费额外时间。当
-b
或
--set
选择的 blocks 排除了 roofline(block 4)时,或者使用已弃用的
--no-roof
时,这些 benchmark 会被跳过。因此,以该方式采集到的现有 profile 不包含 roofline 数据。
MI100(gfx908)不支持 roofline microbenchmarks,其他所有受支持的架构均支持。在 MI100 上,完整 profile 会跳过 benchmark 并成功完成,而选择 roofline 则会失败。因此,MI100 上缺少 roofline 并不是 profile 运行方式有误造成的。绝不要让 MI100 用户为了获取 roofline 而重新 profile;请改用 Speed-of-Light 和
rocprof-compute-memory
skill。有关新架构的支持情况,请对照 compatible-accelerators.rst进行确认。
--roofline-device
用于选择运行 roofline microbenchmarks 的 GPU。它不会选择应用运行所在的 GPU;后者应使用
HIP_VISIBLE_DEVICES
控制。
有关另外两个选项,请参阅 standalone roofline:
  • --roofline
    选择 roofline block;单独使用时,仅收集 roofline 数据。
  • --roofline-bench-only
    仅运行 microbenchmarks,不运行应用。
在 ROCm 10.2 及更早版本上,这些选项分别称为
--device
、
--roof-only
和
--bench-only
。

Collect only what the question needs

只收集问题所需的数据

Never run a full profile. It replays the application once per counter pass and also runs the roofline benchmarks.
  • List what this GPU can collect with
    rocprof-compute --list-metrics
    , and a block's metrics with
    rocprof-compute --list-metrics <alias>
    . On ROCm 10.2 and earlier, use
    --list-blocks <gfx_arch>
    and
    --list-metrics <gfx_arch>
    . Pass
    -b
    only the block aliases, block ids, or metric ids (for example
    2.1.0
    ) the question needs. Aliases differ by architecture.
  • --set <set_name>
    collects a predefined topic in one pass.
    rocprof-compute profile --list-sets
    lists the sets.
  • Add
    -k <kernel_name>
    when the user names the kernels that matter.
  • Unless the question is about roofline, select blocks with
    -b
    and leave out block 4 (
    roof
    ), so the roofline benchmark is skipped.
  • --iteration-multiplexing
    spreads counters over repeated dispatches of each kernel with the same launch parameters, so it only helps when each profiled kernel runs many times with the same launch parameters. Pair it with
    -k
    . See Iteration multiplexing in profile mode.
  • Tell the user which analysis panels the narrower profile leaves empty.
绝不要运行完整 profile。它会为每次 counter pass 重放一次应用,并且还会运行 roofline benchmarks。
  • 使用
    rocprof-compute --list-metrics
    列出此 GPU 可采集的内容,使用
    rocprof-compute --list-metrics <alias>
    列出某个 block 的 metrics。在 ROCm 10.2 及更早版本上,使用
    --list-blocks <gfx_arch>
    和
    --list-metrics <gfx_arch>
    。仅通过
    -b
    传入问题所需的 block aliases、block ids 或 metric ids(例如
    2.1.0
    )。Aliases 因架构而异。
  • --set <set_name>
    在一次 pass 中采集一个预定义主题。可通过
    rocprof-compute profile --list-sets
    列出 sets。
  • 当用户指定了需要关注的 kernels 时,添加
    -k <kernel_name>
    。
  • 除非问题涉及 roofline,否则使用
    -b
    选择 blocks,并排除 block 4(
    roof
    ),从而跳过 roofline benchmark。
  • --iteration-multiplexing
    会将 counters 分散到各 kernel 使用相同 launch parameters 的重复 dispatch 中,因此只有在每个被 profile 的 kernel 都以相同 launch parameters 运行很多次时才有帮助。请将它与
    -k
    配合使用。请参阅 profile mode中的 Iteration multiplexing。
  • 告知用户,精简后的 profile 会使哪些 analysis panels 留空。

2. Read the table

2. 读取表格

bash
rocprof-compute analyze --path ./workloads/<name>/<gpu_model> --list-stats
rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id> --roofline
Always pass one kernel id. The table gives the kernel's arithmetic intensity in FLOPs per byte alongside the empirical peak FLOPs and peak bandwidth measured on this machine. Compare against those printed numbers; never compute a peak yourself.
Report two things first, before any tuning advice:
  1. Which ceiling limits the kernel, memory or compute.
  2. How far the kernel sits below that ceiling, as a percentage of it.
Read the verdict from the table as:
  • Low arithmetic intensity, close to the bandwidth ceiling: memory-bound. Work on traffic, reuse, tiling, and locality. Continue with the
    rocprof-compute-memory
    skill.
  • High arithmetic intensity, close to the compute ceiling: compute-bound. Work on instruction mix, matrix instruction use, and divergence.
  • Well below both ceilings: neither is the limit. The kernel is held back by occupancy, launch configuration, or stalls. Go back to the
    rocprof-compute-kernel-bottleneck
    skill.
A kernel sitting below both ceilings is the common case and the most misread one. Never report it as compute-bound merely because its arithmetic intensity is high.
The distance to the ceiling is what makes the verdict actionable. "Memory-bound at 45% of peak bandwidth" tells the user there is headroom; "memory-bound at 94%" tells them to reduce traffic instead of chasing it.
bash
rocprof-compute analyze --path ./workloads/<name>/<gpu_model> --list-stats
rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id> --roofline
始终传入一个 kernel id。该表会给出 kernel 的 arithmetic intensity(以 FLOPs per byte 表示),以及在这台机器上实测的 empirical peak FLOPs 和 peak bandwidth。请与表中打印的数值进行比较;绝不要自行计算 peak。
在提供任何 tuning 建议之前,首先报告以下两项:
  1. 哪个 ceiling 限制 kernel,是 memory 还是 compute。
  2. kernel 距离该 ceiling 还差多少,以该 ceiling 的百分比表示。
按照以下方式解读表格中的结论:
  • Arithmetic intensity 较低且接近 bandwidth ceiling:memory-bound。应优化 traffic、reuse、tiling 和 locality。继续使用
    rocprof-compute-memory
    skill。
  • Arithmetic intensity 较高且接近 compute ceiling:compute-bound。应优化 instruction mix、matrix instruction use 和 divergence。
  • 远低于两个 ceilings:两者都不是限制因素。kernel 受到 occupancy、launch configuration 或 stalls 的限制。请返回
    rocprof-compute-kernel-bottleneck
    skill。
kernel 同时低于两个 ceilings 是常见情况,也是最容易被误读的情况。绝不要仅因为 arithmetic intensity 较高就将其报告为 compute-bound。
与 ceiling 的距离决定了结论是否具有可操作性。“在 peak bandwidth 的 45% 处为 memory-bound”说明仍有提升空间;“在 peak bandwidth 的 94% 处为 memory-bound”则说明应减少 traffic,而不是继续追逐带宽。

3. Pick the right precision and memory level

3. 选择正确的 precision 和 memory level

The table lists a peak for every precision and an arithmetic intensity for every memory level. Compare against the peak row for the precision the kernel actually issues, and the intensity row for the memory level in question.
A mixed-precision or matrix kernel compared against the FP32 peak will look far worse than it is. Read the precision from the instruction mix with
-b cu_ins
rather than assuming it. Ask the user which precision the kernel is meant to use only when the mix is genuinely mixed and no single type dominates; they know the intent, the counters know what ran.
HBM answers "am I limited by main memory", while L2 and vL1D show whether caches are absorbing the traffic.
To compare many kernels, write the analysis database with
--output-format db
and query it with SQL.
该表会为每种 precision 列出 peak,并为每个 memory level 列出 arithmetic intensity。应与 kernel 实际发出的 precision 所对应的 peak 行,以及所关注 memory level 的 intensity 行进行比较。
将 mixed-precision 或 matrix kernel 与 FP32 peak 对比,会显得远差于实际表现。应通过
-b cu_ins
从 instruction mix 中读取 precision,不要凭假设判断。仅当 mix 确实混合且没有单一类型占主导时,才询问用户 kernel 预期使用的 precision;用户知道意图,而 counters 知道实际执行了什么。
HBM 用于回答“我是否受主存储器限制”,L2 和 vL1D 则显示缓存是否吸收了 traffic。
要比较多个 kernel,请使用
--output-format db
写入 analysis database,并通过 SQL 查询。

4. When roofline data is missing

4. Roofline 数据缺失时

CauseWhat to do
Profiled with
--no-roof
, or
-b
/
--set
without block 4
re-profile without
--no-roof
; add
--roofline
to
-b
, or replace
--set
with
-b
blocks plus
--roofline
(no set includes block 4)
Architecture has no microbenchmark supportuse Speed-of-Light and the
rocprof-compute-memory
skill instead
roofline.csv
absent from the workload directory
the benchmark did not complete; check the profile log
The concepts behind the ceilings are in the performance model.
原因操作
使用
--no-roof
进行 profile,或使用不含 block 4 的
-b
/
--set
重新 profile,移除
--no-roof
;给
-b
添加
--roofline
,或者用
-b
blocks 加上
--roofline
替换
--set
(没有 set 包含 block 4)
架构不支持 microbenchmark改用 Speed-of-Light 和
rocprof-compute-memory
skill
workload 目录中缺少
roofline.csv
benchmark 未完成;检查 profile log
有关这些 ceilings 背后的概念,请参阅 performance model。