Conform to the new repo layout (master moved repros under tests/, e.g. tests/cuda/repro/graph). Relocate examples/RocprofOnDemandRepro to tests/rocprof/repro/on_demand and replace the hand-written Makefile with a CMake build mirroring the CUDA repro: builds the HIP reproducer, wires it as a ctest target, and optionally builds the check_gpu_ctx_name verification helper against the Tracy server library. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Rocprofiler On-Demand Profiling Repro
Demonstrates that unpatched Tracy crashes when a profiler connects to a
HIP application built with TRACY_ON_DEMAND and TRACY_ROCPROF.
Root cause
Three bugs in TracyRocprof.cpp break on-demand profiling:
-
GpuNewContext not deferred.
gpu_context_allocate()writes aGpuNewContextqueue item but does not callDeferItem(). When a Tracy client connects late, the context creation message is never replayed. The server then receivesGpuZoneBeginevents for a context it has never seen, triggering:Assertion `ctx' failed in ProcessGpuZoneBeginImplCommon -
GpuContextName not deferred. Same function writes the context name ("rocprofv3") without calling
DeferItem(). Even after fixing bug 1, a late-connecting client sees the GPU context but it appears unnamed in the profiler. Usecheck_gpu_ctx_nameto verify. -
Kernel symbols dropped before init. The
data->initguard at the top oftool_callback_tracing_callback()blocks all callbacks before the GPU context is allocated. Kernel symbol registrations (CODE_OBJECT_DEVICE_KERNEL_SYMBOL_REGISTER) happen at HIP init time — beforedata->initis true — so they are silently dropped. Even if the crash is worked around, kernel names would be missing.
Prerequisites
- AMD GPU with working ROCm driver
librocprofiler-sdk.soavailable (typically at/opt/rocm/lib/)/opt/rocm/bin/hipcc
Build and run
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
./build/repro &
tracy-capture -o repro.tracy -s 5
If ROCm is not under /opt/rocm, pass -DROCM_PATH=/path/to/rocm.
The reproducer is also registered as a ctest target:
ctest --test-dir build -R repro
Verifying the context name
check_gpu_ctx_name loads a .tracy file and prints the GPU context
names. It links the Tracy server library, so it is built only on request:
cmake -B build -DBUILD_CHECK_TOOL=ON
cmake --build build --target check_gpu_ctx_name
./build/check_gpu_ctx_name repro.tracy
# Expected (patched): "GPU context 0: rocprofv3"
# Expected (unpatched): "GPU context 0: (unnamed)"
Exit codes: 0 = all contexts named, 2 = unnamed context found.
What to expect
| Tracy version | Result |
|---|---|
| Unpatched | tracy-capture crashes: Assertion 'ctx' failed |
| Patched (GpuNewContext only) | Capture succeeds but GPU context is unnamed |
| Fully patched | Capture succeeds with ~50 GPU zones and context named "rocprofv3" |