#[offload_kernel]🔬This is a nightly-only experimental API. (
gpu_offload #131513)Expand description
The offload_kernel macro is applied to a function to generate two separate
definitions: a host-side wrapper for dispatch and a device-side kernel.
The macro does not perform the offload itself. It generates the necessary code required by the compiler’s offloading infrastructure.
§Usage example:
This expands to the host-side function:
ⓘ
#[unsafe(no_mangle)]
#[inline(never)]
fn foo(_: &[f32], _: &[f32], _: *mut f32) {
::core::panicking::panic("not implemented")
}And the device-side kernel:
ⓘ
#[rustc_offload_kernel]
#[unsafe(no_mangle)]
unsafe extern "gpu-kernel" fn foo(a: &[f32], b: &[f32], c: *mut f32) {
*c = a[0] + b[0];
}