Derive Macro rust_cuda::lend::LendRustToCuda

source ·
#[derive(LendRustToCuda)]
{
    // Attributes available to this derive:
    #[cuda]
}
Available on crate feature derive only.
Expand description

Provides the #[derive(LendRustToCuda) derive macro for the rust_cuda::lend::RustToCuda utility trait, which enables the usage of the rust_cuda::lend::LendToCuda trait that allows Rust data structures to be shared with CUDA kernels.

At the moment, only structs are supported by this derive macro.

The derive also accepts a #[cuda(...)] attribute. You can annotate the entire struct with the #[cuda(...)] to configure the implementation as follows:

  • #[cuda(crate = "<crate-path>")] changes the path to the rust-cuda crate that the derive uses, which by default is rust_cuda.
  • #[cuda(bound = "<where-predicate>")] adds the provided predicate to the where clause of the trait implementation.
  • #[cuda(free = "<type>")] removes the the auto-added trait bounds for the type parameter <type> from the trait implementation, e.g. when implementing a wrapper around [std::marker::PhantomData<T>] which should implement the trait for any T.
  • #[cuda(async = <bool>)] explicitly enables or disables the async implementation of the trait, rust_cuda::lend::RustToCudaAsync. By default, #[cuda(async = true)] is set.
  • #[cuda(layout::ATTR = "VALUE")] adds the #[layout(ATTR = "VALUE")] attribute to the #derive(const_type_layout::TypeLayout) derive for this struct’s rust_cuda::lend::RustToCuda::CudaRepresentation.
  • #[cuda(ignore)] removes all subsequent attributes from the generated rust_cuda::lend::RustToCuda::CudaRepresentation struct.

Additionally, the #[cuda(...)] attribute can also be applied individually to the fields of the struct to customise the implementation as follows: