Add get_aie_coredump_elf() API for generating coredump (ET_CORE) ELF - #9997
Add get_aie_coredump_elf() API for generating coredump (ET_CORE) ELF#9997sayyanna wants to merge 6 commits into
Conversation
Signed-off-by: Sri Latha Ayyannagari <SriLatha.Ayyannagari@amd.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
stsoe
left a comment
There was a problem hiding this comment.
Please comment the code, structs, etc.
| case aiebu::osabi_aie2p: return aiebu::aiebu_assembler::buffer_type::coredump_aie2p; | ||
| case aiebu::osabi_aie2ps: return aiebu::aiebu_assembler::buffer_type::coredump_aie2ps; | ||
| case aiebu::osabi_aie4: return aiebu::aiebu_assembler::buffer_type::coredump_aie4; | ||
| case aiebu::osabi_aie4a: return aiebu::aiebu_assembler::buffer_type::coredump_aie4a; | ||
| case aiebu::osabi_aie4z: return aiebu::aiebu_assembler::buffer_type::coredump_aie4z; | ||
| default: throw std::runtime_error("AIE coredump not supported for this ELF architecture"); |
There was a problem hiding this comment.
Impossible to debug, please new line after case
| throw std::runtime_error("AIE coredump ELF not available: no ELF loaded in this context"); | ||
| // All ELFs in one hw_context target the same AIE partition — any entry yields correct OS/ABI |
| throw std::runtime_error("AIE coredump ELF not available: no ELF loaded in this context"); | ||
| // All ELFs in one hw_context target the same AIE partition — any entry yields correct OS/ABI |
| auto buf_type = osabi_to_coredump_type(elf.get_handle()->get_os_abi()); | ||
| aiebu::aiebu_assembler a(buf_type, blob, aiebu::aiebu_assembler::no_meta); | ||
| return a.get_elf(); |
There was a problem hiding this comment.
What makes this XRT code? Should it be in aiebu. Comments may help explain why it is here.
| #include <vector> | ||
|
|
||
| namespace xrt::aie { | ||
|
|
There was a problem hiding this comment.
This is a public API, these structs need extensive comments.
I am not sure about the aie namespace within this file. I need to think about this.
|
One more question, who is the consumer of these new APIs? If it is XDP, I would argue that they should add this code themselves. E.g. first get the raw coredump from XRT, then re-package it using aiebu. |
larry9523
left a comment
There was a problem hiding this comment.
A few high level comments
- please add some detail in the PR description about why are we doing this.
- I would suggest we only provide one public API get_aie_coredump_elf() internally it will create an ELF coredump with metadata. It does not hurt to add metadata into ELF. (Thanks @stsoe for the input)
- I think there is no consumer of xrt.ini path to create aie coredump (I confirm this with @IshitaGhosh and @jvillarre). So while we keep our xrt::hw_context::get_aie_coredump() API, we should generate ELF format coredump with metadata for the xrt,ini path.
Signed-off-by: Sri Latha Ayyannagari <SriLatha.Ayyannagari@amd.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
Signed-off-by: Sri Latha Ayyannagari <SriLatha.Ayyannagari@amd.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
Signed-off-by: Sri Latha Ayyannagari <SriLatha.Ayyannagari@amd.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
| for (const auto& entry : data) { | ||
| if (std::stoi(entry.metadata.id) == islot) { | ||
| meta.context_status = entry.is_suspended | ||
| ? aiebu::aie_context_status::idle | ||
| : aiebu::aie_context_status::running; | ||
| break; | ||
| } |
There was a problem hiding this comment.
One less scope with early-continue
| for (const auto& entry : data) { | |
| if (std::stoi(entry.metadata.id) == islot) { | |
| meta.context_status = entry.is_suspended | |
| ? aiebu::aie_context_status::idle | |
| : aiebu::aie_context_status::running; | |
| break; | |
| } | |
| for (const auto& entry : data) { | |
| if (std::stoi(entry.metadata.id) != islot) | |
| continue; | |
| meta.context_status = entry.is_suspended | |
| ? aiebu::aie_context_status::idle | |
| : aiebu::aie_context_status::running; | |
| break; | |
| } |
| namespace { | ||
|
|
||
| aiebu::aiebu_assembler::buffer_type | ||
| osabi_to_coredump_type(uint8_t os_abi) | ||
| { | ||
| switch (os_abi) { | ||
| case aiebu::osabi_aie2p: | ||
| return aiebu::aiebu_assembler::buffer_type::coredump_aie2p; | ||
| case aiebu::osabi_aie2ps: | ||
| return aiebu::aiebu_assembler::buffer_type::coredump_aie2ps; | ||
| case aiebu::osabi_aie4: | ||
| return aiebu::aiebu_assembler::buffer_type::coredump_aie4; | ||
| case aiebu::osabi_aie4a: | ||
| return aiebu::aiebu_assembler::buffer_type::coredump_aie4a; | ||
| case aiebu::osabi_aie4z: | ||
| return aiebu::aiebu_assembler::buffer_type::coredump_aie4z; | ||
| default: | ||
| throw std::runtime_error("AIE coredump not supported for this ELF architecture"); | ||
| } | ||
| } | ||
|
|
||
| } // namespace |
There was a problem hiding this comment.
Don't scope the anonymous namespace inside a named namespace, move it out, or make this a static function within current namespace to keep the proximity to where it is used.
| if (!ostr) | ||
| throw std::runtime_error("Could not open '" + file + "' for writing"); | ||
| ostr.write(core.data(), static_cast<std::streamsize>(core.size())); | ||
| std::abort(); |
There was a problem hiding this comment.
I think there was a mention that we should not abort on coredump, but the original spec said we should. I want to make sure remove std::abort() is indeed correct.
There was a problem hiding this comment.
We should keep the std::abort() to make sure driver clean up hw_context after timeout. We don't have to get the exception message and coredump() at one run. When usesrs set xrt.ini to save aie coredump, they already see the timeout and exception message.
Signed-off-by: Sri Latha Ayyannagari <SriLatha.Ayyannagari@amd.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
Signed-off-by: Sri Latha Ayyannagari <SriLatha.Ayyannagari@amd.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
stsoe
left a comment
There was a problem hiding this comment.
Looks good. Minor corrections.
| : ""; | ||
| } | ||
|
|
||
| aiebu::aiebu_assembler::buffer_type |
There was a problem hiding this comment.
It was previously in a nested unnamed namespace, I suggested either moving the namespace or making the function static,
| aiebu::aiebu_assembler::buffer_type | |
| static aiebu::aiebu_assembler::buffer_type |
| for (const auto& kv : *drivers) { | ||
| const auto& drv = kv.second; |
There was a problem hiding this comment.
It is generally preferred to use structured bindings for anything return tuples.
| for (const auto& kv : *drivers) { | |
| const auto& drv = kv.second; | |
| for (const auto& [dummy, drv] : *drivers) { |
| return xrt_core::elf_int::make_aie_coredump_elf( | ||
| elf, get_aie_coredump(), m_core_device.get(), m_hdl->get_slotidx(), ""); |
There was a problem hiding this comment.
You defaulted the uuid string in make_aie_coredump_elf, which I think is fine, but then this function should not mention anything about UUID and not call with the empty string.
Problem solved by the commit
Add get_aie_coredump_elf() API for generating coredump (ET_CORE) ELF
Bug / issue (if any) fixed, which PR introduced the bug, how it was discovered
Add get_aie_coredump_elf() API for generating coredump (ET_CORE) ELF. Currently AIE coredump is generated as a raw bin file, but this PR enables generated of coredump in ELF format. The existing get_aie_coredump() raw blob API will be deprecated.
How problem was solved, alternative solutions (if any) and why they were rejected
Added new API that package a raw AIE coredump blob into an ET_CORE ELF using the AIEBU coredump ELF writer:
std::vector
get_aie_coredump_elf(std::optionalxrt::aie::coredump_meta meta = std::nullopt) const;
The AIE architecture is derived from the ELF loaded in this context. Metadata (timestamp, versions, device info, uuid) is always embedded. If @meta is provided it is used as-is; otherwise metadata is built internally from the hw_context and device.
The coredump ELF packaging logic lives in xrt_elf.cpp and is exposed internally via xrt_core::elf_int::make_aie_coredump_elf, keeping xrt_hw_context.cpp free of any direct aiebu dependency.
Packaging the dump as an ET_CORE ELF solves:
Risks (if any) associated the changes in the commit
None
What has been tested and how, request additional testing if necessary
Added below setting in xrt.ini
[Runtime]
aie_coredump_file = aie_coredump.elf
Enabled coredump: xrt-smi configure --advanced --auto-coredump --enable
then triggered ERT_COM_STATE_TIMEOUT, coredump is ELF generated.
Documentation impact (if any)