Documentation

Hesper.Simd

SIMD CPU Backend for Hesper #

High-performance CPU vector operations using SIMD intrinsics (AVX2/NEON).

This module provides FFI bindings to optimized C++ implementations that leverage:

Example #

let a := FloatArray.mk #[1.0, 2.0, 3.0, 4.0]
let b := FloatArray.mk #[5.0, 6.0, 7.0, 8.0]
let c := simdAdd a b  -- [6.0, 8.0, 10.0, 12.0]
@[extern lean_simd_backend_info]

Get information about the SIMD backend being used

SIMD-optimized Float64 vector addition: c = a + b

Adds two float arrays element-wise using SIMD instructions when available.

Safety: Returns empty array if input sizes don't match.

Performance:

  • AVX2 (x86_64): 4 doubles/operation
  • NEON (ARM64): 2 doubles/operation
  • OpenMP multithreading for arrays ≥10K elements
Equations
Instances For

    Naive (non-SIMD) vector addition for benchmarking comparison.

    Implemented in pure Lean using Array.mapIdx.

    Equations
    Instances For
      def Hesper.Simd.verifyEqual (a b : FloatArray) (epsilon : Float := 1e-6) :

      Verify two float arrays are equal within epsilon tolerance.

      Used for correctness verification of SIMD operations.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For