rust-ndarray / ndarray

ndarray: an N-dimensional array with array views, multidimensional slicing, and efficient operations
https://docs.rs/ndarray/
Apache License 2.0
3.63k stars 307 forks source link

SIMD enhanced Wasm compilation #1271

Open antimora opened 1 year ago

antimora commented 1 year ago

Requesting to add SIMD support for Wasm build targets.

Burn project uses NDArray for one its backends. It is possible to build this backend for WASM target.

According to this blog post

Chrome, Firefox, and Node LTS have all stabilized the SIMD extension to Wasm in the last few months (Safari is lagging at the time of writing. See the updated roadmap for changes). Additionally, Rust has stabilized Wasm SIMD intrinsics recently too. All the pieces are set and now is the time to start authoring libraries that take advantage of the promised performance that SIMD can bring.

So it seems the browsers and compiler support SIMD and it would be great if NDArray could also be enhanced with the support.

bluss commented 1 year ago

Just to add some information: ndarray does not use explicit simd anywhere. Wasm would not be the first target we would add, but if explicit simd started to being used, it should of course be in a way that's generic enough to easily add it - if it's in stable Rust it is "straight forward".

A pointer towards what a plan would look like is this: https://github.com/rust-ndarray/ndarray/issues/46#issuecomment-438458138 abstract out numerical loops into a separate module or crate