-
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
Update llvmlite to be compatible with llvm-17 #1042
base: main
Are you sure you want to change the base?
Conversation
ffi/transforms.cpp
Outdated
LLVMFunctionAnalysisManager FAM, LLVMCGSCCAnalysisManager CGAM, | ||
LLVMPassInstrumentationCallbacks PIC) { | ||
// TODO handle PB memory better | ||
if (PB) |
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 is here because the PipelineTuningOptions cannot currently be updated after creation of a PassBuilder. I'm planning on floating the idea to LLVM upstream of allowing this change so we don't have to do this stuff
Thanks for the PR @modiking - I was hoping to provide some timely feedback on your PR I'm out on PTO for the rest of the week - I'll follow up next week. |
Hi @modiking - I'm looking at this a bit today - I have a couple of clarifying questions:
|
I haven't tested this against Numba yet. I wanted to make sure we were on the same page on how we hook up custom passes before doing more. Are there docs on how to test it? Also for our internal use case of Numba I suspect we'll upgrade this in tandem with whatever the latest release is given this is a more or less a "breaking" change on some level.
Internally I believe we are. However part of the reason we're investing in the upgrade is that figuring out the answer to that question is quite difficult.
I believe the RISC-V tests are running with my build, I'll double check. I've currently working on getting the SVML patches upgraded and testing that scenario. |
You were right that the RISCV tests were not running. Building LLVM against all targets showed the register allocation changed but the instruction sequences are still the same so updated the tests:
|
I would be interested in helping/leaning on this but... I forked @modiking's fork (here) $ git log | head -n1
commit 6009708b4367171ccdbf4b5905cb6a803753fe18
$ export LLVM_CONFIG=$PWD/build-rel-static/bin/llvm-config && cd ../llvmlite
$ git branch -v
main 622c33f Merge pull request #1025 from dlee992/skip_if_meet_raise_bb
* modiking/llvm17 4907a4e [behind 4] Format
$ git log | head -n1
commit 4907a4eee128ae5d95eddbd0ce4aeaa83bab4787
$ python --version
Python 3.9.19 Then just blind
because libffi keeps those things in
which turns out to be due to the fact that
I'll keep "following my nose" (i.e., patching stuff willy-nilly) but I'm just kind of surprised/confused about how you were able to successfully build @modiking |
Hi @makslevental, thanks for taking a look! I took a look and there’s a simple and dumb answer to this: I forgot to add the new file “ffi_types.h” to git 🤦♂️ |
I'm also seeing that:
Fails with SEGFAULT on first run but then subsequently succeeds. I suspect there's some memory management issue happening with the sub-optimal way I'm dealing with the I'm on PTO till next Monday but when I get back I'll track this down so we're not blocked on any future LLVM patch. I also see the build issue with the CI where |
@modiking SGTM. Also (if you're up for it) when you get back from PTO we should sync up and maybe colab - my goal is to bump all the way to TOM LLVM. |
Hello everybody, I am super interested in this fix as well since I am building a code which requires LLVM17 and cannot use LLVM14. |
@modiking Thanks for your efforts so far here, and apologies for the delay in getting back to looking at this. I appreciate the time and effort you've taken to fully map out a way towards getting llvmlite to LLVM 17. For us to be able to move forward in the context of Numba + llvmlite, we need to do things a bit more piecewise than advancing everything forward to LLVM 17 in one go, because getting to LLVM 17 with Numba would mean making sure it all works with the new pass manager, opaque pointers, and any other API changes that I don't yet know about, and having enough time to catch any issues that result from that migration (particularly through having it working in Numba in CI for a while). With that in mind, the first thing I think we need to do is to have separate APIs for the new and legacy pass managers, allowing Numba to have code to use one or the other and a config flag to switch between the two. My understanding of the changes in this PR is that it retains the existing interface, but with the new pass manager. In a separate PR from @yashssh (#1046), there is the other approach where the old and new pass managers are used with separate APIs. That doesn't yet do anything about the refprune pass though, and it looks like you've already worked out updating it for the new pass manager. I was able to make some minimal changes to Numba to test it with the new pass manager in PR #1046, but without the refcount pruning pass. With those points in mind, for us to progress forward, is it possible for you to:
please? How does this sound? |
It looks like there's enough parties here that it would be good to align on all our goals and figure out what's the best way forward. There's Numba office hours next Tuesday at 8:30 AM PST (https://calendar.google.com/calendar/embed?src=5rqnddm4gjrdfjm31fsv182epk%40group.calendar.google.com) that seems like a good time to meet up. We'll also get more Numba perspective on how we want to proceed. |
True, this does require extensive testing and validation.
Can you elaborate more on the advantages of doing it this way? Anything that uses llvmlite needs to be atomically on one pass manager or the other so having NPM be an option requires full correctness.
My plan is to test Numba as well once this change is functionally complete. Definitely do not want to push 2 separate solutions to the same problem though. I suggested earlier to meet up at the next Numba office hours to discuss this-how about we discuss it in more detail then? |
My concern is that between the old and new pass managers we'll see some change in optimization behaviour for certain cases, which some Numba users are sensitive to - there's not a single place I can point to that lays it out clearly, but some past and recent discussions around this area are:
I'd envision the way forward is that Numba could be atomically switched between the old and new pass managers, via a configuration variable. Initially I think we'd use the old pass manager by default, but probably test with the new pass manager enabled in CI. Then switch over to the new pass manager being default once we feel comfortable that most issues are worked out. If someone's use case is negatively affected by the new pass manager, then they can switch back to the old one with the configuration variable. If we only have the new pass manager and "flip the switch" in one go, I don't think we'll have a way to address individual cases, other than attempting to fix them with the way we use the new pass manager for a subsequent release. Because Numba releases are not on a frequent cadence, and our resources to look into a particular issue could be limited at any given time, this might not be a straightforward experience either for Numba users or us as the maintainers.
A general question about getting Numba to the point where it can be tested with this branch - is there a quick solution for Numba's assumption that pointers are typed, thus that you can get the type and size of the pointee, or would there be a lot of code changes needed in Numba to switch over to opaque pointers and run with the LLVM 17 branch?
Sure, I'd be happy to discuss this in the next office hours as well - note that this week the office hours are the EU version, which are at 12pm GMT (1pm BST, 2pm CET) which I think is 5am in PST, so we could also do this the following week's office hours if that works better? |
Sorry I missed this. I'm going to drop in today (in about 30) and ask around. Otherwise we can plan for next week or we can coordinate a sideband convo over email or something. FYI I generally hang out on the LLVM discord https://discord.gg/fKKqJ9sn (under the same handle). |
As a Numba user, I do like the feature But right now, I believe numba has many code locations using |
I should think it would make it easier to work on these parts more efficiently.
Maybe... I hope it won't be too long before we find out - Modi's discussion in the open meeting sounded encouraging, but we'll have to see what fails when we make the changes too. |
Based on the changes introduced in numba#1042 by @modiking
Based on the changes introduced in numba#1042 by @modiking
Based on the changes introduced in numba#1042 by @modiking
Based on the changes introduced in numba#1042 by @modiking
TODO:
High-level details:
global_value_type
which looks at the value rather than the pointer