Skip to content

Commit 7d1ba56

Browse files
Get XDP init and exit runs using a callback from XDP code
Signed-off-by: Rahul Bramandlapalli <rbramand@amd.com>
1 parent ef74e7c commit 7d1ba56

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

src/runtime_src/core/common/api/xrt_kernel.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "core/common/trace.h"
4646
#include "core/common/usage_metrics.h"
4747
#include "core/common/xclbin_parser.h"
48+
#include "core/common/xdp/profile.h"
4849

4950
#include <boost/format.hpp>
5051

@@ -3499,8 +3500,7 @@ class runlist_impl
34993500
// These runs initializes AI array for profile/trace data
35003501
// The list can be empty if profile/trace is not enabled
35013502
if (m_runlist.empty()) {
3502-
const auto& xdp_init_runs = xrt_core::hw_context_int::get_xdp_init_runs(m_hwctx);
3503-
for (const auto& init_run : xdp_init_runs) {
3503+
for (const auto& init_run : xrt_core::xdp::get_init_runs(m_hwctx.get_handle().get())) {
35043504
add_run_helper(init_run);
35053505
}
35063506
}
@@ -3521,8 +3521,7 @@ class runlist_impl
35213521
// Add XDP exit runs if any at the end of runlist before submitting
35223522
// These runs collect profile/trace data
35233523
// The list can be empty if profile/trace is not enabled
3524-
const auto& xdp_exit_runs = xrt_core::hw_context_int::get_xdp_exit_runs(m_hwctx);
3525-
for (const auto& exit_run : xdp_exit_runs) {
3524+
for (const auto& exit_run : xrt_core::xdp::get_exit_runs(m_hwctx.get_handle().get())) {
35263525
add_run_helper(exit_run);
35273526
}
35283527

@@ -3569,7 +3568,7 @@ class runlist_impl
35693568
// Remove any XDP exit runs added during execute
35703569
// This is done because runlist can be reused
35713570
// and XDP exit runs should be added at end
3572-
const auto& xdp_exit_runs = xrt_core::hw_context_int::get_xdp_exit_runs(m_hwctx);
3571+
const auto& xdp_exit_runs = xrt_core::xdp::get_exit_runs(m_hwctx.get_handle().get());
35733572
if (xdp_exit_runs.size() > 0) {
35743573
// remove the exit runs from the runlist
35753574
m_runlist.erase(m_runlist.end() - xdp_exit_runs.size(), m_runlist.end());

src/runtime_src/core/common/xdp/profile.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,4 +736,20 @@ finish_flush_device(void* handle)
736736
#endif
737737
}
738738

739+
const std::vector<xrt::run>&
740+
get_init_runs(void* /*hwctx_impl*/)
741+
{
742+
// placeholder, TODO : XDP to add implementation
743+
static std::vector<xrt::run> init_runs;
744+
return init_runs;
745+
}
746+
747+
const std::vector<xrt::run>&
748+
get_exit_runs(void* /*hwctx_impl*/)
749+
{
750+
// placeholder, TODO : XDP to add implementation
751+
static std::vector<xrt::run> exit_runs;
752+
return exit_runs;
753+
}
754+
739755
} // end namespace xrt_core::xdp

src/runtime_src/core/common/xdp/profile.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#ifndef CORE_COMMON_PROFILE_DOT_H
44
#define CORE_COMMON_PROFILE_DOT_H
55

6+
#include "core/include/xrt/xrt_kernel.h"
7+
68
// The functions here are the general interfaces for the XDP hooks that are
79
// called from the common coreutil library and not the specific shims.
810
namespace xrt_core::xdp {
@@ -22,6 +24,20 @@ update_device(void* handle, bool hw_context_flow);
2224
void
2325
finish_flush_device(void* handle);
2426

27+
// get_init_runs returns vector of init runs to be prepended to a runlist.
28+
// These runs initialize the AI array for profile/trace data collection.
29+
// handle passed is the hw_context_impl pointer that is used to create runlist
30+
// This call returns empty vector if no profile/trace options are enabled
31+
const std::vector<xrt::run>&
32+
get_init_runs(void* hwctx_impl);
33+
34+
// get_exit_runs returns vector of exit runs to be appended to a runlist.
35+
// These runs are used to flush out the AI array profile/trace data
36+
// handle passed is the hw_context_impl pointer that is used to create runlist.
37+
// This call returns empty vector if no profile/trace options are enabled
38+
const std::vector<xrt::run>&
39+
get_exit_runs(void* hwctx_impl);
40+
2541
} // end namespace xrt_core::xdp
2642

2743
#endif

0 commit comments

Comments
 (0)