Skip to content

Commit a4c3e6c

Browse files
committed
Add intrinsic doc comment
1 parent d43655b commit a4c3e6c

File tree

1 file changed

+25
-0
lines changed
  • library/core/src/intrinsics

1 file changed

+25
-0
lines changed

library/core/src/intrinsics/mod.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3304,6 +3304,31 @@ pub const fn copysignf128(x: f128, y: f128) -> f128;
33043304
#[rustc_intrinsic]
33053305
pub const fn autodiff<F, G, T: crate::marker::Tuple, R>(f: F, df: G, args: T) -> R;
33063306

3307+
/// Generates the LLVM body of a wrapper function to offload a kernel `f`.
3308+
///
3309+
/// Type Parameters:
3310+
/// - `F`: The kernel to offload. Must be a function item.
3311+
/// - `T`: A tuple of arguments passed to `f`.
3312+
/// - `R`: The return type of the kernel.
3313+
///
3314+
/// Example usage (pseudocode):
3315+
///
3316+
/// ```rust,ignore (pseudocode)
3317+
/// fn kernel(x: *mut [f64; 128]) {
3318+
/// core::intrinsics::offload(kernel_1, (x,))
3319+
/// }
3320+
///
3321+
/// #[cfg(target_os = "linux")]
3322+
/// extern "C" {
3323+
/// pub fn kernel_1(array_b: *mut [f64; 128]);
3324+
/// }
3325+
///
3326+
/// #[cfg(not(target_os = "linux"))]
3327+
/// #[rustc_offload_kernel]
3328+
/// extern "gpu-kernel" fn kernel_1(x: *mut [f64; 128]) {
3329+
/// unsafe { (*x)[0] = 21.0 };
3330+
/// }
3331+
/// ```
33073332
#[rustc_nounwind]
33083333
#[rustc_intrinsic]
33093334
pub const fn offload<F, T: crate::marker::Tuple, R>(f: F, args: T) -> R;

0 commit comments

Comments
 (0)