Skip to main content

AlignedVec

Struct AlignedVec 

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

Source

pub fn with_capacity(capacity: usize) -> Self

Create with capacity rounded up to 64-byte boundary

Source

pub fn from_slice(slice: &[T]) -> Self

Create from a slice, copying data into aligned storage

Source

pub fn zeros(len: usize) -> Self

Create filled with zeros

Source

pub const fn len(&self) -> usize

Logical length

Source

pub const fn is_empty(&self) -> bool

Check if empty

Source

pub const fn capacity(&self) -> usize

Aligned capacity

Source

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

Get raw pointer (guaranteed 64-byte aligned for f32/f64)

Source

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

Get mutable raw pointer

Source

pub fn as_slice(&self) -> &[T]

Get as slice

Source

pub fn as_mut_slice(&mut self) -> &mut [T]

Get as mutable slice

Source

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.

Source

pub fn size_bytes(&self) -> usize

Size in bytes (actual data, not capacity)

Source

pub fn push(&mut self, value: T)

Push a value (may reallocate if at capacity)

Source

pub fn clear(&mut self)

Clear the vector (keeps capacity)

Source

pub fn get(&self, index: usize) -> Option<&T>

Get element by index

Source

pub fn get_mut(&mut self, index: usize) -> Option<&mut T>

Get mutable element by index

Source

pub fn set(&mut self, index: usize, value: T) -> bool

Set element by index

Trait Implementations§

Source§

impl<T: Clone + Copy + Default> Clone for AlignedVec<T>

Source§

fn clone(&self) -> AlignedVec<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Copy + Default> Debug for AlignedVec<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Copy + Default> Default for AlignedVec<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Copy + Default> FromIterator<T> for AlignedVec<T>

Source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: Copy + Default> Index<usize> for AlignedVec<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T: Copy + Default> IndexMut<usize> for AlignedVec<T>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T: Copy + Default + PartialEq> PartialEq for AlignedVec<T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V