#hamming #avx2 #popcount

hamming_rs

Computes Hamming distance and weight -- if available, uses a highly optimized avx2 implementation

7 releases

0.2.22 Feb 3, 2024
0.2.21 Apr 20, 2022
0.1.1 Apr 16, 2022

#501 in Hardware support

MIT license

4MB
445 lines

Contains (WOFF font, 680KB) target/doc/NanumBarunGothic.ttf.woff, (WOFF font, 400KB) target/doc/NanumBarunGothic.ttf.woff2, (WOFF font, 400KB) NanumBarunGothic-0f09457c7a19b7c6.ttf.woff2, (WOFF font, 190KB) target/doc/FiraSans-Medium.woff, (WOFF font, 135KB) target/doc/FiraSans-Medium.woff2, (WOFF font, 185KB) target/doc/FiraSans-Regular.woff and 21 more.

hamming_rs

Computes hamming distance and weight, possibly with avx/avx2 instructions for x86 processors
avx2 optimized version is used when inputs have same memory alignment
otherwise, functions will fallback to slower versions

references

Muła, Wojciech, Nathan Kurz, and Daniel Lemire. "Faster population counts using AVX2 instructions." The Computer Journal 61.1 (2018): 111-120.

https://arxiv.org/pdf/1611.07612.pdf

performances

We ran benchmarks with cargo bench on a laptop with a Intel core i7-8750H @2.2Ghz with 16Gb of RAM
We compare the avx2 version (with inputs aligned to 256 bytes) against hamming and strsim reference crates
We notice a speedup of ~4 against hamming and of ~100 against strsim

hamming_rs vs hamming hamming_rs vs strsim

No runtime deps