Skip to content

Run constructor Run wait and run start hook for temporal sharing usecase#9721

Open
garimadhaked wants to merge 17 commits intoXilinx:masterfrom
jyothees99:run-constructor-ct-hook
Open

Run constructor Run wait and run start hook for temporal sharing usecase#9721
garimadhaked wants to merge 17 commits intoXilinx:masterfrom
jyothees99:run-constructor-ct-hook

Conversation

@garimadhaked
Copy link
Copy Markdown
Collaborator

@garimadhaked garimadhaked commented Apr 10, 2026

Fix : Added XDP dtrace plugin support for temporal sharing usecase.

  • Added run constructor, run wait and run start hooks
  • updated xdp submodule
  • added dtrace plugin related settings in xrt.ini
  • Use of aiebu api to get info from elf for dtrace

Testing: Verified few examples with and without XDP dtrace plugin. Verified temporal sharing example as well.

jyothees99 and others added 13 commits April 2, 2026 01:10
Call xrt_core::xdp::run_constructor from the xrt::run constructor,
passing the run pointer and hw_context_impl pointer. The hook
dispatches to aie::profile::run_constructor via dlsym-registered
callback (aieProfileRunConstructor), gated on get_aie_profile().
This enables XDP plugins to attach per-run resources at run
construction time.

Made-with: Cursor
Thread the run_impl::get_uid() value as a uint32_t through the
entire hook chain so the per-run CT file is named with the actual
run UID (e.g. aie_profile_ctx_1_run_3.ct), matching the dtrace
dump naming convention (dtrace_dump_ctx_1_run_3_<timestamp>.py).

Made-with: Cursor
Pass kernel name and ELF handle (from xrt::module) through the
run_constructor callback chain so the AIE profile plugin can extract
SAVE_TIMESTAMP locations directly from the ELF at run construction time.

Made-with: Cursor
Expose Debug.aie_dtrace and AIE_dtrace_settings (interval, tile- and
graph-based interface tile metrics) in config_reader.h for xrt.ini.

Register the xdp_aie_dtrace_plugin_xdna module loader in profile.cpp
when the XDP VE2 build supplies that shared library.

Bump the src/runtime_src/xdp submodule to pick up the AIE dtrace plugin
and related XDP profile changes.

Made-with: Cursor
Delete get_aie_profile_settings_dtrace_debug(); AIE dtrace uses
Debug.aie_dtrace only (xdp submodule).

Made-with: Cursor
Add xrt_core::xdp::run_start and run_wait APIs and load aieDtraceRunStart /
aieDtraceRunWait from the dtrace plugin when aie_dtrace is enabled.

Call run_start before kernel submit from xrt::run::start, and run_wait after
xrt::run::wait / wait2 return. Use const_cast for wait paths because wait is
const.

Bump src/runtime_src/xdp submodule to include the plugin exports and hooks.

Made-with: Cursor
Bump src/runtime_src/xdp to include aie_profile cleanup (remove
AieProfileCTWriter, ddr/read/write_bandwidth handling, and generateCTForRun).

Made-with: Cursor
Points src/runtime_src/xdp at commit adding METRIC_* bandwidth constants,
isInterfaceTileBandwidthMetricSet(), and VE2 AieProfileCTWriter updates.

Made-with: Cursor
Remove aie::profile run_constructor callback registration and the
get_aie_profile() branch in xrt_core::xdp::run_constructor. Per-run setup is
handled solely by the aie_dtrace plugin when enabled.

Submodule src/runtime_src/xdp: AIE profile VE2 CT writer removal and related
cleanup (see submodule commit).

Made-with: Cursor
Points xdp at commit that derives UC spans from aiebu op_loc and extends
the last UC through the maximum configured counter column.

Made-with: Cursor
Signed-off-by: Garima Dhaked <garima.dhaked@amd.com>
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

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

inline unsigned int
get_aie_dtrace_settings_interval_us()
{
static unsigned int value = detail::get_uint_value("AIE_dtrace_settings.interval_us", 1000);
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: 1000 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]

  static unsigned int value = detail::get_uint_value("AIE_dtrace_settings.interval_us", 1000);
                                                                                        ^

Guard run_constructor, run_start, and run_wait hooks with
XDP_VE2_BUILD preprocessor conditional to exclude this code
from non-VE2 builds. These hooks are only needed for AIE dtrace
functionality on VE2 XDNA platforms.

