pub struct AlignedVec<T: Copy + Default> { /* private fields */ }Expand description
64-byte aligned vector for SIMD operations (spec §5.2)
Provides memory-aligned storage for efficient SIMD access. Alignment is guaranteed at 64 bytes for AVX-512 compatibility.
§Memory Layout
- Data is stored in a Vec with additional alignment tracking
- Capacity is rounded up to 64-byte boundaries
- Provides raw pointers for FFI/SIMD operations
§Example
use aprender::native::AlignedVec;
let vec = AlignedVec::from_slice(&[1.0_f32, 2.0, 3.0, 4.0]);
assert!(vec.is_aligned());
assert_eq!(vec.len(), 4);
// Access as slice
assert_eq!(vec.as_slice(), &[1.0, 2.0, 3.0, 4.0]);Implementations§
Source§impl<T: Copy + Default> AlignedVec<T>
impl<T: Copy + Default> AlignedVec<T>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create with capacity rounded up to 64-byte boundary
Sourcepub fn from_slice(slice: &[T]) -> Self
pub fn from_slice(slice: &[T]) -> Self
Create from a slice, copying data into aligned storage
Sourcepub fn as_mut_ptr(&mut self) -> *mut T
pub fn as_mut_ptr(&mut self) -> *mut T
Get mutable raw pointer
Sourcepub fn as_mut_slice(&mut self) -> &mut [T]
pub fn as_mut_slice(&mut self) -> &mut [T]
Get as mutable slice
Sourcepub fn is_aligned(&self) -> bool
pub fn is_aligned(&self) -> bool
Check alignment (for debugging)
Note: Standard Rust Vec does not guarantee 64-byte alignment. This function checks if the data pointer happens to be aligned. For true SIMD-aligned allocations, use a specialized allocator.
Sourcepub fn size_bytes(&self) -> usize
pub fn size_bytes(&self) -> usize
Size in bytes (actual data, not capacity)
Trait Implementations§
Source§impl<T: Clone + Copy + Default> Clone for AlignedVec<T>
impl<T: Clone + Copy + Default> Clone for AlignedVec<T>
Source§fn clone(&self) -> AlignedVec<T>
fn clone(&self) -> AlignedVec<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Copy + Default> FromIterator<T> for AlignedVec<T>
impl<T: Copy + Default> FromIterator<T> for AlignedVec<T>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
Auto Trait Implementations§
impl<T> Freeze for AlignedVec<T>
impl<T> RefUnwindSafe for AlignedVec<T>where
T: RefUnwindSafe,
impl<T> Send for AlignedVec<T>where
T: Send,
impl<T> Sync for AlignedVec<T>where
T: Sync,
impl<T> Unpin for AlignedVec<T>where
T: Unpin,
impl<T> UnwindSafe for AlignedVec<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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