4 ms·
Right. I pointed it out because it isn't just about having portable SIMD that makes SIMD optimizations possible. Therefore, the lack of one in Rust doesn't have
by burntsushi 3y ago
Right. I pointed it out because it isn't just about having portable SIMD that makes SIMD optimizations possible. Therefore, the lack of one in Rust doesn't have much explanatory power for why Rust's standard library doesn't contain SIMD. (It does have some.) It's good enough for things like memchr (well, kinda, NEON doesn't have `movemask`[1,2]), but not for things like Teddy that do multi-substring search. When you do want to write SIMD across platforms, it's not too hard to define your own bespoke portable API[3].
I'm basically just pointing out that a portable API is somewhat oversold, because it's not uncommon to need to abandon it, especially for string related ops that make creative use of ISA extensions. And additionally, that Rust unfortunately has other reasons for why std doesn't make as much use of SIMD as it probably should (the core/alloc/std split).
[1]: https://github.com/BurntSushi/memchr/blob/c6b885b870b6f1b9bfae2de482e1264d6c7aa040/src/vector.rs#L326-L333 https://github.com/BurntSushi/memchr/blob/c6b885b870b6f1b9bf...
[2]: https://github.com/BurntSushi/memchr/blob/c6b885b870b6f1b9bfae2de482e1264d6c7aa040/src/vector.rs#L363-L379 https://github.com/BurntSushi/memchr/blob/c6b885b870b6f1b9bf...
[3]: https://github.com/BurntSushi/aho-corasick/blob/f227162f7c56b3f28e9dd69a655316af0107b29b/src/packed/vector.rs https://github.com/BurntSushi/aho-corasick/blob/f227162f7c56...
- neonsunset 3y agoHeh, movemask keeps coming back. Rather than emulating it, it appears to be more efficient to separately handle IndexOfMatch, LastIndexOfMatch and GetMatchCount scenarios it is used for most of the time: - https://github.com/dotnet/runtime/pull/94472/files#diff-58242a9637faae8972d2b49c63a1a17a582b4198f9e0bed27b6615cb47f068fdR3061-R3069 https://github.com/dotnet/runtime/pull/94472/files#diff-5824... (it's closed for now but I'm hoping to get back to it at some point) - https://github.com/jprochazk/tmi-rs/blob/ac3ce6aee8bbe038a983ed9ce41b67c34ce3e4c9/src/irc/simd/arm_neon.rs#L236 https://github.com/jprochazk/tmi-rs/blob/ac3ce6aee8bbe038a98... It can account for good 30% performance variance depending on the use case (on Apple's M-series cores).
- burntsushi 3y agoThat's what the `memchr` crate does. It uses `vshrn` just like in your links. And vpmaxq before even bothering with vshrn: https://github.com/BurntSushi/memchr/blob/c6b885b870b6f1b9bfae2de482e1264d6c7aa040/src/vector.rs#L357-L360 https://github.com/BurntSushi/memchr/blob/c6b885b870b6f1b9bf...