pub struct DynamicSharedMemory { /* private fields */ }Expand description
Dynamic shared memory allocation.
Represents a shared memory buffer whose size is determined at kernel launch
time. Analogous to extern __shared__ T data[] in CUDA where the size is
passed as a launch parameter.
The buffer is untyped (byte-level) and callers can reinterpret as needed.
Implementations§
Sourcepub fn new(size_bytes: usize) -> Self
pub fn new(size_bytes: usize) -> Self
Allocate dynamic shared memory of the given size in bytes.
§Panics
Panics if size_bytes is 0 or allocation fails.
Sourcepub fn size_bytes(&self) -> usize
pub fn size_bytes(&self) -> usize
Returns the size of the buffer in bytes.
Sourcepub fn as_typed_slice<T>(&self) -> &[T]
pub fn as_typed_slice<T>(&self) -> &[T]
Reinterpret the buffer as a typed slice of T.
§Panics
Panics if the buffer size is not a multiple of size_of::<T>() or if
the alignment is insufficient.
Sourcepub fn as_typed_slice_mut<T>(&mut self) -> &mut [T]
pub fn as_typed_slice_mut<T>(&mut self) -> &mut [T]
Reinterpret the buffer as a mutable typed slice of T.
§Safety
Caller must ensure exclusive access and correct typing.
Sourcepub fn as_mut_ptr(&mut self) -> *mut u8
pub fn as_mut_ptr(&mut self) -> *mut u8
Get a mutable raw byte pointer.
Trait Implementations§
Auto Trait Implementations§
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
Mutably borrows from an owned value. Read more