Skip to main content

RaspBatch

Struct RaspBatch 

Source
pub struct RaspBatch<T> { /* private fields */ }
Expand description

Structure-of-arrays storage for bounds-checked pointers.

T is a phantom type; each entry refers to an externally-owned [T] region. The caller is responsible for keeping the regions alive for the lifetime of the batch. Use push_from_slice with the returned slice as a borrow anchor.

Implementations§

Source§

impl<T> RaspBatch<T>

Source

pub fn new() -> Self

Source

pub fn with_capacity(n: usize) -> Self

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn capacity(&self) -> usize

Source

pub fn push_from_slice<'a>( &mut self, slice: &'a [T], perms: u32, ) -> Result<(RaspBatchIndex<T>, &'a [T]), RaspError>

Push a new pointer from a borrowed slice. The returned slice is the lifetime anchor; the batch’s pointer is valid only as long as the anchor is held.

Source

pub fn push_raw( &mut self, ptr: u64, base: u64, length: u32, perms: u32, ) -> Result<RaspBatchIndex<T>, RaspError>

Push from raw integer fields (caller manages target lifetime).

Source

pub fn check_read_scalar(&self, idx: RaspBatchIndex<T>) -> Result<(), RaspError>

Per-element scalar check. Used by per-index call sites and as the correctness oracle for the SIMD batch path.

Source

pub fn raw_ptr(&self, idx: RaspBatchIndex<T>) -> Option<*const T>

Raw pointer at the given index. Returns None for an out-of-range index. The pointer is NOT validated; pair with check_read_scalar (or use read_at which combines both).

Source

pub unsafe fn read_at(&self, idx: RaspBatchIndex<T>) -> Result<T, RaspError>
where T: Copy,

Bounds + permission check followed by a dereference. The caller’s responsibility for the original target lifetime still applies (see push_from_slice’s borrow anchor).

§Safety

The target of the pointer at idx must still be valid (alive, properly aligned for T, and accessible via the permissions encoded). The check enforces the permissions recorded at push time; it does NOT prove the target’s allocation has not been freed.

Source

pub fn check_read_all_scalar(&self) -> Vec<Result<(), RaspError>>

Batch scalar check across the whole array. Reference path.

Source

pub fn count_valid_scalar(&self) -> u32

Count of valid entries (Ok results) via scalar path. Avoids the Vec<Result> allocation when only the count is needed.

Source

pub unsafe fn count_valid_avx2(&self) -> u32

AVX2-accelerated count of valid entries. Processes 4 elements per loop iteration using contiguous SIMD loads from each parallel Vec.

§Safety

Caller must guarantee AVX2 is supported by the runtime CPU.

Source

pub unsafe fn count_valid_avx512(&self) -> u32

AVX-512F count of valid entries. Processes 8 elements per iteration: ZMM (8x u64) loads for ptrs/bases, YMM (8x u32) loads for lengths/perms, mask-producing _mm512_cmpgt_epi64_mask for both bounds checks. Doubles the per-iteration throughput of the AVX2 path.

§Safety

Caller must guarantee AVX-512F is supported by the runtime CPU.

Source

pub fn count_valid(&self) -> u32

Cross-platform safe count of valid entries. Dispatches to count_valid_avx512 when AVX-512F is present, then count_valid_avx2, then count_valid_scalar.

Source

pub unsafe fn check_read_all_avx2(&self) -> Vec<Result<(), RaspError>>

AVX2-accelerated full validation that writes per-index results. Slower than count_valid_avx2 because it materialises a Vec<Result> instead of just counting; use this when the caller needs per-index error attribution.

§Safety

Caller must guarantee AVX2 is supported by the runtime CPU.

Source

pub unsafe fn check_read_all_avx512(&self) -> Vec<Result<(), RaspError>>

AVX-512F full validation that writes per-index results. Processes 8 elements per iteration via ZMM loads and mask-producing _mm512_cmpgt_epi64_mask. Bit-exact equivalent of check_read_all_avx2 and check_read_all_scalar.

§Safety

Caller must guarantee AVX-512F is supported by the runtime CPU.

Source

pub fn check_read_all(&self) -> Vec<Result<(), RaspError>>

Cross-platform safe full validation.

Trait Implementations§

Source§

impl<T> Default for RaspBatch<T>

Source§

fn default() -> Self

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

impl<T: Send> Send for RaspBatch<T>

Source§

impl<T: Sync> Sync for RaspBatch<T>

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