Skip to content

Commit 34d6038

Browse files
authored
AIESW-22124 Loading the whole elf file for just one instance (Xilinx#9548)
Signed-off-by: larry9523 <larry9523@gmail.com>
1 parent cfd5e0c commit 34d6038

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: Apache-2.0
2-
// Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
2+
// Copyright (C) 2022-2026 Advanced Micro Devices, Inc. All rights reserved.
33

44
// This file implements XRT xclbin APIs as declared in
55
// core/include/experimental/xrt_queue.h
@@ -146,6 +146,11 @@ class hw_context_impl : public std::enable_shared_from_this<hw_context_impl>
146146
// using kernel name.
147147
std::map<std::string, xrt::elf> m_elf_map;
148148

149+
// map b/w kernel name and xrt::module
150+
// For xrt::kernel object created in this hw_context, they
151+
// should share the same xrt::module.
152+
std::map<std::string, xrt::module> m_kernel_mod_map;
153+
149154
// No. of cols in the AIE partition managed by this hw ctx
150155
// Devices with no AIE will have partition size as 0
151156
uint32_t m_partition_size = 0;
@@ -393,12 +398,17 @@ class hw_context_impl : public std::enable_shared_from_this<hw_context_impl>
393398
}
394399

395400
xrt::module
396-
get_module(const std::string& kname) const
401+
get_module(const std::string& kname)
397402
{
398-
if (auto itr = m_elf_map.find(kname); itr != m_elf_map.end())
399-
return xrt::module{itr->second}; // create module from the ELF that has this kernel
403+
auto itr = m_elf_map.find(kname);
404+
if (itr == m_elf_map.end())
405+
throw std::runtime_error("no module found with given kernel name in ctx");
406+
407+
auto [kmitr, inserted] = m_kernel_mod_map.try_emplace(kname, xrt::module{});
408+
if (inserted)
409+
kmitr->second = xrt::module{itr->second}; // create module from the ELF that has this kernel
400410

401-
throw std::runtime_error("no module found with given kernel name in ctx");
411+
return kmitr->second;
402412
}
403413

404414
bool

0 commit comments

Comments
 (0)