pub const fn offload<F, T, R>(f: F, args: T) -> Rwhere
T: Tuple,🔬This is a nightly-only experimental API. (
core_intrinsics)Expand description
Generates the LLVM body of a wrapper function to offload a kernel f.
Type Parameters:
F: The kernel to offload. Must be a function item.T: A tuple of arguments passed tof.R: The return type of the kernel.
Example usage (pseudocode):
ⓘ
fn kernel(x: *mut [f64; 128]) {
core::intrinsics::offload(kernel_1, (x,))
}
#[cfg(target_os = "linux")]
extern "C" {
pub fn kernel_1(array_b: *mut [f64; 128]);
}
#[cfg(not(target_os = "linux"))]
#[rustc_offload_kernel]
extern "gpu-kernel" fn kernel_1(x: *mut [f64; 128]) {
unsafe { (*x)[0] = 21.0 };
}For reference, see the Clang documentation on offloading: https://clang.llvm.org/docs/OffloadingDesign.html.