-
Notifications
You must be signed in to change notification settings - Fork 258
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
sha2: wasm32 simd128 backends #562
Conversation
I also ended up porting the SHA-256 algorithm from https://github.com/aws-samples/sha2-with-c-intrinsic/blob/master/src/sha256_compress_x86_64_avx.c and updated this PR. Here are updated benchmarks with simd:
|
What's the status of this? |
This follows the https://github.com/aws-samples/sha2-with-c-intrinsic/ AVX impementation, like the SHA-512 backends.
3ee2583
to
6caccad
Compare
6caccad
to
c27cf7a
Compare
This is awaiting review. @newpavlov Do you mind taking a look at this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review! The changes look mostly good
What are advantages of the explicit SIMD backend in the SHA256 case? It has the same performance as the soft backend. Maybe it's smaller in size when compiled?
Did you look at the second comment in this PR? It seems like initially there was no SIMD algorithm used for SHA-256 in the initial version of this PR but that changed the next day as indicated by the second comment. Unless you of course did some more benchmarking and it's indeed not faster anymore. |
Ah, I indeed missed the second comment. I think it's worth to update OP since its text will be included in the merge commit message. |
21b1597
to
4478789
Compare
@max-te
I would like to add these results to the merge commit message. |
Sure, I added that benchmark to the PR description and updated the other ones. |
Thank you! |
This PR ports the AVX implementation of SHA-512 to simd128. It also implements the related version of SHA-256 from https://github.com/aws-samples/sha2-with-c-intrinsic/blob/master/src/sha256_compress_x86_64_avx.c in simd128.
Also added wasm32 testing in CI using wasmtime. Since wasm does not have feature detection, this backend is only used if the
-C target-feature=+simd128
flag is set.Benchmarks on AMD Ryzen 9 7950X3D, running with wasmtime 26.0.0 (c92317bcc 2024-10-22) on rustc 1.84.0-nightly (b3f75cc87 2024-11-02):