Skip to main content

DynamicSharedMemory

Struct DynamicSharedMemory 

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

Source§

impl DynamicSharedMemory

Source

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.

Source

pub fn size_bytes(&self) -> usize

Returns the size of the buffer in bytes.

Source

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.

Source

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.

Source

pub fn as_ptr(&self) -> *const u8

Get the raw byte pointer.

Source

pub fn as_mut_ptr(&mut self) -> *mut u8

Get a mutable raw byte pointer.

Trait Implementations§

Source§

impl Drop for DynamicSharedMemory

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for DynamicSharedMemory

Source§

impl Sync for DynamicSharedMemory

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

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,