Skip to content
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 IR layer typed pointers mode #1159

Merged
merged 11 commits into from
Mar 4, 2025
Merged

Conversation

rj-jesus
Copy link
Contributor

This patch adds preliminary support for a "lazy opaque pointers" option whereby we emit IR with typed pointers if pointee types are known (even if opaque pointers are enabled). This makes numba-cuda work with opaque pointers enabled and should unblock #1082.

I've enabled opaque pointers unconditionally and made lazy opaque pointers on by default to facilitate testing. These changes could (should?) be moved to a separate PR if required.

@@ -190,17 +186,6 @@ def gep(self, i):
def intrinsic_name(self):
return 'p%d%s' % (self.addrspace, self.pointee.intrinsic_name)

@classmethod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added by @sklam in #1051. I think there's no way this can survive the transition to opaque pointers anyway (and the fact it doesn't seem to have an effect on tests is also somewhat reassuring), but I want to check if @sklam has any thoughts here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The opaque pointer version of this shouldn't be affected by this patch (which is why the tests aren't affected either).
I think the typed version can't survive, but my understanding from #1064 (comment) was that this was okay.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok to remove.

Copy link
Member

@gmarkall gmarkall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @rj-jesus !

I think the general idea is good and I'd be keen to press on with it. I'd hope our strategy would be something like:

  • Merge this PR
  • Get comfortable that nothing Numba-related is broken by it
  • Bump the minimum LLVM version to 16 (because it already builds with it anyway, this should be a simple bump)
  • Remove the references to typed pointers in the binding layer to clean things up a bit
  • Move to later LLVM versions at our convenience

The only idea I'd like to float is WRT naming - we have "opaque pointers" and "lazy opaque pointers" which on the face of it don't have much specific meaning. I'd like to propose that:

  • What we're adding here is called "IR layer typed pointers" (or "IR layer opaque pointers", with the required inversion of boolean conditions)
  • What is enabled by the _opaque_pointers_enabled() function is called "Binding layer opaque pointers"

I think this naming makes it a bit clearer where the effects and differences lie in terms of the abstractions presented by llvmlite. I would be keen to hear the perspective of @sklam and @stuartarchibald here too though.

@rj-jesus
Copy link
Contributor Author

Hi @gmarkall, thanks very much for the feedback!

Your strategy sounds very good to me.

On the naming issue, I'm more than happy to rename "lazy opaque pointers" to "IR layer opaque pointers" or something else entirely, "lazy opaque pointers" was just a work-in-progress name in any case! As far as the normal "opaque pointer mode" goes, while I'm also very happy to rename it, I think maybe we should just remove it entirely. It won't be an option per se going forward as there will be no alternative, and it was only introduced in the first place as a stop-gap solution to enable testing and porting. We've had it for a release cycle, which I believe was the initial plan. What do you think?

rj-jesus and others added 2 commits February 19, 2025 14:48
Co-authored-by: Graham Markall <[email protected]>
Co-authored-by: Graham Markall <[email protected]>
@gmarkall
Copy link
Member

As far as the normal "opaque pointer mode" goes, while I'm also very happy to rename it, I think maybe we should just remove it entirely. It won't be an option per se going forward as there will be no alternative, and it was only introduced in the first place as a stop-gap solution to enable testing and porting. We've had it for a release cycle, which I believe was the initial plan. What do you think?

I think this is a good idea, and it would save an iteration compared to my original plan - I prefer what you suggest instead.

@gmarkall
Copy link
Member

On the naming issue, I'm more than happy to rename "lazy opaque pointers" to "IR layer opaque pointers" or something else entirely, "lazy opaque pointers" was just a work-in-progress name in any case!

Thanks... Will wait and see what others think of the naming.

rj-jesus added a commit to rj-jesus/llvmlite that referenced this pull request Feb 20, 2025
At the LLVM level, typed pointers are no longer supported going forward.

This ticket removes typed pointer support at the LLVM binding layer and
bumps the LLVM release used to LLVM 16.

This builds on top of numba#1159.
@rj-jesus rj-jesus changed the title Add lazy opaque pointers mode Add IR layer typed pointers mode Feb 20, 2025
@rj-jesus
Copy link
Contributor Author

Hi @gmarkall, as discussed I've raised #1160 to drop the old "binding layer" opaque pointers mode (and bump the LLVM release supported to 16), and I've also just committed the rename "lazy opaque pointers" to "IR layer typed pointers" you had suggested. Can you think of anything else we should be doing?

@gmarkall
Copy link
Member

Can you think of anything else we should be doing?

Not at this point - thanks for the updates!

@gmarkall
Copy link
Member

From triage meeting - I'll continue to review this until it's RTM.

gmarkall
gmarkall previously approved these changes Feb 28, 2025
Copy link
Member

@gmarkall gmarkall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code changes look good to me, so I'm approving this.

However, there are updates needed for the docs, examples, and test scripts, which I'll push after approving for @rj-jesus to review (and CI to test 🙂).

Copy link
Contributor Author

@rj-jesus rj-jesus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for these changes @gmarkall! Everything looks good, I just left a few comments about some of the phrasing, but nothing special.

I can't approve this explicitly, but this generally looks good to me.

@gmarkall
Copy link
Member

gmarkall commented Mar 4, 2025

Thanks for the review @rj-jesus - I think your comments all make sense, so I've aimed to address / follow them - let me know what you think.

Copy link
Contributor Author

@rj-jesus rj-jesus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the changes, @gmarkall! I think it's looking really good, I think the distinction between Typed and Opaque Pointers is clear now.

I can't formally approve the review, but please consider it approved.

@sklam sklam merged commit 2677283 into numba:main Mar 4, 2025
26 checks passed
@sklam sklam added this to the v0.45.0 milestone Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants