Skip to content

Commit 4e867ff

Browse files
committed
sembr src/offload/usage.md
1 parent 11f2641 commit 4e867ff

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

src/offload/usage.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Usage
22

3-
This feature is work-in-progress, and not ready for usage. The instructions here are for contributors, or people interested in following the latest progress.
4-
We currently work on launching the following Rust kernel on the GPU. To follow along, copy it to a `src/lib.rs` file.
3+
This feature is work-in-progress, and not ready for usage.
4+
The instructions here are for contributors, or people interested in following the latest progress.
5+
We currently work on launching the following Rust kernel on the GPU.
6+
To follow along, copy it to a `src/lib.rs` file.
57

68
```rust
79
#![feature(abi_gpu_kernel)]
@@ -75,9 +77,12 @@ pub extern "gpu-kernel" fn kernel_1(x: *mut [f64; 256]) {
7577
```
7678

7779
## Compile instructions
78-
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. So either substitute clang/lld invocations below with absolute path, or set your `PATH` accordingly.
80+
It is important to use a clang compiler build on the same llvm as rustc.
81+
Just calling clang without the full path will likely use your system clang, which probably will be incompatible.
82+
So either substitute clang/lld invocations below with absolute path, or set your `PATH` accordingly.
7983

80-
First we generate the device (gpu) code. Replace the target-cpu with the right code for your gpu.
84+
First we generate the device (gpu) code.
85+
Replace the target-cpu with the right code for your gpu.
8186
```
8287
RUSTFLAGS="-Ctarget-cpu=gfx90a --emit=llvm-bc,llvm-ir -Zoffload=Device -Csave-temps -Zunstable-options" cargo +offload build -Zunstable-options -r -v --target amdgcn-amd-amdhsa -Zbuild-std=core
8388
```
@@ -94,8 +99,11 @@ While we integrated most offload steps into rustc by now, one binary invocation
9499
"clang-linker-wrapper" "--should-extract=gfx90a" "--device-compiler=amdgcn-amd-amdhsa=-g" "--device-compiler=amdgcn-amd-amdhsa=-save-temps=cwd" "--device-linker=amdgcn-amd-amdhsa=-lompdevice" "--host-triple=x86_64-unknown-linux-gnu" "--save-temps" "--linker-path=/ABSOlUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/lld/bin/ld.lld" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf_x86_64" "-pie" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "bare" "/lib/../lib64/Scrt1.o" "/lib/../lib64/crti.o" "/ABSOLUTE_PATH_TO/crtbeginS.o" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/x86_64-unknown-linux-gnu" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/lib/clang/21/lib/x86_64-unknown-linux-gnu" "-L/lib/../lib64" "-L/usr/lib64" "-L/lib" "-L/usr/lib" "target/<GPU_DIR>/release/host.o" "-lstdc++" "-lm" "-lomp" "-lomptarget" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/lib" "-lgcc_s" "-lgcc" "-lpthread" "-lc" "-lgcc_s" "-lgcc" "/ABSOLUTE_PATH_TO/crtendS.o" "/lib/../lib64/crtn.o"
95100
```
96101

97-
You can try to find the paths to those files on your system. However, I recommend to not fix the paths, but rather just re-generate them by copying a bare-mode openmp example and compiling it with your clang. By adding `-###` to your clang invocation, you can see the invidual steps.
98-
It will show multiple steps, just look for the clang-linker-wrapper example. Make sure to still include the path to the `host.o` file, and not whatever tmp file you got when compiling your c++ example with the following call.
102+
You can try to find the paths to those files on your system.
103+
However, I recommend to not fix the paths, but rather just re-generate them by copying a bare-mode openmp example and compiling it with your clang.
104+
By adding `-###` to your clang invocation, you can see the invidual steps.
105+
It will show multiple steps, just look for the clang-linker-wrapper example.
106+
Make sure to still include the path to the `host.o` file, and not whatever tmp file you got when compiling your c++ example with the following call.
99107
```
100108
myclang++ -fuse-ld=lld -O3 -fopenmp -fopenmp-offload-mandatory --offload-arch=gfx90a omp_bare.cpp -o main -###
101109
```

0 commit comments

Comments
 (0)