rocprof-compute-memory

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Analyze the AMD GPU memory hierarchy

分析 AMD GPU 内存层级

Use this after Speed-of-Light points at memory, or when the user asks about bandwidth, caches, or data movement directly.
Run
rocprof-compute analyze --help
before choosing flags.
当 Speed-of-Light 指向内存问题,或用户直接询问 带宽、缓存或数据移动时,使用本流程。
在选择 flag 前运行
rocprof-compute analyze --help
。

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。停止操作, 并将用户引导至安装指南中的“安装 ROCm Core SDK”。 单独安装 rocprof-compute 没有帮助。
根据 兼容的加速器检查 GPU。 该表列出的是产品系列,因此应匹配
rocminfo
输出的
Marketing Name
, 并使用
gfx
名称进行确认。如果 GPU 不受支持,请停止并 告知用户。
然后按照安装指南中的“安装 analyze 模式依赖项”操作, 该步骤会将 rocprof-compute 安装在独立的虚拟环境中。使用 nightly 索引, 确保版本与这些 skill 匹配。运行 rocprof-compute 前,使用
source <venv>/bin/activate
激活该环境,并通过
rocprof-compute analyze --debug-verify-deps
进行确认。如果应用是 Python 脚本,请先记下其 Python 的完整路径,再激活环境,并使用该路径运行 脚本。

1. Start with the Memory Chart

1. 从 Memory Chart 开始

bash
rocprof-compute analyze --path ./workloads/<name>/<gpu_model> --list-stats
rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id> --memory-chart
On ROCm 10.2 and earlier, use
-b memchart
instead of
--memory-chart
.
The Memory Chart shows the whole hierarchy at once: requests issued, what each cache level served, and what reached HBM. Read it before opening any single cache level, because it tells you which level to open.
Always analyze one kernel at a time with
-k
.
If there is no workload yet, collect only the memory blocks:
bash
rocprof-compute profile --name <workload_name> --memory-chart -b vl1d l2 lds -- <application> <args>
The cache aliases differ by architecture; for example, some GPUs name their caches
gl0
and
gl2
.
bash
rocprof-compute analyze --path ./workloads/<name>/<gpu_model> --list-stats
rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id> --memory-chart
在 ROCm 10.2 及更早版本上,使用
-b memchart
代替
--memory-chart
。
Memory Chart 会同时显示整个内存层级:已发出的请求、每个 缓存级别所服务的内容,以及到达 HBM 的内容。在打开任何单个 缓存级别之前先读取它,因为它会告诉你应该查看哪个级别。
始终使用
-k
一次分析一个 kernel。
如果还没有 workload,请仅采集内存 block:
bash
rocprof-compute profile --name <workload_name> --memory-chart -b vl1d l2 lds -- <application> <args>
缓存别名因架构而异;例如,某些 GPU 会将其缓存命名为
gl0
和
gl2
。

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 benchmark。
  • 列出该 GPU 可采集的内容:
    rocprof-compute --list-metrics
    ,以及 某个 block 的 metrics:
    rocprof-compute --list-metrics <alias>
    。在 ROCm 10.2 及更早版本上,使用
    --list-blocks <gfx_arch>
    和
    --list-metrics <gfx_arch>
    。 仅通过
    -b
    传入问题所需的 block 别名、block ID 或 metric ID(例如
    2.1.0
    )。别名因架构而异。
  • --set <set_name>
    在一次 pass 中采集一个预定义主题。
    rocprof-compute profile --list-sets
    会列出这些 set。
  • 当用户指出重要的 kernel 名称时,添加
    -k <kernel_name>
    。
  • 除非问题涉及 roofline,否则使用
    -b
    选择 blocks,并排除 block 4 (
    roof
    ),从而跳过 roofline benchmark。
  • --iteration-multiplexing
    会将 counters 分散到使用相同 launch 参数对每个 kernel 的重复 dispatch 中,因此只有在每个被分析的 kernel 都以相同 launch 参数运行多次时才有帮助。将其与
    -k
    配合使用。 有关 Iteration multiplexing,请参阅 profile 模式。
  • 告知用户缩小后的 profile 会使哪些分析面板保持为空。

2. Open the level the chart points at

2. 打开图表所指向的级别

bash
undefined
bash
undefined

Vector L1 data cache

Vector L1 data cache

rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id> -b vl1d
rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id> -b vl1d

L2 cache

