Giter VIP home page Giter VIP logo

simsimd's Introduction

SimSIMD

SIMD-accelerated similarity measures, metrics, distance functions for x86 and Arm. Tuned for Machine Learning applications, mid-size vectors with 100-512 dimensions.

Distance Serial x86 AVX Arm NEON Arm SVE
f32 Dot Product AVX2-FMA
f32 Cosine AVX2-FMA
f32 Euclidean
u1 Hamming AVX512VPOPCNTDQ

Need something like this in your CMake-based project?

FetchContent_Declare(
    simsimd
    GIT_REPOSITORY https://github.com/ashvardanian/simsimd.git
    GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(simsimd)
include_directories(${simsimd_SOURCE_DIR}/include)

Benchmarks

By default, we use GCC12, -O3, -march=native for benchmarks. Serial versions imply auto-vectorization pragmas.


Cosine distance performance on a single core of a 64-core Arm-based "Graviton 3" CPUs powering AWS c7g.metal instances:

Method Vectors Any Length Performance
Serial f32 x16 5 GB/s
Serial f32 x256 5 GB/s
NEON f32 x16 18 GB/s
NEON f32 x256 29 GB/s
SVE f32 x16 15 GB/s
SVE f32 x256 39 GB/s

We only use Arm NEON implementation with vectors lengths that are multiples of 128 bits, avoiding any additional head or tail for loops for misaligned data. SVE looses to NEON on very short vectors, but outperforms on longer sequences.


On the x86 AMD Zen2 cores making up the 64-core Threadripper PRO 3995WX the numbers are:

Method Vectors Any Length Performance
Serial f32 x16 9 GB/s
Serial f32 x256 10 GB/s
AVX-FMA f32 x16 20 GB/s
AVX-FMA f32 x256 24 GB/s

The gap between auto-vectorized code and directly using 128-bit registers is much less pronounced. With AVX2 and 256-bit registers the results should be better, but would be less broadly applicable.


To replicate on your hardware, please run:

cmake -DCMAKE_BUILD_TYPE=Release -DUNSW_BUILD_BENCHMARKS=1 -B ./build && make -C ./build && ./build/simsimd_bench

simsimd's People

Contributors

ashvardanian avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.