pub struct AlignedBuffer { /* private fields */ }Expand description
A cache-line aligned buffer of f32 values.
Guarantees that the backing memory starts at a 64-byte boundary, which is optimal for AVX-512 aligned loads and cache line prefetch.
§Example
use oxibonsai_kernels::aligned::AlignedBuffer;
let buf = AlignedBuffer::new(256);
assert_eq!(buf.len(), 256);
assert_eq!(buf.as_ptr() as usize % 64, 0);Implementations§
Source§impl AlignedBuffer
impl AlignedBuffer
Sourcepub fn new(len: usize) -> Self
pub fn new(len: usize) -> Self
Allocate a new zero-initialized aligned buffer of len f32 elements.
The returned buffer is guaranteed to have 64-byte alignment. A zero-length buffer produces a valid (dangling but aligned) pointer.
Sourcepub fn as_mut_ptr(&mut self) -> *mut f32
pub fn as_mut_ptr(&mut self) -> *mut f32
Returns a mutable raw pointer to the start of the buffer.
Sourcepub fn as_mut_slice(&mut self) -> &mut [f32]
pub fn as_mut_slice(&mut self) -> &mut [f32]
View the buffer as a mutable slice.
Sourcepub fn copy_from_slice(&mut self, src: &[f32])
pub fn copy_from_slice(&mut self, src: &[f32])
Copy data from a slice into this buffer.
Panics if src.len() > self.len().
Trait Implementations§
Source§impl Debug for AlignedBuffer
impl Debug for AlignedBuffer
Source§impl Drop for AlignedBuffer
impl Drop for AlignedBuffer
impl Send for AlignedBuffer
impl Sync for AlignedBuffer
Auto Trait Implementations§
impl Freeze for AlignedBuffer
impl RefUnwindSafe for AlignedBuffer
impl Unpin for AlignedBuffer
impl UnsafeUnpin for AlignedBuffer
impl UnwindSafe for AlignedBuffer
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> 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>
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