-
Notifications
You must be signed in to change notification settings - Fork 15
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
Numba patch: Enable LTOIR to be linked from memory instead of files #72
Numba patch: Enable LTOIR to be linked from memory instead of files #72
Conversation
/ok to test |
2b56226
to
440f99a
Compare
/ok to test |
@nvlcambier there's a style failure (single -> double quotes) |
Yes I'm waiting for the CI to finish and I'll fix all problems. |
440f99a
to
90c2d77
Compare
90c2d77
to
4ef47fb
Compare
/ok to test |
Looks like the copyright range at the top of the file needs a bump |
It would be nice to add a unittest in |
/ok to test |
/ok to test |
Looks like there's an error:
It seems like the ltoir generated by |
Test seems fine. The LTO-IR is built correctly AFAICT. Will try to figure out what's going wrong. EDIT: the LTO-IR isn't build correctly. |
nvcc cannot produce .ltoir out of the box. The file being used for testign is actually an object file. We can use `--keep` to produce .ltoir. However in that case, in addition, we would need to set `lto=True` in the linker creation. This reverts commit 08bb96f.
This reverts commit b6aaafd.
…ectly produce ltoir (should use nvcc -keep)
da13adb
to
161923a
Compare
/ok to test |
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.
Many thanks, this looks good. Linking LTOIR from memory does work once I added code to patch the linker for LTO, which I will add in a subsequent PR.
#72 added support for linking LTO-IR files from memory instead of disk. However, it could not be tested because: - We had no way to generate an LTO-IR container for the test input - NVCC doesn't support emitting an LTO-IR container, only an LTO-IR wrapped in a fatbin wrapped in a host object. - The Numba patch needs to patch Numba for LTO for linking LTO-IR to work. This PR implements both of the above, with these changes: - Addition of a new test binary generator, `generate_raw_ltoir.py`. This uses NVRTC to generate an LTO-IR container. It uses the cuda-python bindings, so `cuda-python` is added to the test environments. - The fixtures had ended up with some duplication and inconsistency between `conftest.py` and other test files, so these are deduplicated, and now kept in `conftest.py`. Appropriate updates to all tests using the fixtures are made. - The `lto` kwarg is added to the `patch_numba_linker()` function. It is disabled by default, as enabling LTO will not presently work in all use cases. - Added a test for linking LTO-IR from memory.
This PR adds support for linking LTO-IR code from memory in the Numba monkey patch.
This is done by creating a new class
LTOIR
withkind = 'ltoir'
.Passing an instance of
LTOIR
tonumba.cuda.jit(link=...)
will enable linking directly from memory, bypassing the need to write the file to disk with an.ltoir
extension.cc @gmarkall @leofang