Skip to content

Commit 6174b1a

Browse files
committed
Auto merge of #149351 - Zalathar:rollup-ee06zha, r=Zalathar
Rollup of 12 pull requests Successful merges: - rust-lang/rust#147936 (Offload intrinsic) - rust-lang/rust#148358 (Fix some issues around `rustc_public`) - rust-lang/rust#148452 (Mangle symbols with a mangled name close to PDB limits with v0 instead of legacy mangling to avoid linker errors) - rust-lang/rust#148751 (Build gnullvm toolchains on Windows natively) - rust-lang/rust#148951 (rustc_target: aarch64: Remove deprecated FEAT_TME) - rust-lang/rust#149149 ([rustdoc] misc search index cleanups) - rust-lang/rust#149173 (Use rust rather than LLVM target features in the target spec) - rust-lang/rust#149307 (Deny const auto traits) - rust-lang/rust#149312 (Mark riscv64gc-unknown-linux-musl as tier 2 target) - rust-lang/rust#149317 (Handle inline asm in has_ffi_unwind_calls) - rust-lang/rust#149326 (Remove unused `Clone` derive on `DelayedLint`) - rust-lang/rust#149341 (Add `Copy` to some AST enums.) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d707c84 + 7ff2e4a commit 6174b1a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/offload/usage.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ We currently work on launching the following Rust kernel on the GPU. To follow a
55

66
```rust
77
#![feature(abi_gpu_kernel)]
8+
#![feature(rustc_attrs)]
9+
#![feature(core_intrinsics)]
810
#![no_std]
911

1012
#[cfg(target_os = "linux")]
1113
extern crate libc;
1214
#[cfg(target_os = "linux")]
1315
use libc::c_char;
1416

17+
#[cfg(target_os = "linux")]
1518
use core::mem;
1619

1720
#[panic_handler]
@@ -38,7 +41,7 @@ fn main() {
3841
}
3942

4043
unsafe {
41-
kernel_1(array_c);
44+
kernel(array_c);
4245
}
4346
core::hint::black_box(&array_c);
4447
unsafe {
@@ -52,6 +55,11 @@ fn main() {
5255
}
5356
}
5457

58+
#[inline(never)]
59+
unsafe fn kernel(x: *mut [f64; 256]) {
60+
core::intrinsics::offload(kernel_1, (x,))
61+
}
62+
5563
#[cfg(target_os = "linux")]
5664
unsafe extern "C" {
5765
pub fn kernel_1(array_b: *mut [f64; 256]);
@@ -60,6 +68,7 @@ unsafe extern "C" {
6068
#[cfg(not(target_os = "linux"))]
6169
#[unsafe(no_mangle)]
6270
#[inline(never)]
71+
#[rustc_offload_kernel]
6372
pub extern "gpu-kernel" fn kernel_1(x: *mut [f64; 256]) {
6473
unsafe { (*x)[0] = 21.0 };
6574
}

0 commit comments

Comments
 (0)