Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: rbramand <[email protected]>
  • Loading branch information
rbramand committed Nov 14, 2024
1 parent 2c25976 commit e86d2c8
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/runtime_src/core/common/api/xrt_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,9 @@ class module_elf_aie2p : public module_elf
size_t m_scratch_pad_mem_size = 0;
uint32_t m_partition_size = UINT32_MAX;

std::vector<std::string> m_ctrlpkt_pm_dynsyms; // preemption dynsyms in elf
std::map<std::string, buf> m_ctrlpkt_pm_bufs; // preemption buffers map

xrt_core::module_int::kernel_info m_kernel_info;

static uint32_t
Expand Down Expand Up @@ -891,6 +894,20 @@ class module_elf_aie2p : public module_elf
return false;
}

// Extract ctrlpkt preemption buffers from ELF sections
// and store it in map with section name as key
void
initialize_ctrlpkt_pm_bufs()
{
for (const auto& sec : m_elfio.sections) {
auto name = sec->get_name();
if (name.find(patcher::section_name_to_string(patcher::buf_type::ctrlpkt_pm)) == std::string::npos)
continue;

m_ctrlpkt_pm_bufs[name].append_section_data(sec.get());
}
}

std::pair<size_t, patcher::buf_type>
determine_section_type(const std::string& section_name)
{
Expand Down Expand Up @@ -954,6 +971,12 @@ class module_elf_aie2p : public module_elf
m_scratch_pad_mem_size = static_cast<size_t>(sym->st_size);
}

static constexpr const char* ctrlpkt_pm_dynsym = "ctrlpkt-pm";
if (std::string(symname).find(ctrlpkt_pm_dynsym) != std::string::npos) {
// store ctrlpkt preemption symbols which is later used for patching instr buf
m_ctrlpkt_pm_dynsyms.emplace_back(symname);
}

// Get control code section referenced by the symbol, col, and page
auto section = m_elfio.sections[sym->st_shndx];
if (!section)
Expand Down Expand Up @@ -1012,6 +1035,7 @@ class module_elf_aie2p : public module_elf
throw std::runtime_error{ "Invalid elf because preempt save and restore is not paired" };

initialize_pdi_buf();
initialize_ctrlpkt_pm_bufs();
initialize_arg_patchers();
}

Expand Down Expand Up @@ -1066,6 +1090,18 @@ class module_elf_aie2p : public module_elf
return std::make_pair(UINT32_MAX, control_packet::get_empty_buf());
}

[[nodiscard]] const std::vector<std::string>&
get_ctrlpkt_pm_dynsyms() const override
{
return m_ctrlpkt_pm_dynsyms;
}

[[nodiscard]] virtual const std::map<std::string, buf>&
get_ctrlpkt_pm_bufs() const override
{
return m_ctrlpkt_pm_bufs;
}

[[nodiscard]] virtual size_t
get_scratch_pad_mem_size() const override
{
Expand Down Expand Up @@ -1489,7 +1525,7 @@ class module_sram : public module_impl
auto bo_itr = m_ctrlpkt_pm_bos.find(sec_name);
if (bo_itr == m_ctrlpkt_pm_bos.end())
throw std::runtime_error("Unable to find ctrlpkt pm buffer for symbol " + dynsym);
patch_instr(m_instr_bo, dynsym, 0, bo_itr->second, patcher::buf_type::ctrltext);
patch_instr(m_instr_bo, dynsym, 0, bo_itr->second, patcher::buf_type::ctrltext, m_instr_sec_idx);
}

XRT_DEBUGF("<- module_sram::create_instr_buf()\n");
Expand Down

0 comments on commit e86d2c8

Please sign in to comment.