Skip to content

Commit d5b8ac4

Browse files
committed
Add intrinsic doc comment
1 parent bfeb3ed commit d5b8ac4

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
@@ -3324,6 +3324,31 @@ pub const fn copysignf128(x: f128, y: f128) -> f128;
33243324
#[rustc_intrinsic]
33253325
pub const fn autodiff<F, G, T: crate::marker::Tuple, R>(f: F, df: G, args: T) -> R;
33263326

3327+
/// Generates the LLVM body of a wrapper function to offload a kernel `f`.
3328+
///
3329+
/// Type Parameters:
3330+
/// - `F`: The kernel to offload. Must be a function item.
3331+
/// - `T`: A tuple of arguments passed to `f`.
3332+
/// - `R`: The return type of the kernel.
3333+
///
3334+
/// Example usage (pseudocode):
3335+
///
3336+
/// ```rust,ignore (pseudocode)
3337+
/// fn kernel(x: *mut [f64; 128]) {
3338+
/// core::intrinsics::offload(kernel_1, (x,))
3339+
/// }
3340+
///
3341+
/// #[cfg(target_os = "linux")]
3342+
/// extern "C" {
3343+
/// pub fn kernel_1(array_b: *mut [f64; 128]);
3344+
/// }
3345+
///
3346+
/// #[cfg(not(target_os = "linux"))]
3347+
/// #[rustc_offload_kernel]
3348+
/// extern "gpu-kernel" fn kernel_1(x: *mut [f64; 128]) {
3349+
/// unsafe { (*x)[0] = 21.0 };
3350+
/// }
3351+
/// ```
33273352
#[rustc_nounwind]
33283353
#[rustc_intrinsic]
33293354
pub const fn offload<F, T: crate::marker::Tuple, R>(f: F, args: T) -> R;

0 commit comments

Comments
 (0)