-
Notifications
You must be signed in to change notification settings - Fork 319
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
Add LLVM 14 support #830
Add LLVM 14 support #830
Conversation
Thanks for starting work on LLVM 14 support. In thinking about how to make it easier to review the changes needed, perhaps the following approach might work:
What do you think? |
Sure. I've created #831 for the code formatting changes. I'm going to leave this PR open so I can use it for the build farm. |
Thanks, keeping this open for testing purposes sounds like a good plan. |
Hi, Here is svml patch for llvm 14 Hardcode84/llvm-project@bc2dcd1 |
The newset version can depend on llvm:13 which is still in ::gentoo And there is ongoing efforts of migrating to llvm:14 See numba/llvmlite#830 Signed-off-by: Yiyang Wu <xgreenlandforwyy@gmail.com>
The newset version can depend on llvm:13 which is still in ::gentoo And there is ongoing efforts of migrating to llvm:14 See numba/llvmlite#830 Signed-off-by: Yiyang Wu <xgreenlandforwyy@gmail.com>
The newset version can depend on llvm:13 which is still in ::gentoo And there is ongoing efforts of migrating to llvm:14 See numba/llvmlite#830 Signed-off-by: Yiyang Wu <xgreenlandforwyy@gmail.com> Closes: #1164 Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
conda-recipes/llvmdev/meta.yaml
Outdated
{% set sha256_lld = "017a788cbe1ecc4a949abf10755870519086d058a2e99f438829aef24f0c66ce" %} | ||
{% set shortversion = "14.0" %} | ||
{% set version = "14.0.1" %} | ||
{% set sha256_llvm = "1a3c2e57916c5a70153aaf0a0e6f1230d6368b9e0f4d04dcb9e039a31b1cd4e6" %} | ||
{% set build_number = "5" %} |
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.
rmbr to reset this before merge
conda-recipes/llvmlite/meta.yaml
Outdated
- llvmdev 14.0.1 *5 # [(osx and arm64)] | ||
- llvmdev 14.0.1 *4 # [not ((osx and arm64) or win)] | ||
- llvmdev 14.0.1 4 # [win] |
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.
- llvmdev 14.0.1 *5 # [(osx and arm64)] | |
- llvmdev 14.0.1 *4 # [not ((osx and arm64) or win)] | |
- llvmdev 14.0.1 4 # [win] | |
- llvmdev 14.0.1 |
Thanks for pointing me here from the llvmlite patch. How important are the patches to llvm itself? There seems to be a bunch of changes in the conda recipes, are those needed outside of a conda environment? |
The patches to LLVM 14 that are included with the recipe are pretty important. Numba uses SVML and that is not in LLVM mainline and needs to be patched in. Some of the other changes are for building on different environments (MacOS and Windows can be uncooperative). |
That's not on our roadmap yet. LLVM 15 has a number of breaking changes in the way it handles pointers, and we aren't prepared to handle those yet. |
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.
@apmasell, try vs2019 and pinning to 14.2 toolset:
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Before proceeding, we should get more cases. Particular, we can to see if there are other patterns if multiple exceptions of different exception type are raised.
e.g.
if cond_a:
raise ValueError
elif cond_b:
raise TypeError
else:
return ok
ffi/custom_passes.cpp
Outdated
auto operand = first->getOperand(0); | ||
// If the operand is a constant, check if it indicates an exception | ||
auto int_operand = dyn_cast<ConstantInt>(operand); | ||
if (int_operand && !int_operand->isZeroValue()) { |
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.
Seems like it will always be one according to the old code.
// and then cast the const as Metadata (Numba sets this as literal
// 1)
auto data = dyn_cast<ConstantAsMetadata>(operand.get());
But other negative non-zero value can indicate other non-raising condition.
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.
See https://github.com/numba/numba/blob/9d4f82df7f0426d89b189eafc7acdc6bf719c716/numba/core/callconv.py#L473-L479. It's Numba handling the return code. For this refprune case, we used to only care about user exception. The existing Numba code seems to only ever emit 1
. Numba callconv may need to clean up.
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.
The case that is failing in the Numba repository emits a 1
, so I'm not sure what's going on with the calling convetions.
ffi/custom_passes.cpp
Outdated
if (phi_operand) { | ||
auto arg_value = dyn_cast<ConstantInt>( | ||
phi_operand->getIncomingValueForBlock(bb)); | ||
return arg_value && !arg_value->isZeroValue(); |
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 as earlier, not all non-zero value means exception
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.
The way the LLVM constants are set up, I can only check for 0, 1, and -1. https://llvm.org/doxygen/classllvm_1_1Constant.html
ffi/custom_passes.cpp
Outdated
auto phi_operand = dyn_cast<PHINode>(operand); | ||
if (phi_operand) { | ||
auto arg_value = dyn_cast<ConstantInt>( | ||
phi_operand->getIncomingValueForBlock(bb)); |
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.
Look at PHI value for the return code is clever. That may save us needing the metadata all together.
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.
It is restricted to the cases where the PHI values contain constants. It would be a lot more effort to untangle if they were other results.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
CI was messed up because of the recent issue with it, so I'm just running the pipelines because I'm curious what the tests look like right now. |
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.
Changes needed:
- The build recipe needs to be changed to build llvm11 for linux-aarch64 per Packaging issue caused due to llvm14 RuntimeDyLd issue on linux-aarch64 numba#8756
- Code changes in the tests are loosing the original intention. I've made suggestions to retain the original intention.
@@ -371,7 +371,7 @@ def test_fanout_1(self): | |||
self.assertEqual(stats.fanout, 3) | |||
|
|||
fanout_2 = r""" | |||
define void @main(i8* %ptr, i1 %cond) { | |||
define void @main(i8* %ptr, i1 %cond, i8** %excinfo) { |
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.
Is this needed? Fanout test shouldn't depend on excinfo.
ret i32 1 ; BAD; all tails are raising without decref | ||
bb_C: | ||
ret i32 1, !ret_is_raise !0 ; BAD; all tails are raising without decref | ||
ret i32 1 ; BAD; all tails are raising without decref |
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.
The original intention of the test is to verify that no pruning is done when all branches are raising. I'd suggest adding the store to excinfo for these branches so isRaising
will return True.
{% set sha256_llvm = "ce8508e318a01a63d4e8b3090ab2ded3c598a50258cc49e2625b9120d4c03ea5" %} | ||
{% set sha256_lld = "017a788cbe1ecc4a949abf10755870519086d058a2e99f438829aef24f0c66ce" %} | ||
{% set build_number = "5" %} | ||
{% set shortversion = "14.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.
We'll need split build for linux-aarch64 to use llvm11 as discussed in numba/numba#8756.
See
https://github.com/numba/llvmlite/pull/599/files#diff-a97126465bc884942a676793bbd8f9443dc410f5aa05c57d9bbf1d0ce5a6c437R2-R18 for reference.
NOTE: need to check if any documentation needs updating. |
# run the tests, skip some on linux-32 | ||
cd ../test | ||
if [[ $ARCH == 'i686' ]]; then | ||
../build/bin/llvm-lit -vv Transforms Analysis CodeGen/X86 | ||
else | ||
../build/bin/llvm-lit -vv Transforms ExecutionEngine Analysis CodeGen/X86 | ||
fi |
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.
What is the reason for removing these tests? If it's because they are in build.sh
perhaps they should be moved to run_test.sh
?
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.
We are having trouble getting any test to work. Deferring adding the test back to another PR given that this PR has passed buildfarm multiple times.
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.
Please could a new issue be opened to track this so it's visible as to what is failing/has been tried already. I also think it is ok on this occasion to defer this work to another patch given how many runs through the build farm this has had. Many thanks.
CC @apmasell.
As titled.
llvmlite/tests/test_refprune.py
Outdated
# Change in behaviour: ignore bad metadata | ||
self.assertEqual(stats.fanout_raise, 2) |
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.
The original intention is to check that pruning does not occur when there's a bad metadata; e.g. misspelled metadata name. See suggestion above.
Co-authored-by: Siu Kwan Lam <1929845+sklam@users.noreply.github.com>
Co-authored-by: Siu Kwan Lam <1929845+sklam@users.noreply.github.com>
Co-authored-by: Siu Kwan Lam <1929845+sklam@users.noreply.github.com>
The installation instructions need updating from here onward: llvmlite/docs/source/admin-guide/install.rst Line 178 in dffe582
suggest deferring this to a subsequent PR? |
CXX = clang++ -std=c++11 -stdlib=libc++ | ||
CXXFLAGS = $(LLVM_CXXFLAGS) | ||
CXX = clang++ | ||
CXXFLAGS = $(LLVM_CXXFLAGS) -O3 |
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.
@apmasell, is the -O3
needed?
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 am removing it in my PR
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.
Approving for merge.
Installation docs defer to separate PR
No description provided.