You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of #149990 - Flakebi:improve-amdgpu-docs, r=ehuss
Improve amdgpu docs: Mention device-libs and xnack
Mention amdgpu-device-libs for allocator and println support and mention the necessary target flag for GPUs from some some series without xnack support.
For the last half year, there were no major changes in the amdgpu-device-libs crate (in fact, there was no need to update the crate), so I believe it is stable enough to mention it here.
The xnack-support flag is something I stumbled upon recently, when more complex printlns failed on a certain GPU.
Tracking issue: #135024
Copy file name to clipboardExpand all lines: src/doc/rustc/src/platform-support/amdgcn-amd-amdhsa.md
+9-4Lines changed: 9 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,8 +20,8 @@ The format of binaries is a linked ELF.
20
20
21
21
Binaries must be built with no-std.
22
22
They can use `core` and `alloc` (`alloc` only if an allocator is supplied).
23
-
At least one function needs to use the `"gpu-kernel"` calling convention and should be marked with `no_mangle`for simplicity.
24
-
Functions using the `"gpu-kernel"` calling convention are kernel entrypoints and can be used from the host runtime.
23
+
At least one function should use the `"gpu-kernel"` calling convention and should be marked with `no_mangle`or `export_name`.
24
+
Functions using the `"gpu-kernel"` calling convention are kernel entrypoints and can be launched from the host runtime.
25
25
26
26
## Building the target
27
27
@@ -34,6 +34,9 @@ The generations are exposed as different target-cpus in the backend.
34
34
As there are many, Rust does not ship pre-compiled libraries for this target.
35
35
Therefore, you have to build your own copy of `core` by using `cargo -Zbuild-std=core` or similar.
36
36
37
+
An allocator and `println!()` support is provided by the [`amdgpu-device-libs`] crate.
38
+
Both features rely on the [HIP] runtime.
39
+
37
40
To build a binary, create a no-std library:
38
41
```rust,ignore (platform-specific)
39
42
// src/lib.rs
@@ -65,13 +68,16 @@ lto = true
65
68
66
69
The target-cpu must be from the list [supported by LLVM] (or printed with `rustc --target amdgcn-amd-amdhsa --print target-cpus`).
67
70
The GPU version on the current system can be found e.g. with [`rocminfo`].
71
+
For a GPU series that has xnack support but the target GPU has not, the `-xnack-support` target-feature needs to be enabled.
72
+
I.e. if the ISA info as printed with [`rocminfo`] says something about `xnack-`, e.g. `gfx1010:xnack-`, add `-Ctarget-feature=-xnack-support` to the rustflags.
68
73
69
74
Example `.cargo/config.toml` file to set the target and GPU generation:
70
75
```toml
71
76
# .cargo/config.toml
72
77
[build]
73
78
target = "amdgcn-amd-amdhsa"
74
79
rustflags = ["-Ctarget-cpu=gfx1100"]
80
+
# Add "-Ctarget-feature=-xnack-support" for xnack- GPUs (see above)
75
81
76
82
[unstable]
77
83
build-std = ["core"] # Optional: "alloc"
@@ -85,8 +91,6 @@ Example code on how to load a compiled binary and run it is available in [ROCm e
85
91
86
92
On Linux, binaries can also run through the HSA runtime as implemented in [ROCR-Runtime].
87
93
88
-
<!-- Mention an allocator once a suitable one exists for amdgpu -->
89
-
90
94
<!--
91
95
## Testing
92
96
@@ -109,3 +113,4 @@ More information can be found on the [LLVM page for amdgpu].
109
113
[LLVM page for amdgpu]: https://llvm.org/docs/AMDGPUUsage.html
0 commit comments