Skip to content

Enable dtrace for npu3#9888

Open
garimadhaked wants to merge 2 commits into
Xilinx:masterfrom
garimadhaked:enable_dtrace_for_npu3
Open

Enable dtrace for npu3#9888
garimadhaked wants to merge 2 commits into
Xilinx:masterfrom
garimadhaked:enable_dtrace_for_npu3

Conversation

@garimadhaked

Copy link
Copy Markdown
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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

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",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",
                        ^

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

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",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants