From ca47bb5196514a5a5faa932441e756344187c9d6 Mon Sep 17 00:00:00 2001 From: rbramand Date: Fri, 1 Nov 2024 21:42:35 +0530 Subject: [PATCH] Fix failure Signed-off-by: rbramand --- .../core/common/api/xrt_kernel.cpp | 61 +++++++++---------- .../core/common/api/xrt_module.cpp | 12 ++-- 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/src/runtime_src/core/common/api/xrt_kernel.cpp b/src/runtime_src/core/common/api/xrt_kernel.cpp index 1705a6d47a..48e40dcb16 100644 --- a/src/runtime_src/core/common/api/xrt_kernel.cpp +++ b/src/runtime_src/core/common/api/xrt_kernel.cpp @@ -1505,39 +1505,18 @@ class kernel_impl : public std::enable_shared_from_this return data; // no skipping } - xrt::module + static xrt::module get_module(const xrt::hw_context& ctx, const std::string& kname) { - // ELF use case, identify module from ctx that has given kernel name and - // get kernel signature from the module to construct kernel args etc + // ELF use case, identify module from ctx that has given kernel name // kernel name will be of format - : auto i = kname.find(":"); if (i == std::string::npos) { - // default case - ctrl code 0 will be used - name = kname.substr(0, kname.size()); - m_ctrl_code_index = 0; + // default case + return xrt_core::hw_context_int::get_module(ctx, kname.substr(0, kname.size())); } - else { - name = kname.substr(0, i); - m_ctrl_code_index = std::stoul(kname.substr(i+1, kname.size()-i-1)); - } - - return xrt_core::hw_context_int::get_module(ctx, name); - } - - const property_type& - get_elf_kernel_properties() - { - // Get kernel info from module - const auto& kernel_info = xrt_core::module_int::get_kernel_info(m_module); - if (name != kernel_info.props.name) - throw std::runtime_error("Kernel name mismatch, incorrect module picked\n"); - - // set kernel args - for (auto& arg : kernel_info.args) - args.emplace_back(arg); - - return kernel_info.props; + else + return xrt_core::hw_context_int::get_module(ctx, kname.substr(0, i)); } static uint32_t @@ -1616,15 +1595,31 @@ class kernel_impl : public std::enable_shared_from_this } kernel_impl(std::shared_ptr dev, xrt::hw_context ctx, const std::string& nm) - : device(std::move(dev)) // share ownership - , hwctx(std::move(ctx)) // hw context - , hwqueue(hwctx) // hw queue - , m_module(get_module(hwctx, nm)) // module object with matching kernel name - , properties(get_elf_kernel_properties()) // kernel info present in Elf + : device(std::move(dev)) // share ownership + , hwctx(std::move(ctx)) // hw context + , hwqueue(hwctx) // hw queue + , m_module(get_module(hwctx, nm)) // module object with matching kernel name + , properties(xrt_core::module_int::get_kernel_info(m_module).props) // kernel info present in Elf , uid(create_uid()) { XRT_DEBUGF("kernel_impl::kernel_impl(%d)\n", uid); + // initialize kernel name and ctrl code index + auto i = nm.find(":"); + if (i == std::string::npos) { + // default case - ctrl code 0 will be used + name = nm.substr(0, nm.size()); + m_ctrl_code_index = 0; + } + else { + name = nm.substr(0, i); + m_ctrl_code_index = std::stoul(nm.substr(i+1, nm.size()-i-1)); + } + + // initialize kernel args + for (auto& arg : xrt_core::module_int::get_kernel_info(m_module).args) + args.emplace_back(arg); + // amend args with computed data based on kernel protocol amend_args(); m_usage_logger->log_kernel_info(device->core_device.get(), hwctx, name, args.size()); @@ -3489,7 +3484,7 @@ alloc_kernel(const std::shared_ptr& dev, xrt::kernel::cu_access_mode mode) { auto amode = hwctx_access_mode(mode); // legacy access mode to hwctx qos - return std::make_shared(dev, xrt::hw_context{dev->get_xrt_device(), xclbin_id, amode}, name); + return std::make_shared(dev, xrt::hw_context{dev->get_xrt_device(), xclbin_id, amode}, xrt::module{}, name); } static std::shared_ptr diff --git a/src/runtime_src/core/common/api/xrt_module.cpp b/src/runtime_src/core/common/api/xrt_module.cpp index 979da54fe2..ea7dcbc4cc 100644 --- a/src/runtime_src/core/common/api/xrt_module.cpp +++ b/src/runtime_src/core/common/api/xrt_module.cpp @@ -1377,8 +1377,9 @@ class module_sram : public module_impl create_instr_buf(const module_impl* parent) { XRT_DEBUGF("-> module_sram::create_instr_buf()\n"); - instr_buf data; - std::tie(m_instr_sec_idx, data) = parent->get_instr(m_index); + auto instr_buf_info = parent->get_instr(m_index); + m_instr_sec_idx = instr_buf_info.first; + const instr_buf& data = instr_buf_info.second; size_t sz = data.size(); if (sz == 0) throw std::runtime_error("Invalid instruction buffer size"); @@ -1461,8 +1462,9 @@ class module_sram : public module_impl void create_ctrlpkt_buf(const module_impl* parent) { - control_packet data; - std::tie(m_ctrlpkt_sec_idx, data) = parent->get_ctrlpkt(m_index); + auto ctrl_pkt_info = parent->get_ctrlpkt(m_index); + m_ctrlpkt_sec_idx = ctrl_pkt_info.first; + const control_packet& data = ctrl_pkt_info.second; size_t sz = data.size(); if (sz == 0) { @@ -1788,7 +1790,7 @@ patch(const xrt::module& module, uint8_t* ibuf, size_t* sz, const std::vectorget_os_abi(); if (os_abi == Elf_Amd_Aie2p || os_abi == Elf_Amd_Aie2p_config) { - const auto& buf_info = hdl->get_instr(idx); + auto buf_info = hdl->get_instr(idx); patch_index = buf_info.first; inst = &(buf_info.second); }