Changes:
- Wrap aie::dtrace namespace in profile.cpp with #ifdef XDP_VE2_BUILD
- Wrap run hook functions in xrt_core::xdp namespace with same guard
- Add XDP_VE2_BUILD compile definition to core_common_api_library_objects
  in CMakeLists.txt for VE2 builds
- Guard run hook calls in xrt_kernel.cpp (run constructor, start, wait)
- Update copyright year in profile.h

Made-with: Cursor
Signed-off-by: Garima Dhaked <garima.dhaked@amd.com>
@garimadhaked garimadhaked changed the title Run constructor ct hook Run constructor Run wait and run start hook for temporal sharing usecase Apr 10, 2026
…e check

Replace compile-time XDP_VE2_BUILD guards with runtime aie_dtrace config check
for run_constructor, run_start, and run_wait hooks. Introduce run_info struct
to encapsulate hook arguments and add make_run_info helper for cleaner call sites.

Made-with: Cursor
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

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

info.run_uid = run_uid;
info.kernel_name = kernel_name;
info.elf_handle = elf_handle;
info.ert_cmd_state = ert_cmd_state;
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: uninitialized record type: 'info' [cppcoreguidelines-pro-type-member-init]

Suggested change
info.ert_cmd_state = ert_cmd_state;
xrt_core::xdp::run_info info{};

Signed-off-by: Garima Dhaked <garima.dhaked@amd.com>
Comment on lines +33 to +39
# Compile definitions for VE2 XDNA builds to enable run hooks
if (XDP_VE2_BUILD_CMAKE STREQUAL "yes")
target_compile_definitions(core_common_api_library_objects
PRIVATE
XDP_VE2_BUILD=1
)
endif()
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.

Isn't this a define for just one TU? Scope it to where needed, please.

Comment on lines +4222 to +4232
inline xrt_core::xdp::run_info
make_run_info(void* run, void* hwctx_handle, uint32_t run_uid,
const char* kernel_name, void* elf_handle = nullptr, int ert_cmd_state = 0)
{
xrt_core::xdp::run_info info;
info.run = run;
info.hwctx_handle = hwctx_handle;
info.run_uid = run_uid;
info.kernel_name = kernel_name;
info.elf_handle = elf_handle;
info.ert_cmd_state = ert_cmd_state;
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.

Explain what this is. What, why, how. This function doesn't appear to belong in xrt_kernel.cpp, but I don't know, because I am not sure what the intent is?

Comment on lines +4248 to +4254
if (xrt_core::config::get_aie_dtrace()) {
auto hwctx = krnl.get_handle()->get_hw_context();
const auto& mod = krnl.get_handle()->get_module();
auto elf_hdl = mod ? xrt_core::module_int::get_elf_handle(mod) : nullptr;
auto info = make_run_info(this, hwctx.get_handle().get(), handle->get_uid(),
krnl.get_handle()->get_name().c_str(), elf_hdl.get());
xrt_core::xdp::run_constructor(info);
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.

This code does not belong here in the ctor. Maybe in alloc_run, but again I have no idea what is done here or why?

Comment on lines +4270 to +4275
if (xrt_core::config::get_aie_dtrace()) {
auto hwctx = handle->get_kernel()->get_hw_context();
auto info = make_run_info(this, hwctx.get_handle().get(), handle->get_uid(),
handle->get_kernel()->get_name().c_str());
xrt_core::xdp::run_start(info);
}
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.

Can this code go into xdp rather than be here?
It would be best if we can move XDP specifics to xdp. Sure, you can make a conditional call into xdp form any function, but you should probably move what is done here into xdp?

Comment on lines +4313 to +4317
auto hwctx = handle->get_kernel()->get_hw_context();
auto info = make_run_info(const_cast<xrt::run*>(this), hwctx.get_handle().get(),
handle->get_uid(), handle->get_kernel()->get_name().c_str(),
nullptr, static_cast<int>(state));
xrt_core::xdp::run_wait(info);
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.

Ditto here.

Comment on lines +4332 to +4336
auto hwctx = handle->get_kernel()->get_hw_context();
auto info = make_run_info(const_cast<xrt::run*>(this), hwctx.get_handle().get(),
handle->get_uid(), handle->get_kernel()->get_name().c_str(),
nullptr, static_cast<int>(handle->state()));
xrt_core::xdp::run_wait(info);
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.

I see the same code over and over again, this does not look right.

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.

3 participants