Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic trace support in ve2 #8721

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/runtime_src/core/common/api/bo_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ XRT_CORE_COMMON_EXPORT
xrt::bo
create_debug_bo(const xrt::hw_context& hwctx, size_t sz);

// create_dtrace_bo() - Create a trace buffer object within a hwctx
//
// Allocates a buffer object within a hwctx used for dynamic tracing.
// The BO is used by driver / firmware to fill dynamic tracing data
// and is shared with user space XRT.
// The shim allocation is through hwctx_handle::alloc_bo with
// the XRT_BO_USE_DTRACE flag captured in extension flags.
XRT_CORE_COMMON_EXPORT
xrt::bo
create_dtrace_bo(const xrt::hw_context& hwctx, size_t sz);

} // bo_int, xrt_core

#endif
5 changes: 5 additions & 0 deletions src/runtime_src/core/common/api/module_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ get_kernel_info(const xrt::module& module);
uint32_t
get_partition_size(const xrt::module& module);

// Dump dynamic trace buffer
// Buffer is dumped after the kernel run is finished
void
dump_dtrace_buffer(const xrt::module& module);

} // xrt_core::module_int

#endif
25 changes: 19 additions & 6 deletions src/runtime_src/core/common/api/xrt_bo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1689,21 +1689,34 @@ get_offset(const xrt::bo& bo)
return handle->get_offset();
}

xrt::bo
create_debug_bo(const xrt::hw_context& hwctx, size_t sz)
static xrt::bo
create_bo_helper(const xrt::hw_context& hwctx, size_t sz, uint32_t use_flag)
{
xcl_bo_flags flags {0}; // see xrt_mem.h
flags.flags = XRT_BO_FLAGS_CACHEABLE;
flags.access = XRT_BO_ACCESS_LOCAL;
flags.dir = XRT_BO_ACCESS_READ_WRITE;
flags.use = XRT_BO_USE_DEBUG;
flags.use = use_flag;

// While the memory group should be ignored (inferred) for debug
// buffers, it is still passed in as a default group 1 with no
// implied correlation to xclbin connectivity or memory group.
// While the memory group should be ignored (inferred) for
// debug / trace buffers, it is still passed in as a default
// group 1 with no implied correlation to xclbin connectivity
// or memory group.
return xrt::bo{alloc(device_type{hwctx}, sz, flags.all, 1)};
}

xrt::bo
create_debug_bo(const xrt::hw_context& hwctx, size_t sz)
{
return create_bo_helper(hwctx, sz, XRT_BO_USE_DEBUG);
}

xrt::bo
create_dtrace_bo(const xrt::hw_context& hwctx, size_t sz)
{
return create_bo_helper(hwctx, sz, XRT_BO_USE_DTRACE);
}

} // xrt_core::bo_int

////////////////////////////////////////////////////////////////
Expand Down
11 changes: 11 additions & 0 deletions src/runtime_src/core/common/api/xrt_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2522,6 +2522,11 @@ class run_impl
static bool dump = xrt_core::config::get_feature_toggle("Debug.dump_scratchpad_mem");
if (dump)
xrt_core::module_int::dump_scratchpad_mem(m_module);

// dump dtrace buffer if ini option is enabled
static auto dtrace_lib_path = xrt_core::config::get_dtrace_lib_path();
if (!dtrace_lib_path.empty())
xrt_core::module_int::dump_dtrace_buffer(m_module);

return state;
}
Expand All @@ -2546,6 +2551,12 @@ class run_impl
state = cmd->wait();
}

// dump dtrace buffer if ini option is enabled
// here dtrace is dumped in both passing and timeout cases
static auto dtrace_lib_path = xrt_core::config::get_dtrace_lib_path();
if (!dtrace_lib_path.empty())
xrt_core::module_int::dump_dtrace_buffer(m_module);

if (state == ERT_CMD_STATE_COMPLETED) {
m_usage_logger->log_kernel_run_info(kernel.get(), this, state);
static bool dump = xrt_core::config::get_feature_toggle("Debug.dump_scratchpad_mem");
Expand Down
Loading
Loading