Skip to main content

KernelParameters

Struct KernelParameters 

Source
pub struct KernelParameters<'a> { /* private fields */ }
Expand description

Dynamically built CUDA kernel argument list.

Use this builder when the argument list depends on runtime conditions:

let mut params = KernelParameters::new();
params.arg(&input_ptr).arg(&output_ptr).push(len);
function.launch(&config, params)?;

For fixed argument lists, passing a tuple of references directly to KernelFunction::launch avoids building a dynamic list:

function.launch(&config, (&input_ptr, &mut output_ptr, &len))?;

Borrowed arguments are tied to the lifetime of this list. Owned scalar and pointer arguments pushed with Self::push or Self::owned_arg are stored inline when they fit, so ordinary kernel launches do not allocate per argument.

Implementations§

Source§

impl<'a> KernelParameters<'a>

Source

pub const fn new() -> Self

Source

pub fn arg<T: 'a>(&mut self, value: &'a T) -> &mut Self

Source

pub fn arg_mut<T: 'a>(&mut self, value: &'a mut T) -> &mut Self

Source

pub fn owned_arg<T: Copy + 'static>(&mut self, value: T) -> &mut Self

Pushes a copied kernel argument whose storage is owned by this list.

Small scalar and pointer values are stored inline. Larger values fall back to heap storage, while keeping the argument pointee stable until CUDA has copied it during launch or graph-node creation.

Source

pub fn push<A: PushKernelArg>(&mut self, arg: A) -> &mut Self

Source

pub fn device_slice<T: DeviceRepr, S: DeviceSlice<T> + ?Sized>( &mut self, slice: &S, ) -> &mut Self

Source

pub fn device_slice_mut<T: DeviceRepr, S: DeviceSliceMut<T> + ?Sized>( &mut self, slice: &mut S, ) -> &mut Self

Trait Implementations§

Source§

impl Debug for KernelParameters<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for KernelParameters<'_>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a> KernelLaunchArgs<'a> for KernelParameters<'a>

Source§

impl<'a> KernelLaunchArgs<'a> for &mut KernelParameters<'a>

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for KernelParameters<'a>

§

impl<'a> !Send for KernelParameters<'a>

§

impl<'a> !Sync for KernelParameters<'a>

§

impl<'a> !UnwindSafe for KernelParameters<'a>

§

impl<'a> Freeze for KernelParameters<'a>

§

impl<'a> Unpin for KernelParameters<'a>

§

impl<'a> UnsafeUnpin for KernelParameters<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.