L2 cache

rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id> -b l2
rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id> -b l2

L2 per channel, including Infinity Fabric read and write stalls

L2 per channel, including Infinity Fabric read and write stalls

rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id> -b l2_per_channel
rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id> -b l2_per_channel

Local Data Share, including bank conflicts and unaligned stalls

Local Data Share, including bank conflicts and unaligned stalls

rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id> -b lds
rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id> -b lds

Address processing and data return, for coalescing behaviour

Address processing and data return, for coalescing behaviour

rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id> -b tatd
rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id> -b tatd

Scalar L1 data cache

Scalar L1 data cache

rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id> -b sl1d

Aliases are stable; numeric block ids are architecture-specific. List what this
workload actually has with `--list-metrics`.
rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id> -b sl1d

别名是稳定的;数字 block ID 因架构而异。使用 `--list-metrics` 列出
此 workload 实际包含的内容。

3. Interpret

3. 解释

Each level has its own reference, with the counters, the formulas, and what they mean:
Client APUs use a different hierarchy; see the RDNA performance model for GL0, GL1, and GL2.
Read hit rates and utilizations against the
Percent of Peak
and
Peak
columns the report prints. Do not apply a remembered cutoff such as "L2 hit rate below 50% is bad"; a streaming kernel with no reuse is supposed to miss. Judge a rate against what the algorithm should do, the neighbouring kernels, and a known-good baseline.
What usually follows from what:
ReadingUsual meaning
High request count, low cache hitspoor locality or no reuse to exploit
Many requests per instruction in TA/TDuncoalesced access
Sustained LDS bank conflictspadding or access reordering needed
High fabric read or write stallstraffic exceeds what the fabric can absorb
Near-peak HBM with low cache hitsreduce traffic or add reuse; more bandwidth is not available
每个级别都有自己的参考资料,其中包含 counters、公式及其含义:
Client APU 使用不同的层级;有关 GL0、GL1 和 GL2,请参阅 RDNA 性能模型。
将命中率和利用率与报告输出的
Percent of Peak
和
Peak
列进行对照。不要套用凭记忆设定的阈值,例如“L2 命中率低于 50% 就表现不佳”; 没有数据复用的 streaming kernel 本来就应当未命中。应根据算法应有的行为、 相邻 kernel 以及已知良好的 baseline 来判断某个比率。
指标读数常见含义
请求数高、缓存命中数低局部性不佳,或没有可利用的数据复用
TA/TD 中每条指令产生大量请求访问未合并(uncoalesced access)
持续出现 LDS bank conflict需要进行 padding 或调整访问顺序
Fabric 读或写 stall 较高流量超出 Fabric 的承载能力
HBM 接近峰值且缓存命中数低减少流量或增加复用;无法获得更多带宽

4. Memory bandwidth analysis (experimental, gfx950)

4. 内存带宽分析(实验性,gfx950)

A guided breakdown that walks the bandwidth tree and names the limiting level. It is experimental and currently shipped for gfx950 only; see memory bandwidth analysis. It needs only the memory chart (block 3) and block 30, so profile only those two blocks:
bash
rocprof-compute profile --experimental --membw-analysis --memory-chart -b 30 \
    --name <name> -- <application>

rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id>
Report the guidance the tool produced rather than substituting your own numbers.
On any other architecture, use the Memory Chart path above.
该功能会引导你逐层分析带宽树,并指出受限级别。 它仍处于实验阶段,目前仅随 gfx950 提供;请参阅 内存带宽分析。它只需要 Memory Chart(block 3)和 block 30,因此只 profile 这两个 block:
bash
rocprof-compute profile --experimental --membw-analysis --memory-chart -b 30 \
    --name <name> -- <application>

rocprof-compute analyze --path ./workloads/<name>/<gpu_model> -k <kernel_id>
报告工具生成的指导结果,而不是替换为你自己的数值。
在任何其他架构上,使用上述 Memory Chart 流程。

5. Normalization

5. 归一化

For a bandwidth question,
-n per_second
is meaningful and
per_cycle
is not.
-n
applies to the entire report, so switch it only when the user is asking about bandwidth alone. Leave it at
per_kernel
for a mixed report.
对于带宽问题,
-n per_second
有意义,而
per_cycle
没有意义。
-n
应用于整个报告,因此仅当用户只询问带宽时才切换它。 对于混合报告,保持为
per_kernel
。