Skip to content

Rollup of 11 pull requests #142781

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

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
9aa572d
use consistent title capitalization
tshepang May 22, 2025
a4c8ef9
Adjust some doc for Query System
xizheyin Jun 13, 2025
067a99b
install docs for each target in different directory
Forist2034 Jun 13, 2025
94d56d1
Merge pull request #2441 from rust-lang/tshepang-remove-title-case
tshepang Jun 14, 2025
9265493
Merge pull request #2465 from xizheyin/rustc-query
tshepang Jun 14, 2025
a70deb6
content has moved to another chapter
tshepang Jun 14, 2025
9926215
Merge pull request #2466 from rust-lang/tshepang-moved
tshepang Jun 14, 2025
0834e48
use sentence case
tshepang Jun 14, 2025
a3f261c
Merge pull request #2467 from rust-lang/tshepang-patch-1
tshepang Jun 14, 2025
820e88a
title case
tshepang Jun 14, 2025
21a1e51
do not inline links
tshepang Jun 14, 2025
d16e1a1
Merge pull request #2468 from rust-lang/query-cleaning
tshepang Jun 14, 2025
808d16c
Use stage 1 for building docs
Darksonn Jun 16, 2025
3edb332
Merge pull request #2471 from Darksonn/patch-1
Noratrieb Jun 16, 2025
1dbf86a
Remove hanging parenthesis from example signature.
cbloodsworth Jun 16, 2025
02334e1
Merge pull request #2472 from cbloodsworth/fix/tytable_parens
BoxyUwU Jun 16, 2025
8bc55da
Profiling with perf: specify the section of bootstrap settings.
lolbinarycat Jun 17, 2025
671817f
Merge pull request #2475 from lolbinarycat/patch-3
Noratrieb Jun 17, 2025
d96b2d4
Stub chapter and consolidate under `/hir/`
BoxyUwU Jun 6, 2025
42888bb
Write chapter on Unambig vs Ambig Types/Consts
BoxyUwU Jun 17, 2025
c1506c0
Add links
BoxyUwU Jun 17, 2025
39e9800
Reviews
BoxyUwU Jun 18, 2025
6c7830e
Merge pull request #2474 from BoxyUwU/ambig_unambig_ty_consts
BoxyUwU Jun 18, 2025
4145596
fix markup
tshepang Jun 18, 2025
79652d9
Merge pull request #2476 from rust-lang/tshepang-patch-1
tshepang Jun 18, 2025
0a185e4
initial instructions for gpu offload
ZuseZ4 Jun 2, 2025
f25cfe8
Merge pull request #2447 from rust-lang/offload-docs
ZuseZ4 Jun 19, 2025
48b36ee
Preparing for merge from rustc
invalid-email-address Jun 19, 2025
d854d56
Merge from rustc
invalid-email-address Jun 19, 2025
8c28161
Add `get_host_target` function
Kobzol Jun 17, 2025
21d21d5
Normalize host target in snapshot tests
Kobzol Jun 17, 2025
718e475
Clarify arrow in snapshot tests
Kobzol Jun 18, 2025
eefd598
correct template for `#[align]`
folkertdev Jun 19, 2025
aca0688
De-dup common code from `ExternalCrate` methods
yotamofek Jun 19, 2025
6ad42bf
Merge pull request #2477 from rust-lang/rustc-pull
tshepang Jun 19, 2025
dfaa622
add issue template for rustdoc
lolbinarycat Jun 19, 2025
240dc05
Add a mailmap entry for y21
tgross35 Jun 19, 2025
fca6e81
Make sure to rebuild rustdoc if `src/rustdoc-json-types` is changed
jieyouxu Jun 19, 2025
42b0201
Fix `tests/ui/asm/naked-invalid-attr.stderr`.
nnethercote May 27, 2025
4a1f445
Use a symbol for `ExpansionConfig::crate_name`.
nnethercote May 29, 2025
1edf201
Avoid some unnecessary symbol interning.
nnethercote May 29, 2025
b95d39d
Remove an unnecessary check in rustfmt.
nnethercote May 27, 2025
75bcc9c
remove equivalent new method on context
jdonszelmann Jun 19, 2025
d475e10
Add temporary directory for executing snapshot tests
Kobzol Jun 20, 2025
88f1ed4
Convert `ilog(10)` to `ilog10()`
ChaiTRex Jun 20, 2025
aae966e
Rollup merge of #142478 - Forist2034:master, r=clubby789
Kobzol Jun 20, 2025
044b499
Rollup merge of #142629 - Kobzol:bootstrap-tests-builder, r=jieyouxu
Kobzol Jun 20, 2025
480ea7e
Rollup merge of #142715 - folkertdev:fn-align-corrections, r=jdonszel…
Kobzol Jun 20, 2025
99b850e
Rollup merge of #142720 - yotamofek:pr/rustdoc/ext-crate-cleanup, r=G…
Kobzol Jun 20, 2025
b638bec
Rollup merge of #142736 - lolbinarycat:rustdoc-issue-template, r=Guil…
Kobzol Jun 20, 2025
3a676cc
Rollup merge of #142743 - tshepang:rdg-push, r=jieyouxu
Kobzol Jun 20, 2025
509d289
Rollup merge of #142744 - tgross35:y21-mailmap, r=y21
Kobzol Jun 20, 2025
833efa1
Rollup merge of #142758 - jieyouxu:rustdoc-json-types, r=Kobzol
Kobzol Jun 20, 2025
8b8255b
Rollup merge of #142764 - ChaiTRex:ilog_10_to_ilog10, r=workingjubilee
Kobzol Jun 20, 2025
4c899b2
Rollup merge of #142767 - nnethercote:symbol-cleanups, r=petrochenkov
Kobzol Jun 20, 2025
7cb6acc
Rollup merge of #142769 - jdonszelmann:remove-useless-new-method, r=t…
Kobzol Jun 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
initial instructions for gpu offload
  • Loading branch information
