-
Notifications
You must be signed in to change notification settings - Fork 185
Use C linkage for JIT LTO kernels #1909
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
Merged
rapids-bot
merged 7 commits into
rapidsai:release/26.04
from
divyegala:jit-lto-c-linkage
Mar 16, 2026
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8b5d1f7
introduce c linkage
divyegala f1c4cee
Use same symbol name in each fragment
KyleFromNVIDIA 3722008
Make cache private
KyleFromNVIDIA aab1d74
Pass strings by value
KyleFromNVIDIA 01e06a5
s/fragment/kernel/
KyleFromNVIDIA de61748
Remove extra newline
KyleFromNVIDIA 50a83f8
Make fragment database .cpp instead of .cu
KyleFromNVIDIA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,21 +6,13 @@ | |
| // This file is auto-generated. Do not edit manually. | ||
|
|
||
| #include <cuvs/detail/jit_lto/RegisterKernelFragment.hpp> | ||
| #include <cuvs/detail/jit_lto/ivf_flat/interleaved_scan_tags.hpp> | ||
| #include "@embedded_header_file@" | ||
|
|
||
| using namespace cuvs::neighbors::ivf_flat::detail; | ||
|
|
||
| namespace { | ||
|
|
||
| __attribute__((__constructor__)) void register_kernel() | ||
| { | ||
| registerAlgorithm<tag_@type_abbrev@, | ||
| tag_acc_@acc_abbrev@, | ||
| tag_idx_@idx_abbrev@>( | ||
| "interleaved_scan_kernel_capacity_@capacity@_veclen_@veclen@_@ascending_descending@_@compute_norm_name@", | ||
| embedded_fatbin, | ||
| sizeof(embedded_fatbin)); | ||
| registerAlgorithm("@kernel_name@", embedded_fatbin, sizeof(embedded_fatbin)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One thing to note is that the |
||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 fragment key is now assembled in C++ from
tag_abbrev<>, while the generated embedded file key comes fromCMake/JSONvia@kernel_name@, no?If so, that'd mean the planner side and generator side must stay perfectly synchronized across:
If any one of those drifts, the failure mode might be late and opaque.
I’d strongly suggest either deriving both names from one source, or adding a smoke test that exercises one generated interleaved scan kernel through the full registration
cudaLibraryGetKernelpath.This is not a blocking comment, if I'm correct then this can be addressed as a follow up, so would just request to open an issue to track.
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 don't know if it's possible to derive those from one source. CMake
NAME_FORMATis done at configure/build time, while the C++ implementation is done at runtime.The way we're doing things here is not new, and any time the naming conventions have drifted, it's failed very loudly due to failure of either nvjitlink or the fragment database to find the appropriate fragment.
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 could inject at least the string of
NAME_FORMATwith placeholders to thePlannerclass so at runtime, instead of constructing the string piece-by-piece, developers can just substitute the placeholder?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.
Wouldn't we then have to generate a whole matrix of files that instantiate
Plannerfor each possible combination?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 wouldn't substitute the real types/values at build time. Just the string with placeholders for the types/values so the developers don't have to know how to construct and match the string.
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.
How would that work? There are hundreds of possible strings. How do you substitute in
@kernel_name@without generating another matrix of hundreds of files?Uh oh!
There was an error while loading. Please reload this page.
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.
Oh, I see. You're thinking of having it look like:
and then doing the substitution of
@param1@and@param2@at runtime.Yes, that's a good idea. We should do that in a follow-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.
Yes that's exactly what I was thinking. Follow-up is perfect 👍 will merge this PR now