Repository navigation
fix(rocprofiler-sdk): fix GPU hang when device thread trace starts before hsa_init() - #8943
Conversation
❌ PR Check — Action Required
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🚫 Please fix the failed policies before requesting reviews. The following policy checks failed:
The |
There was a problem hiding this comment.
Pull request overview
This PR addresses an intermittent GPU hang when a device thread trace context is started before hsa_init() by changing when deferred thread-trace starts are replayed during HSA registration, ensuring SQTT hardware programming happens only after the queue infrastructure is fully initialized.
Changes:
- Updates
thread_trace::initialize()to only build per-agent resources and no longer replay deferred starts. - Adds
thread_trace::start_active_contexts()to replay pre-hsa_init()device thread-trace starts afterqueue_controller_init()and queue interposition are established. - Invokes
thread_trace::start_active_contexts()at the end of the HSA registration path inregistration.cpp.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/thread_trace/core.hpp | Documents the new split between resource initialization and deferred-start replay via start_active_contexts(). |
| projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/thread_trace/core.cpp | Moves deferred-start replay out of initialize() into the new start_active_contexts() to avoid early SQTT programming. |
| projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/registration.cpp | Calls rocprofiler::thread_trace::start_active_contexts() after queue controller initialization and queue interposition setup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Motivation
PR #8007 (AIPROFSDK-887) allows a device thread trace context to be started before
hsa_init()by deferring the request and replaying it once HSA is registered. Ondevelop, the newthread-trace-api-agent-before-hsa-init-testintermittently hangs the GPU (HW Exception ... reason :GPU Hang) because the deferred start programs the thread trace (SQTT) hardware too early during HSA initialization. This PR fixes the hang while keeping the deferred-start feature.Technical Details
The deferred-start replay ran inside
thread_trace::initialize(), which executes during HSA table registration beforequeue_controller_init()and queue interposition are set up. Programming the SQTT hardware at that point intermittently wedges the GPU command processor. The replay is moved out ofinitialize()(now only builds per-agent resources) into a newthread_trace::start_active_contexts(), invoked at the end of the HSA registration path afterqueue_controller_init()and queue interposition. This matches the deferred-start ordering already used by device counting (device_counting_service_hsa_registration) and PC sampling (post_hsa_init_start_active_service). Changed files:thread_trace/core.cpp,thread_trace/core.hpp,registration.cpp.Test Plan
Reproduced on MI300X (gfx942, 8 GPUs) using the CI test environment (
ATT_START_BEFORE_HSA_INIT=1), which hung within a few runs. After the fix: ran the failing test 100x in a loop, ranthread-trace-api-agent-before-hsa-init-testandthread-trace-api-agent-start-stop-before-hsa-init-test25x each underctest --repeat until-fail, ran the full thread-trace integration suite, and confirmed trace data is still collected end-to-end with the trace decoder (latency validated, identical to the normal agent test).Test Result
Before: GPU hang within 2-4 runs (~25%). After: 100/100 loop runs clean, both before-hsa-init tests pass 25/25 under ctest, full thread-trace suite passes (10/10, 2 disabled), and the decoder confirms trace data is collected. No regressions.
Submission Checklist