Run constructor Run wait and run start hook for temporal sharing usecase#9721
Run constructor Run wait and run start hook for temporal sharing usecase#9721garimadhaked wants to merge 17 commits intoXilinx:masterfrom
Conversation
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
This reverts commit befc23e.
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>
| inline unsigned int | ||
| get_aie_dtrace_settings_interval_us() | ||
| { | ||
| static unsigned int value = detail::get_uint_value("AIE_dtrace_settings.interval_us", 1000); |
There was a problem hiding this comment.
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>
…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
| info.run_uid = run_uid; | ||
| info.kernel_name = kernel_name; | ||
| info.elf_handle = elf_handle; | ||
| info.ert_cmd_state = ert_cmd_state; |
There was a problem hiding this comment.
warning: uninitialized record type: 'info' [cppcoreguidelines-pro-type-member-init]
| info.ert_cmd_state = ert_cmd_state; | |
| xrt_core::xdp::run_info info{}; |
Signed-off-by: Garima Dhaked <garima.dhaked@amd.com>
| # 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() |
There was a problem hiding this comment.
Isn't this a define for just one TU? Scope it to where needed, please.
| 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; |
There was a problem hiding this comment.
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?
| 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); |
There was a problem hiding this comment.
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?
| 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); | ||
| } |
There was a problem hiding this comment.
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?
| 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); |
| 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); |
There was a problem hiding this comment.
I see the same code over and over again, this does not look right.
Fix : Added XDP dtrace plugin support for temporal sharing usecase.
Testing: Verified few examples with and without XDP dtrace plugin. Verified temporal sharing example as well.