rocprof-compute-roofline
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRoofline 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 and
before choosing flags. Do not open the generated HTML chart. The analyze table
carries the same numbers in readable form.
rocprof-compute profile --helprocprof-compute analyze --helpRoofline 将 kernel 的 arithmetic intensity 与两个实测上限——峰值算力和峰值带宽——进行对照,并回答一个问题:两者中哪一个构成了限制。
在选择 flags 之前,运行 和 。不要打开生成的 HTML 图表。analyze 表格以可读的形式呈现相同的数据。
rocprof-compute profile --helprocprof-compute analyze --helpBefore you start
开始之前
If finds the tool and
passes, skip this section.
On ROCm 10.2, use instead of .
command -v rocprof-computerocprof-compute analyze --debug-verify-deps--verify-deps--debug-verify-depsOtherwise, check that ROCm and a GPU are present:
bash
rocminfo
amd-smi listIf 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 that
prints, and use the name to confirm. If the GPU is not supported, stop and
tell the user.
Marketing NamerocminfogfxThen 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
before you run rocprof-compute, and confirm with
. If the application is a Python
script, note the full path of its Python before you activate, and run the
script with that path.
source <venv>/bin/activaterocprof-compute analyze --debug-verify-deps如果 找到了该工具,并且 执行通过,则跳过本节。
在 ROCm 10.2 上,使用 代替 。
command -v rocprof-computerocprof-compute analyze --debug-verify-deps--verify-deps--debug-verify-deps否则,检查 ROCm 和 GPU 是否存在:
bash
rocminfo
amd-smi list如果任一命令失败,说明未安装 ROCm 或看不到 GPU。停止操作,并引导用户查看安装指南中的“Install the ROCm Core SDK”。单独安装 rocprof-compute 不足以解决问题。
然后按照安装指南中的“Install the analyze mode dependencies”操作,该步骤会将 rocprof-compute 安装在其独立的 virtual environment 中。使用 nightly index,以确保版本与这些 skills 匹配。运行 rocprof-compute 前,通过 激活该环境,并通过 进行确认。如果应用是 Python script,请在激活环境前记下其 Python 的完整路径,并使用该路径运行脚本。
source <venv>/bin/activaterocprof-compute analyze --debug-verify-deps1. Collect
1. 收集
Collect only the roofline block:
bash
rocprof-compute profile --name <workload_name> --roofline -- <application> <args>On ROCm 10.2 and earlier, use instead of .
-b roof--rooflineCollecting it runs microbenchmarks in addition to profiling the application,
which takes extra time. They are skipped when or selects blocks
that leave out roofline (block 4), or with the deprecated , so an
existing profile collected that way has no roofline data.
-b--set--no-roofMI100 (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 skill instead. Confirm support
for a new architecture against
compatible-accelerators.rst.
rocprof-compute-memory--roofline-deviceHIP_VISIBLE_DEVICESSee standalone roofline for two more options:
- selects the roofline block; used alone, it collects only roofline data.
--roofline - runs only the microbenchmarks, without an application.
--roofline-bench-only
On ROCm 10.2 and earlier, these options are named , and
.
--device--roof-only--bench-only仅收集 roofline block:
bash
rocprof-compute profile --name <workload_name> --roofline -- <application> <args>在 ROCm 10.2 及更早版本上,使用 代替 。
-b roof--roofline收集时,除 profiling 应用外还会运行 microbenchmarks,因此会耗费额外时间。当 或 选择的 blocks 排除了 roofline(block 4)时,或者使用已弃用的 时,这些 benchmark 会被跳过。因此,以该方式采集到的现有 profile 不包含 roofline 数据。
-b--set--no-roofMI100(gfx908)不支持 roofline microbenchmarks,其他所有受支持的架构均支持。在 MI100 上,完整 profile 会跳过 benchmark 并成功完成,而选择 roofline 则会失败。因此,MI100 上缺少 roofline 并不是 profile 运行方式有误造成的。绝不要让 MI100 用户为了获取 roofline 而重新 profile;请改用 Speed-of-Light 和 skill。有关新架构的支持情况,请对照 compatible-accelerators.rst进行确认。
rocprof-compute-memory--roofline-deviceHIP_VISIBLE_DEVICES有关另外两个选项,请参阅 standalone roofline:
- 选择 roofline block;单独使用时,仅收集 roofline 数据。
--roofline - 仅运行 microbenchmarks,不运行应用。
--roofline-bench-only
在 ROCm 10.2 及更早版本上,这些选项分别称为 、 和 。
--device--roof-only--bench-onlyCollect 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 , and a block's metrics with
rocprof-compute --list-metrics. On ROCm 10.2 and earlier, userocprof-compute --list-metrics <alias>and--list-blocks <gfx_arch>. Pass--list-metrics <gfx_arch>only the block aliases, block ids, or metric ids (for example-b) the question needs. Aliases differ by architecture.2.1.0 - collects a predefined topic in one pass.
--set <set_name>lists the sets.rocprof-compute profile --list-sets - Add when the user names the kernels that matter.
-k <kernel_name> - Unless the question is about roofline, select blocks with and leave out block 4 (
-b), so the roofline benchmark is skipped.roof - 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
--iteration-multiplexing. See Iteration multiplexing in profile mode.-k - Tell the user which analysis panels the narrower profile leaves empty.
绝不要运行完整 profile。它会为每次 counter pass 重放一次应用,并且还会运行 roofline benchmarks。
- 使用 列出此 GPU 可采集的内容,使用
rocprof-compute --list-metrics列出某个 block 的 metrics。在 ROCm 10.2 及更早版本上,使用rocprof-compute --list-metrics <alias>和--list-blocks <gfx_arch>。仅通过--list-metrics <gfx_arch>传入问题所需的 block aliases、block ids 或 metric ids(例如-b)。Aliases 因架构而异。2.1.0 - 在一次 pass 中采集一个预定义主题。可通过
--set <set_name>列出 sets。rocprof-compute profile --list-sets - 当用户指定了需要关注的 kernels 时,添加 。
-k <kernel_name> - 除非问题涉及 roofline,否则使用 选择 blocks,并排除 block 4(
-b),从而跳过 roofline benchmark。roof - 会将 counters 分散到各 kernel 使用相同 launch parameters 的重复 dispatch 中,因此只有在每个被 profile 的 kernel 都以相同 launch parameters 运行很多次时才有帮助。请将它与
--iteration-multiplexing配合使用。请参阅 profile mode中的 Iteration multiplexing。-k - 告知用户,精简后的 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> --rooflineAlways 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:
- Which ceiling limits the kernel, memory or compute.
- 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
skill.
rocprof-compute-memory - 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
skill.
rocprof-compute-kernel-bottleneck
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 建议之前,首先报告以下两项:
- 哪个 ceiling 限制 kernel,是 memory 还是 compute。
- kernel 距离该 ceiling 还差多少,以该 ceiling 的百分比表示。
按照以下方式解读表格中的结论:
- Arithmetic intensity 较低且接近 bandwidth ceiling:memory-bound。应优化 traffic、reuse、tiling 和 locality。继续使用 skill。
rocprof-compute-memory - Arithmetic intensity 较高且接近 compute ceiling:compute-bound。应优化 instruction mix、matrix instruction use 和 divergence。
- 远低于两个 ceilings:两者都不是限制因素。kernel 受到 occupancy、launch configuration 或 stalls 的限制。请返回 skill。
rocprof-compute-kernel-bottleneck
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
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.
-b cu_insHBM 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
and query it with SQL.
--output-format db该表会为每种 precision 列出 peak,并为每个 memory level 列出 arithmetic intensity。应与 kernel 实际发出的 precision 所对应的 peak 行,以及所关注 memory level 的 intensity 行进行比较。
将 mixed-precision 或 matrix kernel 与 FP32 peak 对比,会显得远差于实际表现。应通过 从 instruction mix 中读取 precision,不要凭假设判断。仅当 mix 确实混合且没有单一类型占主导时,才询问用户 kernel 预期使用的 precision;用户知道意图,而 counters 知道实际执行了什么。
-b cu_insHBM 用于回答“我是否受主存储器限制”,L2 和 vL1D 则显示缓存是否吸收了 traffic。
要比较多个 kernel,请使用 写入 analysis database,并通过 SQL 查询。
--output-format db4. When roofline data is missing
4. Roofline 数据缺失时
| Cause | What to do |
|---|---|
Profiled with | re-profile without |
| Architecture has no microbenchmark support | use Speed-of-Light and the |
| the benchmark did not complete; check the profile log |
The concepts behind the ceilings are in the
performance model.
| 原因 | 操作 |
|---|---|
使用 | 重新 profile,移除 |
| 架构不支持 microbenchmark | 改用 Speed-of-Light 和 |
workload 目录中缺少 | benchmark 未完成;检查 profile log |
有关这些 ceilings 背后的概念,请参阅 performance model。