Skip to main content

KernelArg

Enum KernelArg 

Source
pub enum KernelArg {
Show 13 variants DevSlice(Box<dyn DevSliceArg>), Scalar(Box<dyn ScalarArg>), Usize(usize), DevSliceF32(GpuRef<f32>), DevSliceF64(GpuRef<f64>), DevSliceI32(GpuRef<i32>), DevSliceU32(GpuRef<u32>), DevSliceU8(GpuRef<u8>), ScalarF32(f32), ScalarF64(f64), ScalarI32(i32), ScalarU32(u32), ScalarU64(u64),
}
Expand description

A single argument to an NVRTC kernel launch.

The two boxed variants (KernelArg::DevSlice and KernelArg::Scalar) are the canonical Phase-0.3+ form; every dtype the runtime understands routes through them via the DevSliceArg / ScalarArg blanket impls. The remaining typed-variant aliases are #[deprecated] and exist so pre-Phase-0.3 callers still compile.

Variants§

§

DevSlice(Box<dyn DevSliceArg>)

Canonical: a typed device slice as Box<dyn DevSliceArg>. Construct as KernelArg::DevSlice(Box::new(my_gpu_ref)) for any GpuRef<T: CudaDtype> (which is every supported dtype, including u8 raw byte buffers).

§

Scalar(Box<dyn ScalarArg>)

Canonical: a typed scalar as Box<dyn ScalarArg>. Construct as KernelArg::Scalar(Box::new(2.0_f32)).

§

Usize(usize)

usize is not a CudaDtype (its size is platform-dependent) so it has its own variant.

§

DevSliceF32(GpuRef<f32>)

👎Deprecated: use KernelArg::DevSlice with GpuRef directly
§

DevSliceF64(GpuRef<f64>)

👎Deprecated: use KernelArg::DevSlice with GpuRef directly
§

DevSliceI32(GpuRef<i32>)

👎Deprecated: use KernelArg::DevSlice with GpuRef directly
§

DevSliceU32(GpuRef<u32>)

👎Deprecated: use KernelArg::DevSlice with GpuRef directly
§

DevSliceU8(GpuRef<u8>)

👎Deprecated: use KernelArg::DevSlice with GpuRef directly
§

ScalarF32(f32)

👎Deprecated: use KernelArg::Scalar with the scalar value directly
§

ScalarF64(f64)

👎Deprecated: use KernelArg::Scalar with the scalar value directly
§

ScalarI32(i32)

👎Deprecated: use KernelArg::Scalar with the scalar value directly
§

ScalarU32(u32)

👎Deprecated: use KernelArg::Scalar with the scalar value directly
§

ScalarU64(u64)

👎Deprecated: use KernelArg::Scalar with the scalar value directly

Implementations§

Source§

impl KernelArg

Source

pub fn canonicalize(self) -> KernelArg

Normalise any pre-Phase-0.3 typed-variant alias to the canonical KernelArg::DevSlice / KernelArg::Scalar / KernelArg::Usize form.

Used by the actor to fold the ten deprecated typed variants into the two boxed-dyn variants before the launch loop. After canonicalisation the launch loop has exactly three arms (DevSlice, Scalar, Usize) instead of eleven.

Auto Trait Implementations§

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> Extension for T
where T: Any + Send + Sync,