Expand description
SIMD-accelerated engines for the standard and URL-safe alphabets.
These are gated behind the simd-unsafe feature because they use unsafe. Three engines are
provided:
Simddetects the best available instruction set at runtime and falls back to the scalarGeneralPurposeengine when none is available. It requiresstdfor the detection.Avx2andNeontarget a specific instruction set with no runtime detection, so they can be used inno_stdbuilds when the target is known to support the instructions.
Only the STANDARD and URL_SAFE alphabets are accelerated (they share indices 0..=61 and differ
only at 62/63). Each engine therefore has dedicated standard / url_safe constructors
rather than taking an arbitrary Alphabet; use GeneralPurpose
for any other alphabet.
The kernels follow Wojciech Mulaβs vectorized base64 algorithms
(http://0x80.pl/notesen/2016-01-17-sse-base64-decoding.html and the companion encoding note).
AVX2 uses the multiply-based bit (de)interleave; NEON, which lacks the relevant multiplies, uses
the shift/mask variant. Both share the same per-alphabet lookup tables, expressed as the
associated constants of the SimdAlphabet trait so the kernels can inline them.
ModulesΒ§
- avx2 π
StructsΒ§
- Avx2
- A base64 engine that unconditionally uses AVX2, without runtime detection.
- Simd
- A base64 engine that uses the best SIMD instruction set detected at runtime, falling back to the
scalar
GeneralPurposeengine.
EnumsΒ§
- Backend π
- Which instruction set an engine dispatches to.
- Simd
Kind π - Which accelerated alphabet family an engine uses. Selects the kernel monomorphization at runtime.
- Standard π
- The STANDARD alphabet family (
+//at 62/63). - UrlSafe π
- The URL_SAFE alphabet family (
-/_at 62/63).
ConstantsΒ§
- BITPOS_
LUT π - pshufb decode validity table: maps a high nibble to a single set bit. Shared by both alphabets.
- SIMD_
MIN_ πINPUT_ DECODE - SIMD_
MIN_ πINPUT_ ENCODE - Minimum input length before a SIMD path is used. Below these the setup cost outweighs the gain; encode needs more data than decode to break even.
TraitsΒ§
- Simd
Alphabet π - A base64 alphabet family the SIMD kernels can accelerate.
FunctionsΒ§
- avx2_
decode π β - Dispatch the AVX2 decode kernel to the right alphabet monomorphization.
- avx2_
encode π β - Dispatch the AVX2 encode kernel to the right alphabet monomorphization.