Skip to content

Commit

Permalink
Dynamic trace support in Telluride
Browse files Browse the repository at this point in the history
Signed-off-by: rbramand <[email protected]>
  • Loading branch information
rbramand committed Jan 28, 2025
1 parent ba5cadc commit d66e5e7
Show file tree
Hide file tree
Showing 7 changed files with 298 additions and 9 deletions.
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

0 comments on commit d66e5e7

Please sign in to comment.