Skip to content

Conversation

@yzsolt
Copy link
Contributor

@yzsolt yzsolt commented Nov 11, 2023

Adds support for WebAssembly SIMD, using the currently available stable intrinsics in Rust.

I also added a GitHub action for automated testing. Benchmarking also works, and shows a ~3x improvement of SIMD vs. scalar when running in wasmtime.

Note that I'm not a SIMD expert, so I may have missed some optimization opportunities when implementing operations which don't map 1:1 to WASM SIMD intrinsics. I've tried to follow already existing SSE and NEON implementations though.

Closes #20.

@yzsolt yzsolt mentioned this pull request Nov 11, 2023
@arduano
Copy link
Owner

arduano commented Dec 15, 2024

Request my review when you think it's ready, also please mention how to run/test it

@yzsolt
Copy link
Contributor Author

yzsolt commented Dec 15, 2024

Hey, I think it's ready! Rebased onto master and reenabled the commented out scalar tests.

About testing: I've set up things in a way that if you specify wasm32-wasip1 as target, wasmtime (de-facto standard Rust WebAssembly runtime) will be used for running the produced .wasm modules. It's installed on CI automatically, locally you have to do it yourself beforehand. Both cargo test and cargo bench work for wasm32-wasi.

For more complex testing you can build simdnoise for WebAssembly, which I did back when I initially implemented this. It worked nicely, got the same 2-3x scalar -> SIMD speedups in WASM as in native code.

@yzsolt yzsolt requested a review from arduano December 15, 2024 08:24
Copy link
Owner

@arduano arduano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks about right, I can't find any issues. Is it good to merge?

@yzsolt
Copy link
Contributor Author

yzsolt commented Dec 16, 2024

Looks about right, I can't find any issues. Is it good to merge?

Yes, ship it!

@arduano arduano merged commit b0132e6 into arduano:master Dec 17, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wasm32 support

2 participants