-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Mostly CUDA: Replace llvmpy API usage with llvmlite APIs #6813
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
Conversation
The llvmpy API exists only for compatibility; this commit replaces all uses of the llvmpy APIs with llvmlite IR builder API calls in the CUDA target. Notes: - Some of the functionality in the `llvmlite.llvmpy.core.Module` subclass of `llvmlite.ir.Module` has been moved into new functions in cgutils. - Because CUDA modules are now llvmlite.ir.Module instances, some of the core calls to `mod.get_or_insert_function` are replaced with calls to the new `cgutils` functions, as the CUDA modules also pass through these functions in the core.
f63cfa2 to
2f0af50
Compare
This required a few changes because llvmlite Modules don't have `get_global_variable_named()` and `add_function()` methods.
|
@gmarkall thanks for the patch, please could you resolve the conflict against mainline, many thanks! |
|
@stuartarchibald Conflicts resolved! |
Many thanks! |
stuartarchibald
left a comment
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.
Thanks for doing this refactoring. The addition of the few functions to cgutils helps a lot with reducing usage of methods on the module itself. Couple of minor comments else looks good to go. Thanks again!
|
|
||
| if dynamic_smem: | ||
| gvmem.linkage = lc.LINKAGE_EXTERNAL | ||
| gvmem.linkage = 'external' |
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.
Wonder if the enum in llvmlite ought to be moved out of llvmpy and into the llvmlite API such that reliance on strings is reduced? (Not for this 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.
Maybe... I assumed that the use of strings instead of the enum was a deliberate design decision to permit flexibility in the linkage types for the user of llvmlite, but it's probably flexibility that's turned out to be un-needed (unless it's being used by external non-Numba users).
Co-authored-by: stuartarchibald <stuartarchibald@users.noreply.github.com>
stuartarchibald
left a comment
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.
Thanks for the patch and fixes.
|
Buildfarm ID: |
|
This one fails on CUDA 9.0 and 10.0 tests with: |
|
@gmarkall thanks for the fixes, |
|
@esc many thanks! |
stuartarchibald
left a comment
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.
Thanks for the fix, looks good.
This PR replaces all llvmpy API usage with llvmlite API usage in the CUDA target. I started this replacement work because I often want to do something based on existing code in the CUDA target, but I'm loathe to add new code using the compatibility layer, so I felt it would be better to make the entire CUDA target an exemplar of the right API. This spidered out of just the CUDA target because a lot of code is shared between the core and the CUDA target, so the changes are:
Moduleclass with the llvmliteModuleclass. I started by replacing only CUDA target modules with the llvmliteModuleclass, but since it passes through the core so much, with the possibility of a lack of test coverage for some basic functionality (simple mathematical operators, etc, might not be explicitly tested by the CUDA target, with the assumption that simple nopython mode things generally work) I thought the safest route was to make sure that no target uses an llvmpyModule.cgutilsnow has some extra methods to replace functionality that was in the llvmpyModuleclass - these functions are now called where the oldModulemethod was used. I didn't replaceget_global_variable_named()with anything incgutilsbecause it was used exactly once.I'm marking this as medium effort because although it's quite a long PR, the majority of it is very mechanical substitutions.