-
Notifications
You must be signed in to change notification settings - Fork 478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xclbin to ELF flow migration #8581
base: master
Are you sure you want to change the base?
Conversation
ef27174
to
8539462
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good. I am not completely done reviewing, but maybe address my first points and I will review again.
kernel_properties::mailbox_type | ||
get_mailbox_from_ini(const std::string& kname) | ||
{ | ||
static auto mailbox_kernels = xrt_core::config::get_mailbox_kernels(); | ||
return (mailbox_kernels.find("/" + kname + "/") != std::string::npos) | ||
? xrt_core::xclbin::kernel_properties::mailbox_type::inout | ||
: xrt_core::xclbin::kernel_properties::mailbox_type::none; | ||
} | ||
|
||
// Kernel auto restart counter offset | ||
// Needed until meta-data support (Vitis-1147) | ||
kernel_properties::restart_type | ||
get_restart_from_ini(const std::string& kname) | ||
{ | ||
static auto restart_kernels = xrt_core::config::get_auto_restart_kernels(); | ||
return (restart_kernels.find("/" + kname + "/") != std::string::npos) | ||
? 1 | ||
: 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather not. Instead of rebuilding the properties, please cache a pointer to the existing properties that have all the information
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to export these functions?
bool | ||
get_sw_reset_from_ini(const std::string& kname) | ||
{ | ||
static auto reset_kernels = xrt_core::config::get_sw_reset_kernels(); | ||
return (reset_kernels.find("/" + kname + "/") != std::string::npos); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same export question
kernel_properties::mailbox_type | ||
get_mailbox_from_ini(const std::string& kname); | ||
|
||
kernel_properties::restart_type | ||
get_restart_from_ini(const std::string& kname); | ||
|
||
bool | ||
get_sw_reset_from_ini(const std::string& kname); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets avoid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still open?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need these functions while creating properties in ELF flow as well @stsoe , should I use static functions there as well? I moved these functions in header so that there wont be code duplicity
@hlaccabu recently added some code to enable elf flow in xrt-smi validate for npu3. Please work with him to make sure that this change doesn't breaks the existing code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good to go from driver perspective. As long as driver's xrt submodule (and corresponding xrt_plugin.deb) contains these changes as well as the XRT .deb.
@hlaccabu can you please check if your feature doesn't break with these changes |
Yep you're all set, the xrt-smi tests that I enabled for npu3 still run |
8539462
to
d199a7f
Compare
ca47bb5
to
a899344
Compare
Hi @stsoe , created CR - https://jira.xilinx.com/browse/CR-1219757 for refactoring existing code to move ELF parsing to xrt::elf object and make it similar to xrt::xclbin. |
@rbramand-xilinx , Did we run any exsiting preemption test to make sure we won't break any? |
a899344
to
6e61f5f
Compare
Hi @larry9523 , I have run preemption test cases with my changes and found 1 bug and fixed it. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more comments. I did not review xrt_module.cpp.
// 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)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhh, this is a little hard to parse.
This is the second place name is parsed at :
. Can this parsing be re-factored into say
std::pair<std::string, uint32_t>
static get_kernel_name_and_ctrl_code_index(const std::string& nm)
{
...
return {name, index};
}
Then use as
std::tie(name, m_ctrl_code_index) = get_name_and_ctrl_code_index(nm);
Maybe choose a better function name for the refactored code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will refactor the code Soren, my attempt was to use initializer list for most of the class members but yeah it does not look good.
kernel_properties::mailbox_type | ||
get_mailbox_from_ini(const std::string& kname) | ||
{ | ||
static auto mailbox_kernels = xrt_core::config::get_mailbox_kernels(); | ||
return (mailbox_kernels.find("/" + kname + "/") != std::string::npos) | ||
? xrt_core::xclbin::kernel_properties::mailbox_type::inout | ||
: xrt_core::xclbin::kernel_properties::mailbox_type::none; | ||
} | ||
|
||
// Kernel auto restart counter offset | ||
// Needed until meta-data support (Vitis-1147) | ||
kernel_properties::restart_type | ||
get_restart_from_ini(const std::string& kname) | ||
{ | ||
static auto restart_kernels = xrt_core::config::get_auto_restart_kernels(); | ||
return (restart_kernels.find("/" + kname + "/") != std::string::npos) | ||
? 1 | ||
: 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to export these functions?
bool | ||
get_sw_reset_from_ini(const std::string& kname) | ||
{ | ||
static auto reset_kernels = xrt_core::config::get_sw_reset_kernels(); | ||
return (reset_kernels.find("/" + kname + "/") != std::string::npos); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same export question
kernel_properties::mailbox_type | ||
get_mailbox_from_ini(const std::string& kname); | ||
|
||
kernel_properties::restart_type | ||
get_restart_from_ini(const std::string& kname); | ||
|
||
bool | ||
get_sw_reset_from_ini(const std::string& kname); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still open?
f3576d4
to
fccc82e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now. Let me know when you have resolved if we really need to export internal xclbin_parser functions or not.
9cc746f
to
c2e4500
Compare
Hi @stsoe, we don't need those functions to be exported. I have reverted the change and verified the testcase it passes. |
Signed-off-by: rbramand <[email protected]>
Signed-off-by: rbramand <[email protected]>
Signed-off-by: rbramand <[email protected]>
Signed-off-by: rbramand <[email protected]>
Signed-off-by: rbramand <[email protected]>
Signed-off-by: rbramand <[email protected]>
30de0c6
to
46f9f30
Compare
Signed-off-by: rbramand <[email protected]>
46f9f30
to
e86d2c8
Compare
Problem solved by the commit
This PR enables new flow where ELF file is input instead of xclbin.
spec - https://confluence.amd.com/display/AIE/AIE+Compiler+Artifacts#AIECompilerArtifacts-Flow2
spec of new config elf - https://confluence.amd.com/pages/viewpage.action?pageId=1485002156#Profile/Config/CtrlcodeElfSpec-Config.elf
This new Elf has partition size and kernel signature.
It has multiple .ctrltext and .ctrldata sections and multiple .pdi sections.
Each ctrltext section represents one control code and pdi addresses along with kernel args needs to be patched into the control code buffer.
Control code that needs to be run is decided while creating xrt::kernel object using kernel name - <kernel_name>:<ctrl_code_id> eg: "DPU:0" runs with control code from section .ctrltext0 and "DPU:1" runs with control code from section .ctrlcode1
Sample test case :
XRT first class object changes :
xrt::hw_context - Added new APIs to create context using Elf instead of xclbin
xrt::kernel - Added new ext API to create kernel object using kernel name, added changes to construct kernel args from kernel signature.
xrt::elf - can now take new Elf with os abi 70 as input
xrt::module - added changes to parse this new Elf, also refactored code
TODO : Refactor code to parse ELF file using xrt::elf class and make it similar to xrt::xclbin. Created CR - https://jira.xilinx.com/browse/CR-1219757 for tracking this.
Bug / issue (if any) fixed, which PR introduced the bug, how it was discovered
This is a new feature
How problem was solved, alternative solutions (if any) and why they were rejected
Hw context can be created either with xclbin (traditional flow) or with xrt::elf. A new constructor is provided for same.
A new xrt::ext::kernel constructor is provided that takes ctx and kernel name as input.
Added code to parse new Elf file and patch it according to spec.
Rest of the flow remains same
Risks (if any) associated the changes in the commit
Low to medium
Tested the existing flows but needs more testing with all the available test cases.
What has been tested and how, request additional testing if necessary
Tested with new application flow on aie2p simnow (needs changes with respect to flow in amdxdna shim and firmware, changes are yet to be merged, so tested with local drops)
Tested existing test cases on phoenix hw (linux) and tests passes so existing flow didn't break.
TODO : check whether existing aie2ps test cases work
Documentation impact (if any)
Added doxygen comments in code for new APIs added, may be we need to document about new flow after it is stabilized.