ZuseZ4 committed Jun 19, 2025
commit 0a185e422ccac38f0fb856b81c5f955873ff7cd0
2 changes: 2 additions & 0 deletions src/doc/rustc-dev-guide/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
- [The `rustdoc` test suite](./rustdoc-internals/rustdoc-test-suite.md)
- [The `rustdoc-gui` test suite](./rustdoc-internals/rustdoc-gui-test-suite.md)
- [The `rustdoc-json` test suite](./rustdoc-internals/rustdoc-json-test-suite.md)
- [GPU offload internals](./offload/internals.md)
- [Installation](./offload/installation.md)
- [Autodiff internals](./autodiff/internals.md)
- [Installation](./autodiff/installation.md)
- [How to debug](./autodiff/debugging.md)
Expand Down
71 changes: 71 additions & 0 deletions src/doc/rustc-dev-guide/src/offload/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Installation

In the future, `std::offload` should become available in nightly builds for users. For now, everyone still needs to build rustc from source.

## Build instructions

First you need to clone and configure the Rust repository:
```bash
git clone --depth=1 git@github.com:rust-lang/rust.git
cd rust
./configure --enable-llvm-link-shared --release-channel=nightly --enable-llvm-assertions --enable-offload --enable-enzyme --enable-clang --enable-lld --enable-option-checking --enable-ninja --disable-docs
```

Afterwards you can build rustc using:
```bash
./x.py build --stage 1 library
```

Afterwards rustc toolchain link will allow you to use it through cargo:
```
rustup toolchain link offload build/host/stage1
rustup toolchain install nightly # enables -Z unstable-options
```



## Build instruction for LLVM itself
```bash
git clone --depth=1 git@github.com:llvm/llvm-project.git
cd llvm-project
mkdir build
cd build
cmake -G Ninja ../llvm -DLLVM_TARGETS_TO_BUILD="host,AMDGPU,NVPTX" -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_ENABLE_RUNTIMES="offload,openmp" -DLLVM_ENABLE_PLUGINS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=.
ninja
ninja install
```
This gives you a working LLVM build.


## Testing
run
```
./x.py test --stage 1 tests/codegen/gpu_offload
```

## Usage
It is important to use a clang compiler build on the same llvm as rustc. Just calling clang without the full path will likely use your system clang, which probably will be incompatible.
```
/absolute/path/to/rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc --edition=2024 --crate-type cdylib src/main.rs --emit=llvm-ir -O -C lto=fat -Cpanic=abort -Zoffload=Enable
/absolute/path/to/rust/build/x86_64-unknown-linux-gnu/llvm/bin/clang++ -fopenmp --offload-arch=native -g -O3 main.ll -o main -save-temps
LIBOMPTARGET_INFO=-1 ./main
```
The first step will generate a `main.ll` file, which has enough instructions to cause the offload runtime to move data to and from a gpu.
The second step will use clang as the compilation driver to compile our IR file down to a working binary. Only a very small Rust subset will work out of the box here, unless
you use features like build-std, which are not covered by this guide. Look at the codegen test to get a feeling for how to write a working example.
In the last step you can run your binary, if all went well you will see a data transfer being reported:
```
omptarget device 0 info: Entering OpenMP data region with being_mapper at unknown:0:0 with 1 arguments:
omptarget device 0 info: tofrom(unknown)[1024]
omptarget device 0 info: Creating new map entry with HstPtrBase=0x00007fffffff9540, HstPtrBegin=0x00007fffffff9540, TgtAllocBegin=0x0000155547200000, TgtPtrBegin=0x0000155547200000, Size=1024, DynRefCount=1, HoldRefCount=0, Name=unknown
omptarget device 0 info: Copying data from host to device, HstPtr=0x00007fffffff9540, TgtPtr=0x0000155547200000, Size=1024, Name=unknown
omptarget device 0 info: OpenMP Host-Device pointer mappings after block at unknown:0:0:
omptarget device 0 info: Host Ptr Target Ptr Size (B) DynRefCount HoldRefCount Declaration
omptarget device 0 info: 0x00007fffffff9540 0x0000155547200000 1024 1 0 unknown at unknown:0:0
// some other output
omptarget device 0 info: Exiting OpenMP data region with end_mapper at unknown:0:0 with 1 arguments:
omptarget device 0 info: tofrom(unknown)[1024]
omptarget device 0 info: Mapping exists with HstPtrBegin=0x00007fffffff9540, TgtPtrBegin=0x0000155547200000, Size=1024, DynRefCount=0 (decremented, delayed deletion), HoldRefCount=0
omptarget device 0 info: Copying data from device to host, TgtPtr=0x0000155547200000, HstPtr=0x00007fffffff9540, Size=1024, Name=unknown
omptarget device 0 info: Removing map entry with HstPtrBegin=0x00007fffffff9540, TgtPtrBegin=0x0000155547200000, Size=1024, Name=unknown
```
9 changes: 9 additions & 0 deletions src/doc/rustc-dev-guide/src/offload/internals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# std::offload

This module is under active development. Once upstream, it should allow Rust developers to run Rust code on GPUs.
We aim to develop a `rusty` GPU programming interface, which is safe, convenient and sufficiently fast by default.
This includes automatic data movement to and from the GPU, in a efficient way. We will (later)
also offer more advanced, possibly unsafe, interfaces which allow a higher degree of control.

The implementation is based on LLVM's "offload" project, which is already used by OpenMP to run Fortran or C++ code on GPUs.
While the project is under development, users will need to call other compilers like clang to finish the compilation process.