Skip to content

Commit

Permalink
VITIS-13530 : Add support to dump scratch pad memory (Xilinx#8503)
Browse files Browse the repository at this point in the history
* Dump scrtach pad memory when available

Signed-off-by: rbramand <[email protected]>

* Address comments on PR

Signed-off-by: rbramand <[email protected]>

---------

Signed-off-by: rbramand <[email protected]>
Co-authored-by: rbramand <[email protected]>
  • Loading branch information
rbramand-xilinx and rbramand authored Oct 9, 2024
1 parent 5448dd1 commit 76b9e7d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/runtime_src/core/common/api/module_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ sync(const xrt::module&);
ert_cmd_opcode
get_ert_opcode(const xrt::module& module);

// Dump scratch pad mem buffer
void
dump_scratchpad_mem(const xrt::module& module);

} // xrt_core::module_int

#endif
7 changes: 7 additions & 0 deletions src/runtime_src/core/common/api/xrt_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2478,6 +2478,9 @@ class run_impl
}

m_usage_logger->log_kernel_run_info(kernel.get(), this, state);
static bool dump = xrt_core::config::get_feature_toggle("Debug.dump_scratchpad_mem");
if (dump)
xrt_core::module_int::dump_scratchpad_mem(m_module);

return state;
}
Expand All @@ -2504,6 +2507,10 @@ class run_impl

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");
if (dump)
xrt_core::module_int::dump_scratchpad_mem(m_module);

return std::cv_status::no_timeout;
}

Expand Down
30 changes: 30 additions & 0 deletions src/runtime_src/core/common/api/xrt_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,26 @@ class module_sram : public module_impl
{
return m_scratch_pad_mem;
}

void
dump_scratchpad_mem()
{
if (m_scratch_pad_mem.size() == 0) {
xrt_core::message::send(xrt_core::message::severity_level::debug, "xrt_module",
"preemption scratchpad memory is not available");
return;
}

// sync data from device before dumping into file
m_scratch_pad_mem.sync(XCL_BO_SYNC_BO_FROM_DEVICE);

std::string dump_file_name = "preemption_scratchpad_mem" + std::to_string(get_id()) + ".bin";
dump_bo(m_scratch_pad_mem, dump_file_name);

std::string msg {"dumped file "};
msg.append(dump_file_name);
xrt_core::message::send(xrt_core::message::severity_level::debug, "xrt_module", msg);
}
};

} // namespace xrt
Expand Down Expand Up @@ -1470,6 +1490,16 @@ get_ert_opcode(const xrt::module& module)
return module.get_handle()->get_ert_opcode();
}

void
dump_scratchpad_mem(const xrt::module& module)
{
auto module_sram = std::dynamic_pointer_cast<xrt::module_sram>(module.get_handle());
if (!module_sram)
throw std::runtime_error("Getting module_sram failed, wrong module object passed\n");

module_sram->dump_scratchpad_mem();
}

} // xrt_core::module_int

////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 76b9e7d

Please sign in to comment.