-
Notifications
You must be signed in to change notification settings - Fork 322
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
targets.py: Add ABIName parameter for RISC-V hard float targets #775
Conversation
@occheung thank you for contributing this. I have added it to the queue for review. |
Can we get this merged? Sounds like a simple and valid change. |
@sbourdeauducq I think the problem is that access to RISC-V is limited. Have you been able to test this on some real hardware? |
I can test this - will post an update once I've done so. |
Definitely - our compiler uses llvmlite with the patch and we test it on our FPGA board, we even have hardware-in-the-loop CI. |
@sbourdeauducq How are you building and testing this? Are you building an llvmlite with the RISCV target enabled? |
If you meant LLVM with the RISCV target enabled - yes. |
Thanks... I was originally going about testing this the wrong way - I was building on a RISC-V host and trying to find a way to get the LLVM JIT to work so the whole test suite could run - I've not completed testing this PR yet but haven't forgotten it. |
If you don't have any hardware to test, QEMU can emulate RISC-V. Or just looking at the generated assembly should be enough anyway. |
In that case, is it possible to add a test that can run on the host with a RISC-V target that can check for the expected output in the generated assembly? That would make it a lot easier to check that I'm checking this PR correctly (and also lay a good foundation for future RISC-V-specific code generation functionality and tests). |
#785 is related, as we will want to add RISCV as a target in our LLVM builds in order to run any RISC-V tests in our CI systems. |
Tests regarding the impact of ABI are performed in LLVM already, such as this (albeit in later LLVM version). AFAIK the ABIs should have no influence on how the LLVM IR needs be written? |
Yes. |
Added test to show difference between ABIs. Tests passed locally. Do I enable RISC-V target in LLVM? (Is it through this file?) |
Many thanks for adding the tests! I think that you have found the correct location to modify, but I'm not sure if there's additional places it would need modifying too - I will check. |
ef8d72f
to
864c95f
Compare
Many thanks for adding the RISCV target - note that this will need the llvmdev / llvmlite packages to be rebuilt on our channel before the test starts to pass in CI. |
@gmarkall thank you for tending to this PR. We will need to decide what llvmlite version this should be a part of. |
From our perspective we would really appreciate a Conda Win64 package with RISC-V, this, and #702. |
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.
This generally looks good to me. Some notes:
- WIth Add RISC-V + all default targets to LLVM build #788, the tests passed. 🎉
- I was a little concerned about fragility of the test because it checks the assembly strings line-for-line, but on reflection I don't think they are likely to change unless we upgrade LLVM, so they will likely be stable enough in their current form.
- The documentation in
docs/source/user-guide/binding/target-information.rst
will also need updating, as it isn't generated from the docstring.
42fbdcf
to
4a04450
Compare
@occheung Many thanks for updating the docs! A side note: could I please ask that for future changes you merge master rather than rebasing please? The reason for this is that Github doesn't make it easy to track what happened on the reviewing side in newly-added commits. I think the only substantive change in your last push is the addition of the docs, but it's quite hard for me to tell for certain. Many thanks in advance! |
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.
This looks good to me, assuming that CI passes after new packages have been built following the merge of #788.
/azp run |
Commenter does not have sufficient privileges for PR 775 in repo numba/llvmlite |
/azp run |
Pull request contains merge conflicts. |
@gmarkall I have pushed the conflict resolution patch. |
@gmarkall it looks like this is still bust |
@esc Let's discuss this a little in the dev meeting if there's time. |
Is the issue that the build scripts are looking in channel
whereas it's build 4 that contains the additional cross targets and they are all in |
good catch, that may very well be the case! |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
All tests passed now that the llvmdev packages are available on the main channel - many thanks @esc! |
👌 Excellent! |
@occheung @sbourdeauducq @gmarkall thank you all! |
LLVM requires RISC-V targets to specify ABI if hard float is supported. The current implementation does not allow
TargetOptions.McOptions.ABIName
to be specified.This patch exposes the ABIName to the
create_target_machine
function. So a RISC-V target that supports hard-float can be created like such:Similar feature was also added to Rust's LLVM interface: See discussion | See commit
Alternatively, we can also process the target triple and features to deduce the appropriate ABI.