Attribute Macro cuda_std::kernel

source · []
#[kernel]
Expand description

Registers a function as a gpu kernel.

This attribute must always be placed on gpu kernel functions.

This attribute does a couple of things:

  • Tells rustc_codegen_nvvm to mark this as a gpu kernel and to not remove it from the ptx file.
  • Marks the function as no_mangle.
  • Errors if the function is not unsafe.
  • Makes sure function parameters are all Copy.
  • Makes sure the function doesn’t return anything.

Note that this does not cfg the function for nvptx(64), that is explicit so that rust analyzer is able to offer intellisense by default.