Skip to main content

Module lanes

Module lanes 

Source
Expand description

Numbers bit-packed in lanes: what a frame’s list of ints is made of.

A list of n numbers width bits each (1..=32) is n / GROUP groups, then the rest packed one after another (little-endian bits). A group is GROUP numbers in LANES lanes of 32-bit words: number j goes to lane j % LANES, the j / LANES-th in it; a lane’s numbers are packed one after another into its words, and word k of lane l is the group’s k * LANES + l-th. A row of LANES numbers is shifted and merged as one 256-bit vector, so packing and unpacking run a group at a time — with the best instruction set the processor has (Backend: SSE4.2, AVX2, AVX-512, NEON), chosen once at start; the same bytes whichever. Numbers wider than 32 bits go one after another, no groups.

Number i is found in O(1) (get), so views read in place.

Enums§

Backend
An instruction set that packs and unpacks groups. Every backend writes and reads the same bytes; they differ only in speed.

Constants§

GROUP
Numbers in a group.
GROUP_MAX_BITS
The widest numbers packed in groups.
LANES
Lanes of a group: a 256-bit vector of 32-bit words.

Functions§

get
Number i of bytes (n numbers, width bits each) — i < n.
group_bytes
A group’s bytes, its numbers width bits each.
pack
Packs items (n of them, each fitting width bits) onto out.
packed_bytes
The bytes n numbers width bits each take.
unpack
Each of the n numbers in bytes (width bits each), in order, to f.