feat(cuda.core): support nvJitLink incremental linking - #2867
Conversation
| link_time_optimization : bool, optional | ||
| Perform link time optimization. | ||
| Default: False. | ||
| relocatable : bool, optional |
There was a problem hiding this comment.
Q: Maybe we should call it relocatable_device_code to match what we have in ProgramOptions? Seems like they have the same semantics?
There was a problem hiding this comment.
The design doc notes the distinction:
ProgramOptions.relocatable_device_codeand the proposedLinkerOptions.relocatableare also distinct:
- The program option makes a compilation unit suitable for device linking.
- The linker option permits a link result to remain relocatable and to retain unresolved device references.
There was a problem hiding this comment.
I sort of think relocatable_device_code and relocatable are respectively different notions created one on the nvrtc and nvjitlink side. My prior discussion with folks suggests rdc is quite commonly used as a shorthand to refer to the nvrtc behavior. Coercing the linker side to overlap this terminology could introduce some confusion in the future.
There was a problem hiding this comment.
I think I was confused for a moment when reading even relocatable_device_code and relocatable 😂
There was a problem hiding this comment.
@isVoid good idea, but maybe we should rename it for clarity? Such as incremental_link?
There was a problem hiding this comment.
+1. Like incremental_link
Maybe the page didn't refresh when you reply, see #2867 (comment). Do you have specific preference on incremental_link over incremental? @lijinf2
There was a problem hiding this comment.
Yes I think page did not refresh on my side. incremental looks good too!
There was a problem hiding this comment.
Don't the driver docs prefer the term "relative" over "incremental" though? Diverging from that could be confusing in a different way.
There was a problem hiding this comment.
Don't the driver docs prefer the term "relative" over "incremental" though? Diverging from that could be confusing in a different way.
I can see the term relocatable is used across the board to refer specifically to the output of the linker with -r or compiler with -rdc. But when referring to the -r flag, the nvjitlink do mention both terms, and actually in some sense highlighting the incremental to emphasize the linker behavior.
Andy-Jost
left a comment
There was a problem hiding this comment.
One blocker: link("ltoir") silently drops inputs that carry no LTOIR (details inline, with a repro). Two untested rows of the design matrix, and a few small cleanups. The relocatable and LTOIR round trips themselves look right.
| link_time_optimization : bool, optional | ||
| Perform link time optimization. | ||
| Default: False. | ||
| relocatable : bool, optional |
There was a problem hiding this comment.
The design doc notes the distinction:
ProgramOptions.relocatable_device_codeand the proposedLinkerOptions.relocatableare also distinct:
- The program option makes a compilation unit suitable for device linking.
- The linker option permits a link result to remain relocatable and to retain unresolved device references.
There was a problem hiding this comment.
Nice. Let me write down my understanding. Before this PR, application code had to gather all compiled device inputs (PTX/LTOIR/cubin) before invoking a single Linker. After this PR, application code can do cascading linking — each stage produces a partial result that feeds directly into the next Linker.
| link_time_optimization : bool, optional | ||
| Perform link time optimization. | ||
| Default: False. | ||
| relocatable : bool, optional |
There was a problem hiding this comment.
I think I was confused for a moment when reading even relocatable_device_code and relocatable 😂
|
Left a question here: #2867 (comment) |
|
/ok to test 3cc270d |
lijinf2
left a comment
There was a problem hiding this comment.
My comments all addressed. Thanks. PR looks good to me!
This comment has been minimized.
This comment has been minimized.
|
/ok to test fc8c850 |
|
Summary
LinkerOptions(incremental=True), gated on nvJitLink 13.2+ObjectCode(code_type="cubin")so they round-trip directly into anotherLinkerLinker.link("ltoir")on nvJitLink 13.3+ so incremental LTO chains can retain IR until final code generationcode_type="object"means a host object containing device codeDesign choices
"cubin"; ELFET_RELdescribes link state, not a distinct cuda.core transport format.target_typeaccepts"cubin", or"ltoir"when LTO is enabled and the getter is available."ptx"is rejected.Linker."ltoir"; requesting"cubin"creates a machine-code boundary that later LTO cannot optimize through.Testing
Closes #2369