Repository navigation
Offload: support launch in lib - #166576
Open
kjetilkjeka wants to merge 2 commits into
Open
kjetilkjeka wants to merge 2 commits into
kjetilkjeka wants to merge 2 commits into
Conversation
- Makes it possible to pass `-Zoffload=Host` without path, we don't embed device code in host libs - Don't require `lto=fat` when building rlibs
- Host emits offload manifest in out-dir - Separate DeviceImage flag when the device image should be embedded - No need for Test flag due to the more modular system
kjetilkjeka
force-pushed
the
offload-launch-in-lib
branch
from
November 26, 2026 07:59
16abe35 to
552ea74
Compare
kjetilkjeka
marked this pull request as ready for review
November 26, 2026 08:04
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This solves another one of the blockers for using offload kernels (tracking issue #131513) with cargo dependencies. This makes it possible to launch kernels from dependencies. The test shows that the kernels are generated in the appropriate device compilations. My local tests also include linking by running on my cargo fork with offload support and it links and runs correctly.
This does not change anything related to the crate loading limitation
The first part of allowing to launch kernels in a lib is to call
-Zoffload=Hostwithout providing a device image when building an rlib. The device part of the library is not bundled into the host .rlib, they're instead kept separate until linking. With these changes we don't even need to have the device image when building for Host, and since the normal Host stage now also produce the offload manifest we don't need to run the-Zoffload=HostMetadataat all if we compile device after host when not linking.The second part is not requiring
-Clto=fatwhen building an .rlib. Cargo doesn't pass it to rustc when building an .rlib and doing so wouldn't make much sense (it's called link-time for a reason). This PR makes the change to only require it when there's anything else than an .rlib being produced.There's also a change here that is not strictly required. Instead of allowing to pass
-Zoffload=Hostwith an optional path I instead added the-Zoffload=DeviceImage=<path>that must be used when linking. This is to make the two things (1. is this an offload host compile, and 2. does this invocation include linking) additive instead of having to change aHostto aHost=<path>. The name is also a bit more self-documenting. I believe it to be a positive UI change, but it's easy to get rid of if it's not welcome.To make the UI even cleaner and close to what cargo already deals with there's a follow up Draft MR (#166585). That one adds the offload manifest in an
--emitso the names needs some extra scrutiny and an MCP.@rustbot label +F-gpu_offload
r? @ZuseZ4