Skip to main content

KernelArguments

Struct KernelArguments 

Source
pub struct KernelArguments {
    pub resources: Vec<KernelResource>,
    pub declared_io: Vec<BufferIOAttr>,
    pub info: MetadataBindingInfo,
}
Expand description

Arguments to execute a kernel.

Fields§

§resources: Vec<KernelResource>

Kernel bindings

§declared_io: Vec<BufferIOAttr>

What the caller declared each resource is for, indexed like resources.

The compiled kernel’s own answer is better when it exists — the visibility analysis can prove a buffer write-only or dead, which a caller cannot — but it only exists once the kernel compiles. This one is stamped at the launch site from what the caller can see (a launch generated from &Tensor versus &mut Tensor knows it statically), so it survives the compile failing, which is exactly when it is needed: a launch that never ran must not taint the buffers it was only going to read. Missing entries read as ReadWrite, so a caller that declares nothing keeps the loud fallback.

§info: MetadataBindingInfo

Packed scalars and metadata. First scalars sorted by type, then static metadata, then dynamic metadata.

Implementations§

Source§

impl KernelArguments

Source

pub fn new() -> Self

Create a new bindings struct

Source

pub fn with_buffer(self, binding: BufferBinding) -> Self

Add a buffer binding

Source

pub fn with_buffer_io(self, binding: BufferBinding, io: BufferIOAttr) -> Self

Add a buffer binding, declaring what the kernel does with it.

The declaration is what a launch that fails before running — a kernel that does not compile above all — falls back on: only declared-writable buffers take the failure, so the ones the kernel was only going to read stay readable. Resources added without a declaration read as ReadWrite, and mixing the two keeps every declaration on the resource it was made for.

Source

pub fn with_buffers(self, bindings: Vec<BufferBinding>) -> Self

Extend the buffers with bindings

Source

pub fn with_info(self, info: MetadataBindingInfo) -> Self

Set the info to info

Source

pub fn with_tensor_maps(self, bindings: Vec<TensorMapBinding>) -> Self

Extend the tensor maps with bindings

Source

pub fn buffers(&self) -> impl Iterator<Item = &BufferBinding>

The buffers this launch was given.

Source

pub fn memory_ids(&self) -> impl Iterator<Item = ManagedMemoryId> + '_

The memory this launch was given.

Source

pub fn buffers_written<'a>( &'a self, io: Option<&'a [BufferIOAttr]>, ) -> impl Iterator<Item = &'a BufferBinding>

The buffers this launch was given that the kernel writes, per the compiled kernel’s own answer — the ones a launch that fails taints, and nothing else.

io is what the compiler recorded from its visibility analysis, indexed like resources (see BufferIOAttr). An index it has no answer for falls back to the caller’s declaration in declared_io — which is how a kernel that never compiled still taints only its outputs — and an index neither answers reads as written: naming a buffer the kernel only read fails a read that would have been fine, loudly; missing one it writes hands back the bytes that were there before, silently — so the last-resort fallback over-names.

Source

pub fn buffers_read<'a>( &'a self, io: Option<&'a [BufferIOAttr]>, ) -> impl Iterator<Item = &'a BufferBinding>

The buffers this launch was given that the kernel reads — the ones whose contents have to be trustworthy before the launch runs, and the only ones checked: a pure output is not read, so a relaunch into a tainted buffer is exactly how the buffer gets repaired.

The same fallback chain as buffers_written: compiled answer, then the caller’s declaration, then read — so a kernel nobody kept an answer for is checked on everything rather than checked on nothing.

Trait Implementations§

Source§

impl Debug for KernelArguments

Source§

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

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

impl Default for KernelArguments

Source§

fn default() -> Self

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

impl Display for KernelArguments

Source§

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

Formats the value using the given formatter. Read more

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<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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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