Table64

Struct Table64 

Source
pub struct Table64 { /* private fields */ }
Expand description

A SIMD-optimized 64-entry lookup table, able to do extremely efficient lookups in ARM NEON and Intel AVX-512VBMI.

§2D Interpretation

Table64 can also be viewed as an 8×8 two-dimensional table stored in row-major order:

       col 0  col 1  col 2  col 3  col 4  col 5  col 6  col 7
row 0:   0      1      2      3      4      5      6      7
row 1:   8      9     10     11     12     13     14     15
row 2:  16     17     18     19     20     21     22     23
row 3:  24     25     26     27     28     29     30     31
row 4:  32     33     34     35     36     37     38     39
row 5:  40     41     42     43     44     45     46     47
row 6:  48     49     50     51     52     53     54     55
row 7:  56     57     58     59     60     61     62     63

Use lookup_one_2d to perform lookups using (row, column) coordinates.

Implementations§

Source§

impl Table64

Source

pub fn new(table: &[u8; 64]) -> Self

Source

pub fn lookup_one(&self, idx: u8x16) -> u8x16

Single-vector lookup: each byte of idx (0..63) selects from this 64B table. Returns a u8x16 with the looked-up values.

Source

pub fn lookup_one_2d(&self, rows: u8x16, cols: u8x16) -> u8x16

2D lookup: treats the 64-entry table as an 8×8 row-major matrix.

Each lane computes index = row * 8 + col and looks up the corresponding value.

§Arguments
  • rows: Row indices (0..7) for each of the 16 lanes
  • cols: Column indices (0..7) for each of the 16 lanes
§Panics (debug only)

Debug-asserts that all row and column values are in range 0..8.

§Example
let table = Table64::new(&data);
let rows = u8x16::from([0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7]);
let cols = u8x16::from([0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7]);
let result = table.lookup_one_2d(rows, cols);
// Looks up indices [0, 8, 16, 24, 32, 40, 48, 56, 7, 15, 23, 31, 39, 47, 55, 63]
Source

pub fn lookup(&self, idx: &[u8x16], out: &mut [u8x16])

Dynamic lookup: each byte of idx[k] (0..63) selects from this 64B table.

  • Requires: idx.len() == out.len()
  • No element tails (I/O is in whole u8x16 blocks).

Trait Implementations§

Source§

impl Clone for Table64

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Table64

Source§

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

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

impl Default for Table64

Source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

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

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.