Skip to main content

warp_kernel

Attribute Macro warp_kernel 

Source
#[warp_kernel]
Expand description

Mark a function as a GPU kernel entry point.

This attribute transforms the function signature for PTX compilation:

  • Adds #[no_mangle] for symbol visibility in PTX
  • Adds extern "ptx-kernel" ABI
  • Wraps the body in unsafe (PTX kernels are inherently unsafe)

§Parameter Rules

Kernel parameters must be one of:

  • Raw pointers (*const T, *mut T) — for device memory
  • Scalars (u32, i32, f32, u64, i64, f64, bool) — passed by value

§Compile-Time Safety

The function body uses warp-types normally. Warp::kernel_entry() creates the initial Warp<All>, and the type system prevents shuffle-from-inactive-lane bugs at compile time — on the actual GPU target.