Enable dtrace for npu3#9888
Open
garimadhaked wants to merge 2 commits into
Open
Conversation
garimadhaked
commented
Jun 30, 2026
Collaborator
- Enable dtrace plugin for NPU3
- Fix dtrace run hooks polling an unsubmitted command
- get_xdp_kernel_data() called run_impl->state(), which polls the hwqueue. The XDP dtrace run_constructor/run_start hooks fire from the run_impl constructor and immediately before submit, when the command has no fence id yet. Polling it threw 'Cannot poll a command that has not been submitted', breaking HW-context/runner creation (e.g. FlexMLRT) when aie_dtrace was enabled.
Wire up the AIE dtrace plugin in the client build path so it is loaded when Debug.aie_dtrace is enabled. dtrace::load() now selects the loader based on build type (sdk_loader on client Windows, module_loader otherwise) and picks the NPU3-specific plugin name via AMD_XDP_NPU3, matching the existing aie_profile/aie_trace/aie_halt plugins.
get_xdp_kernel_data() called run_impl->state(), which polls the hwqueue. The XDP dtrace run_constructor/run_start hooks fire from the run_impl constructor and immediately before submit, when the command has no fence id yet. Polling it threw 'Cannot poll a command that has not been submitted', breaking HW-context/runner creation (e.g. FlexMLRT) when aie_dtrace was enabled. Read the cached ERT packet state directly instead of polling.
| warning_callbacks_empty); | ||
| #else | ||
| static xrt_core::module_loader | ||
| xdp_aie_dtrace_loader(std::getenv("AMD_XDP_NPU3") ? "xdp_aie_dtrace_plugin_npu3" : "xdp_aie_dtrace_plugin", |
Contributor
There was a problem hiding this comment.
warning: function is not thread safe [concurrency-mt-unsafe]
xdp_aie_dtrace_loader(std::getenv("AMD_XDP_NPU3") ? "xdp_aie_dtrace_plugin_npu3" : "xdp_aie_dtrace_plugin",
^
Collaborator
There was a problem hiding this comment.
We cannot use std::getenv, please use xrt_core::utils::getenv, but is an env really what you want in the first place, why not ini?
stsoe
requested changes
Jun 30, 2026
| warning_callbacks_empty); | ||
| #else | ||
| static xrt_core::module_loader | ||
| xdp_aie_dtrace_loader(std::getenv("AMD_XDP_NPU3") ? "xdp_aie_dtrace_plugin_npu3" : "xdp_aie_dtrace_plugin", |
Collaborator
There was a problem hiding this comment.
We cannot use std::getenv, please use xrt_core::utils::getenv, but is an env really what you want in the first place, why not ini?
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.