#iterator #simd #algorithm #operations #simd-accelerated #find #max

simd-itertools

SIMD-accelerated alternatives for common operations like contains, max, find etc

7 releases

0.3.0 Feb 8, 2025
0.2.3 Jul 15, 2024
0.1.1 Jul 11, 2024

#224 in Concurrency

Download history 37/week @ 2024-10-29 13/week @ 2024-11-05 33/week @ 2024-11-12 28/week @ 2024-11-19 22/week @ 2024-11-26 9/week @ 2024-12-03 62/week @ 2024-12-10 81/week @ 2024-12-17 139/week @ 2024-12-24 231/week @ 2024-12-31 179/week @ 2025-01-07 135/week @ 2025-01-14 244/week @ 2025-01-21 130/week @ 2025-01-28 440/week @ 2025-02-04 259/week @ 2025-02-11

1,075 downloads per month
Used in candystore

MIT/Apache

150KB
798 lines

SIMD-accelerated iterators

crates.io

Unmatched flexibility 🤯

let needles = [42, 52, 94];
arr.iter().any_simd(|x| needles.contains(x) || x > 156);
  • Works by letting LLVM do the vectorization (may change in the future).
  • Functions are made easy to paste into Godbolt for inspection.

Currently the following are implemented:

find filter position all any argmin/argmax

Tradeoffs

Every piece of software makes tradeoffs. The goal of this library it to provide the majority of performance gains gained from going scalar -> vectorized, while staying user-friendly. If you are looking to shave off the last few cycles this might not be what you are looking for.

⚠️ Warning ⚠️:

The library makes one extra assumption over the stdlib: The closure may be executed any number of times:

arr.iter().simd_position(|x| {
    println!("hello world");
    *x == 42
})

May print a different number of times compared to the standard library. This shouldn't be an issue under normal use-cases but something to keep in mind.

Why is this not part of the standard library

It's tricky. Hopefully one day.

Dependencies

~245–680KB
~16K SLoC