Derive Macro rust_cuda_derive::LendRustToCuda
source · #[derive(LendRustToCuda)]
{
// Attributes available to this derive:
#[cuda]
}
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 therust-cudacrate that the derive uses, which by default isrust_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 aroundstd::marker::PhantomData<T>which should implement the trait for anyT.#[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’srust_cuda::lend::RustToCuda::CudaRepresentation.#[cuda(ignore)]removes all subsequent attributes from the generatedrust_cuda::lend::RustToCuda::CudaRepresentationstruct.
Additionally, the #[cuda(...)] attribute can also be applied individually
to the fields of the struct to customise the implementation as follows:
#[cuda(embed)]signals that this field has a non-identity CUDA representation and should be embedded by using therust_cuda::lend::RustToCudaimplementation of this field’s type. When this attribute is not specified, the field must instead implementCopy,rust_cuda::safety::PortableBitSemantics, andconst_type_layout::TypeGraphLayout.#[cuda(embed = "<proxy-type>")]works like#[cuda(embed)]but can be used when the field’s type does not implementrust_cuda::lend::RustToCudaitself, but some<proxy-type>exists, which implementsrust_cuda::lend::RustToCudaProxyfor the field’s type.#[cuda(ignore)]removes all subsequent attributes from this field in the generatedrust_cuda::lend::RustToCuda::CudaRepresentationstruct.