Skip to content

Conversation

@ZuseZ4
Copy link
Member

@ZuseZ4 ZuseZ4 commented Nov 21, 2025

Automates step 1 from the rustc-dev-guide offload section:
https://rustc-dev-guide.rust-lang.org/offload/usage.html#compile-instructions
"clang-offload-packager" "-o" "host.out" "--image=file=device.bc,triple=amdgcn-amd-amdhsa,arch=gfx90a,kind=openmp"

Verified on an MI 250X

cc @jhuber6, @kevinsala, @jdoerfert, @Sa4dUs

r? oli-obk

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 21, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@ZuseZ4 ZuseZ4 force-pushed the automate-offload-packager branch from 2a3a561 to 80e8fce Compare November 21, 2025 09:49
@rustbot rustbot added the A-rustc-dev-guide Area: rustc-dev-guide label Nov 21, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 21, 2025

oli-obk is not on the review rotation at the moment.
They may take a while to respond.

@ZuseZ4 ZuseZ4 marked this pull request as ready for review November 21, 2025 09:49
@rustbot
Copy link
Collaborator

rustbot commented Nov 21, 2025

The rustc-dev-guide subtree was changed. If this PR only touches the dev guide consider submitting a PR directly to rust-lang/rustc-dev-guide otherwise thank you for updating the dev guide with your changes.

cc @BoxyUwU, @jieyouxu, @Kobzol, @tshepang

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 21, 2025
@rust-log-analyzer

This comment has been minimized.

@ZuseZ4 ZuseZ4 force-pushed the automate-offload-packager branch 3 times, most recently from 95a0037 to 519499d Compare November 21, 2025 10:16
@ZuseZ4 ZuseZ4 force-pushed the automate-offload-packager branch from 519499d to 88ca3bc Compare November 21, 2025 10:41
OS1.flush();
auto MB = llvm::MemoryBuffer::getMemBufferCopy(Storage, "module.bc");

SmallVector<char, 1024> BinaryData;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This buffer could be an argument provided by rustc and then rustc can do the file writing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is, that the C++ version is resizable. If we provide a buffer from rust, it wouldn't be.
I asked and there is no reasonable default size, so we'd pass a (likely) too-small buffer in, set the needed length and return false, see that in rust, allocate a larger buffer with the requested size, call the method again, and hope that it now passes.
It's just 3 lines extra on the Rust side, and I don't expect it to become a compile-time bottleneck, since no one (famous last words) will compile >10k kernels, but it still feels ugly.

Copy link
Member Author

@ZuseZ4 ZuseZ4 Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked deeper into the next steps, and I think it's probably not worth cleaning up this write, since it will be fused with the next step, where we consume the in-memory host.out file.

I'll implement a save-temps equivalent later for debugging where we'll still write it out, but then we can handle all intermediate writes at once.
Similar to my offload frontend, which Marcello also just rewrote after we figured out, what we actually need.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wip #149202

@oli-obk
Copy link
Contributor

oli-obk commented Nov 22, 2025

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Nov 22, 2025

📌 Commit 88ca3bc has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 22, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 22, 2025
…r=oli-obk

automate gpu offloading - part 1

Automates step 1 from the rustc-dev-guide offload section:
https://rustc-dev-guide.rust-lang.org/offload/usage.html#compile-instructions
`"clang-offload-packager" "-o" "host.out" "--image=file=device.bc,triple=amdgcn-amd-amdhsa,arch=gfx90a,kind=openmp"`

Verified on an MI 250X

cc `@jhuber6,` `@kevinsala,` `@jdoerfert,` `@Sa4dUs`

r? oli-obk
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 22, 2025
…r=oli-obk

automate gpu offloading - part 1

Automates step 1 from the rustc-dev-guide offload section:
https://rustc-dev-guide.rust-lang.org/offload/usage.html#compile-instructions
`"clang-offload-packager" "-o" "host.out" "--image=file=device.bc,triple=amdgcn-amd-amdhsa,arch=gfx90a,kind=openmp"`

Verified on an MI 250X

cc ``@jhuber6,`` ``@kevinsala,`` ``@jdoerfert,`` ``@Sa4dUs``

r? oli-obk
bors added a commit that referenced this pull request Nov 22, 2025
Rollup of 8 pull requests

Successful merges:

 - #147536 (Add `rust-mingw` component for `*-windows-gnullvm` hosts)
 - #148407 (Warn against calls which mutate an interior mutable `const`-item)
 - #149168 (Fix ICE when collecting opaques from trait method declarations)
 - #149170 (automate gpu offloading - part 1)
 - #149180 (Couple of refactors to SharedEmitter)
 - #149185 (Handle cycles when checking impl candidates for `doc(hidden)`)
 - #149194 (Move safe computation out of unsafe block)
 - #149204 (Fix typo in HashMap performance comment)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 22, 2025
…r=oli-obk

automate gpu offloading - part 1

Automates step 1 from the rustc-dev-guide offload section:
https://rustc-dev-guide.rust-lang.org/offload/usage.html#compile-instructions
`"clang-offload-packager" "-o" "host.out" "--image=file=device.bc,triple=amdgcn-amd-amdhsa,arch=gfx90a,kind=openmp"`

Verified on an MI 250X

cc ```@jhuber6,``` ```@kevinsala,``` ```@jdoerfert,``` ```@Sa4dUs```

r? oli-obk
bors added a commit that referenced this pull request Nov 22, 2025
Rollup of 7 pull requests

Successful merges:

 - #147536 (Add `rust-mingw` component for `*-windows-gnullvm` hosts)
 - #148407 (Warn against calls which mutate an interior mutable `const`-item)
 - #149168 (Fix ICE when collecting opaques from trait method declarations)
 - #149170 (automate gpu offloading - part 1)
 - #149185 (Handle cycles when checking impl candidates for `doc(hidden)`)
 - #149194 (Move safe computation out of unsafe block)
 - #149204 (Fix typo in HashMap performance comment)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 22, 2025
…r=oli-obk

automate gpu offloading - part 1

Automates step 1 from the rustc-dev-guide offload section:
https://rustc-dev-guide.rust-lang.org/offload/usage.html#compile-instructions
`"clang-offload-packager" "-o" "host.out" "--image=file=device.bc,triple=amdgcn-amd-amdhsa,arch=gfx90a,kind=openmp"`

Verified on an MI 250X

cc ````@jhuber6,```` ````@kevinsala,```` ````@jdoerfert,```` ````@Sa4dUs````

r? oli-obk
@matthiaskrgr
Copy link
Member

@bors2 try jobs=dist-ohos-aarch64

rust-bors bot added a commit that referenced this pull request Nov 22, 2025
automate gpu offloading - part 1

try-job: dist-ohos-aarch64
@rust-bors
Copy link

rust-bors bot commented Nov 22, 2025

⌛ Trying commit 88ca3bc with merge a278658

To cancel the try build, run the command @bors try cancel.

Workflow: https://github.com/rust-lang/rust/actions/runs/19599008472

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-rustc-dev-guide Area: rustc-dev-guide S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants