pub struct KernelParamStorage { /* private fields */ }Expand description
Storage backing the void** array cuLaunchKernel expects.
CUDA’s cuLaunchKernel takes a *mut *mut c_void whose elements each
point to the value bytes of a single argument. The lifetimes are
awkward: the value bytes must outlive the launch call, and so must
the pointer array. KernelParamStorage owns both so the launch
site can take a *mut *mut c_void into it and pass that to
cuLaunchKernel without leaking.
Currently only used on CUDA builds; the no-CUDA host path records the
parsed Vec<LoweredArg> directly. The struct is still defined
non-conditionally so the type checker can prove the no-CUDA build
keeps the lowering free of CUDA-specific types.
§Layout (post v0.3.4)
A single contiguous Vec<u8> (backing) holds every scalar value
in declaration order, aligned per its native type. slots is the
pointer table CUDA reads through — each *mut c_void points to the
start of one slot inside backing. A 16-arg kernel costs one
Vec<u8> allocation plus one Vec<*mut c_void> allocation rather
than 16 small Box<[u8]> allocations.
The single-buffer layout is sound because cuLaunchKernel reads
each parameter through kernelParams[i] independently; the driver
has no per-slot alignment requirement that depends on slots being
distinct allocations. We still align each slot to
std::mem::align_of::<T>() so a misaligned f64 cannot read garbage
on architectures that fault on unaligned loads.
Implementations§
Trait Implementations§
impl Send for KernelParamStorage
Auto Trait Implementations§
impl !Sync for KernelParamStorage
impl Freeze for KernelParamStorage
impl RefUnwindSafe for KernelParamStorage
impl Unpin for KernelParamStorage
impl UnsafeUnpin for KernelParamStorage
impl UnwindSafe for KernelParamStorage
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
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