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: MetadataBindingInfoPacked scalars and metadata. First scalars sorted by type, then static metadata, then dynamic metadata.
Implementations§
Source§impl KernelArguments
impl KernelArguments
Sourcepub fn new() -> KernelArguments
pub fn new() -> KernelArguments
Create a new bindings struct
Sourcepub fn with_buffer(self, binding: BufferBinding) -> KernelArguments
pub fn with_buffer(self, binding: BufferBinding) -> KernelArguments
Add a buffer binding
Sourcepub fn with_buffer_io(
self,
binding: BufferBinding,
io: BufferIOAttr,
) -> KernelArguments
pub fn with_buffer_io( self, binding: BufferBinding, io: BufferIOAttr, ) -> KernelArguments
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.
Sourcepub fn with_buffers(self, bindings: Vec<BufferBinding>) -> KernelArguments
pub fn with_buffers(self, bindings: Vec<BufferBinding>) -> KernelArguments
Extend the buffers with bindings
Sourcepub fn with_info(self, info: MetadataBindingInfo) -> KernelArguments
pub fn with_info(self, info: MetadataBindingInfo) -> KernelArguments
Set the info to info
Sourcepub fn with_tensor_maps(
self,
bindings: Vec<TensorMapBinding>,
) -> KernelArguments
pub fn with_tensor_maps( self, bindings: Vec<TensorMapBinding>, ) -> KernelArguments
Extend the tensor maps with bindings
Sourcepub fn buffers(&self) -> impl Iterator<Item = &BufferBinding>
pub fn buffers(&self) -> impl Iterator<Item = &BufferBinding>
The buffers this launch was given.
Sourcepub fn memory_ids(&self) -> impl Iterator<Item = ManagedMemoryId>
pub fn memory_ids(&self) -> impl Iterator<Item = ManagedMemoryId>
The memory this launch was given.
Sourcepub fn buffers_written<'a>(
&'a self,
io: Option<&'a [BufferIOAttr]>,
) -> impl Iterator<Item = &'a BufferBinding>
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.
Sourcepub fn buffers_read<'a>(
&'a self,
io: Option<&'a [BufferIOAttr]>,
) -> impl Iterator<Item = &'a BufferBinding>
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
impl Debug for KernelArguments
Source§impl Default for KernelArguments
impl Default for KernelArguments
Source§fn default() -> KernelArguments
fn default() -> KernelArguments
Auto Trait Implementations§
impl Freeze for KernelArguments
impl RefUnwindSafe for KernelArguments
impl Send for KernelArguments
impl Sync for KernelArguments
impl Unpin for KernelArguments
impl UnsafeUnpin for KernelArguments
impl UnwindSafe for KernelArguments
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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