Analysis and debugging tools#
rocSHMEM ships two sets of developer scripts alongside the library. They are not installed with the library; run them from a source checkout.
scripts/analysis- commit-vs-commit comparison of compiler codegen: per-kernel GPU resource usage and LTO inlining decisions.scripts/debug- deadlock diagnosis for a running (or hung) rocSHMEM application, built onrocgdb.
Runtime statistics and tracing#
Before reaching for the scripts, two in-library facilities are often enough:
Statistics counters. Build with
-DPROFILE=ONand callrocshmem_dump_stats()to print the runtime’s internal counters.rocshmem_reset_stats()clears only the counters its backend supports — it does not clear user-created host contexts, so it cannot be relied on to exclude all warm-up activity. See Library setup, exit, and query routines.Tracing with rocprofiler-sdk. With the default
-DUSE_ROCPROFILER_REGISTER=ON, rocSHMEM’s host-stream APIs are visible to tools such asrocprofv3. See the “Profiling and tracing support” section of Build from source.Verbose logging.
ROCSHMEM_DEBUG_LEVELcontrols log verbosity at runtime. Theapiandtracelevels additionally require a build with-DBUILD_DEBUG_TRACE_HOST=ONor-DBUILD_DEBUG_TRACE_DEVICE=ON. See rocSHMEM environment variables.
Codegen regression analysis#
Both comparison scripts build each commit under test in its own isolated
git worktree under /tmp, so your working tree - including uncommitted
changes - is never touched. Each runs the same pipeline: build, extract
compiler remarks, convert to CSV, diff, and emit a self-contained interactive
HTML dashboard plus PNG charts.
Prerequisites#
The project must be a git repository.
A ROCm
clang++/hipcctoolchain with the AMDGPU backend.python3.PyYAML, forlto_inline_remarks_compare.shonly.matplotlib, optional; PNG chart generation is skipped with a warning if it is missing.llvm-cxxfiltorc++filtonPATH, used to demangle kernel names.
Resource usage#
scripts/analysis/resource_usage_compare.sh reports per-kernel VGPR, SGPR,
AGPR, scratch, LDS, and occupancy from
-Rpass-analysis=kernel-resource-usage remarks. Use it to answer whether a
change increased register pressure or dropped occupancy for a given kernel.
# Compare two commits
./scripts/analysis/resource_usage_compare.sh \
--commit1 HEAD~1 --commit2 HEAD \
--gpu-target gfx950 --build-config all_backends
# Compare a GitHub PR against its merge-base
./scripts/analysis/resource_usage_compare.sh --pr 42 --build-config all_backends
# Compare two build configurations of different commits
./scripts/analysis/resource_usage_compare.sh \
--commit1 923767a9 --commit1-extra-args "-DUSE_SDMA=1" \
--commit2 41b678fa --commit2-extra-args "-DUSE_TDM=1"
Results are written to
<parent-of-project>/resource-usage/<gpu>-<config>-<sha1>-vs-<sha2>/.
LTO inlining decisions#
scripts/analysis/lto_inline_remarks_compare.sh reports the whole-program
AMDGPU LTO inliner’s optimization-record remarks. Use it to answer whether a
change flipped an inlining decision.
./scripts/analysis/lto_inline_remarks_compare.sh \
--commit1 HEAD~1 --commit2 HEAD --build-config ipc_single
Results are written to
<parent-of-project>/lto-inline-remarks/<gpu>-<config>-<sha1>[-vs-<sha2>]/.
Common options#
Option |
Default |
Description |
|---|---|---|
|
|
First commit or branch to measure. |
|
none |
Second commit to diff against |
|
none |
Fetch GitHub PR |
|
|
Base branch used to resolve the |
|
|
GPU architecture to build and measure. |
|
|
Named build script under |
|
none |
Direct path to an executable build script. Takes precedence over
|
|
none |
Extra arguments appended to the build-config invocation for
|
|
off |
Rebuild even if a cached build exists for this commit. |
|
|
Rows shown per chart. Defaults to |
|
see above |
Where to write the report. |
Note
The Python helpers under scripts/analysis carry no rocSHMEM-specific
logic. To use these tools in another CMake project, copy the whole
scripts/analysis/ directory next to that project’s top-level
CMakeLists.txt and point the scripts at your own build wrapper with
--config-path. See scripts/analysis/README.md for the full
description.
Deadlock analysis#
scripts/debug diagnoses a hung rocSHMEM application by coalescing GPU
wavefront backtraces, identifying the rocSHMEM API entry points the waves are
stuck in, and grouping identical patterns across ranks.
Script |
Purpose |
|---|---|
|
rocgdb Python script: coalesces GPU wavefront backtraces, identifies rocSHMEM API entry points, and prints deadlock hints. |
|
Finds every running instance of an executable on the local node, attaches to each, saves per-process output, and prints a compact summary. |
|
Deploys |
|
Reads the per-rank output files, groups identical backtrace patterns across ranks, and highlights the patterns that are uncommon among ranks - usually where the deadlock is. |
Prerequisites: rocgdb on PATH (override with the ROCGDB
environment variable) and the timeout command.
# 1. Start your (deadlocked) application
mpirun -np 4 ./my_rocshmem_app &
# 2. Attach to all local instances, analyze, and save output
./scripts/debug/attach_deadlock_analysis.sh my_rocshmem_app
Per-process output is written to
./rocshmem_deadlock_analysis_<timestamp>/pe<PE_RANK>_pid_<PID>.txt, and a
compact summary is printed to stdout. The PE rank is read from the process’s
OMPI_COMM_WORLD_RANK; it is reported as unknown for non-MPI processes.
Use --cull to suppress wave groups that are merely sitting in a GPU barrier
or grid sync, which is usually noise rather than the deadlock itself:
./scripts/debug/attach_deadlock_analysis.sh my_rocshmem_app --cull
Note
Build rocSHMEM and the application with -DCMAKE_BUILD_TYPE=RelWithDebInfo
before using these scripts. A Release build shows only the outermost
non-inlined API frame, not the internal wait loops where the deadlock is
visible. Consider also building with -DUSE_FUNC_CALL=ON so that rocSHMEM
frames are not inlined away. See scripts/debug/README.md for the full
description.