Repository navigation
[experiment] fix(rocprofiler-sdk): confine kernel-replay toggles to the replayed agent - #13168
Draft
Conversation
…gent Kernel replay keeps its per-pass toggles in thread-local state, and a tool callback on the replaying thread can submit GPU work while the loop runs: - To the agent being replayed, the dispatch takes that agent's replay lock shared while the thread holds it exclusively. libstdc++ throws std::system_error (EDEADLK) out of WriteInterceptor and the process aborts with no explanation. - To another agent, the dispatch runs normally but its dispatch hooks see this loop's toggles. If that dispatch is replayed too, the nested loop clears the thread's toggle routing when it exits, so the outer loop's remaining passes silently lose their toggles. Record the replayed agent in the loop's control block and expose it as kernel_replay::replaying_agent(). The dispatch hooks and the kernel dispatch tracing filter pass the dispatch's agent to is_locally_enabled(), which applies overrides only on the replayed agent. WriteInterceptor never replays a dispatch issued while its thread is replaying, and stops with a clear message when a replay callback submits work to the replayed agent. is_locally_enabled() now reads the thread-local state directly instead of calling local_context_override(). Document the constraint in kernel_replay.h and add GPU-free tests for the agent scoping and replaying_agent(). Co-authored-by: Vivek Kale <vivek.kale@amd.com>
Contributor
|
This pull request has been inactive for 25 days and will be marked as stale. If you would like to keep this PR open, please:
This PR will be automatically closed in 5 days if no further activity occurs. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Experiment, stacked on #13083. The base is #13083's branch, so this diff is only 398062b4fc. Opened as a draft to get a GPU run.
Motivation
Kernel replay keeps its per-pass toggles in thread-local state, and the replay loop holds the replayed agent's replay mutex exclusively (queue.cpp#L1136-L1137). A tool callback that runs on the replaying thread (CONFIG/PASS phase callbacks, dispatch callbacks) can still submit GPU work while the loop runs:
std::system_error("Resource deadlock avoided") out ofWriteInterceptor, and the process aborts with no explanation. That includes runtime copies and fills implemented as kernels. Nothing in the docs warns tools about it.Technical Details
local_context_control_trecords the replayed agent.kernel_replay::replaying_agent()reports it for the loop's lifetime.is_locally_enabled(). Overrides apply only on the replayed agent.WriteInterceptornever replays a dispatch issued while its thread is replaying. It stops with a clear message when a replay callback submits work to the replayed agent.is_locally_enabled()reads the thread-local state directly instead of callinglocal_context_override(). Benchmarked, that saves the extra out-of-line call: about 17.5 to 12.8 ns per dispatch with 8 contexts outside a loop.kernel_replay.hdocuments the constraint and the per-agent scope of the toggles.Issue Tracking
None.
Test Plan
kernel_replay_local_context.overrides_apply_only_on_the_replay_agentand.replaying_agent_tracks_the_loop.local_context.cpp(out of tree): random replay agents, dispatch agents and toggles, with a reference model.Test Result
-Werrorand clang-format are clean on all touched files.Submission Checklist