Skip to content

Backend selection

Configure the engine

ts
const engine = await createVectorEngine({
  backend: 'auto', // 'auto' | 'native' | 'wasm'
  simd: 'auto', // 'auto' | 'off' | 'required'
})
  • auto: Node tries native first and falls back to Wasm on native loading failure. The error is available in engine.info.nativeUnavailable. Browsers select Wasm.
  • native: fails if a compatible addon cannot load; it never silently selects Wasm.
  • wasm: loads Wasm even in Node.
  • simd: 'off': disables explicit SIMD dispatch and selects the scalar Wasm asset.
  • simd: 'required': fails if the selected backend cannot provide SIMD. With backend: 'auto', it can fall back from native to SIMD-capable Wasm.

Inspect operation capabilities

engine.info.kernel is avx2, neon, simd128, or scalar. Native x86-64 checks CPU support before entering AVX2 kernels; AArch64 checks NEON. Short arrays and remaining elements use the scalar tail. The Rust compiler may also optimize scalar loops; off is not a promise about every generated machine instruction.

Query the implementation of an individual operation separately from the engine's selected kernel:

ts
engine.getCapability('add')
// { execution: 'simd', kernel: 'neon', fallback: false } on a NEON engine
engine.getCapability('add', 'f64')
// { execution: 'scalar', kernel: 'scalar', fallback: true } on a NEON engine
engine.getCapability('convert', 'i32', 'u8') // registered conversion direction

execution is simd, scalar, or unsupported. fallback: true means an operation uses scalar code despite the engine selecting SIMD. SIMD availability covers the vector prefix; short inputs and tails still run scalar. Initialization with simd: 'required' keeps its existing engine-level meaning.

Platform fallback

Release artifacts include macOS arm64/x64, Linux glibc arm64/x64, and Windows x64 addons in a single npm package. Other platforms, including Linux musl, use the bundled Wasm fallback when the native addon cannot load. No AVX-512 kernels are included in this version.

See support and compatibility for the distinction between implemented targets and recorded execution evidence.

Released under the MIT License.