-
-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
port the memchr implementations to "generic SIMD" code #87
Comments
Ok I got a bit overeager and started implementing this. I basically just copied
I'm not super happy how the dispatch currently works in Porting this to wasm should be quite simple on top of #84, and in theory porting to AArch64 would also be super simple since now it's basically just an impl of |
Ok benchmarks. I did one run where I forcibly disabled avx, and this is the result:
and then when I enabled avx:
I think the sse bits have transitioned well but looks like some tuning is needed for avx. |
Closed by #129 |
When I wrote the new memmem implementation earlier this year, one thing I did was write the implementation as something that was generic over the vector type:
memchr/src/memmem/genericsimd.rs
Lines 95 to 107 in 186ac04
where an example of it being called, e.g. for AVX2, is:
memchr/src/memmem/x86/avx.rs
Line 27 in 186ac04
So basically, the idea here is, you write the nasty SIMD code once, and then write some trivial shims for each target feature you want to support.
The actual use of SIMD in this crate is reasonably simple, so it turns out that the trait defining the API of a vector is quite small:
memchr/src/memmem/vector.rs
Lines 21 to 32 in 186ac04
OK, so what's this issue about? I think ideally, we would push the
Vector
trait up a level in the module hierarchy, port the existing x86 SIMD memchr implementation to a "generic" version, and then replace the existing implementations with shims that call out to the generic version.This will hopefully let us easily add a WASM implementation of memchr, but adding other implementations in the future would be good too once more intrinsics (e.g., for ARM) are added to std.
(One wonders whether we should just wait for portable SIMD to land in std, but I don't know when that will happen.)
The text was updated successfully, but these errors were encountered: