intel-intrinsics icon indicating copy to clipboard operation
intel-intrinsics copied to clipboard

WASM: use WASM intrinsics for faster performance

Open JohanEngelen opened this issue 3 years ago • 7 comments

I just noticed that WASM also has SIMD support. (I'm not personally interested at the moment, but hope this helps someone in the future ;-)

Perhaps performance is already quite OK, but I can imagine that implementations of certain intrinsics can be improved by using WASM intrinsics.

https://v8.dev/features/simd https://emscripten.org/docs/porting/simd.html

Looks like the LDC/LLVM attribute to add is "simd128": -mattr=+simd128. So that's __traits(targetHasFeature, "simd128"), and version(WebAssembly). https://d.godbolt.org/z/WrxP8EqMo

JohanEngelen avatar Jul 10 '21 13:07 JohanEngelen

Yes, simd-everywhere has support for this. It's a significant amount of work, and I'm not sure if the Webasm target supports the druntime?

p0nce avatar Jul 10 '21 15:07 p0nce

No druntime support yet afaik (I think @skoppe has worked on it), but that's not needed for the intrinsics.

JohanEngelen avatar Jul 10 '21 16:07 JohanEngelen

It seems druntime doesn't build with wasm? image This is with LDC 1.27-b3

p0nce avatar Jul 16 '21 12:07 p0nce

So it turns out when using WASM you can't use druntime nor libc... fun

p0nce avatar Jul 16 '21 12:07 p0nce

yeah... this feature request is too soon, I think.

JohanEngelen avatar Jul 16 '21 13:07 JohanEngelen

mmm apart from _mm_malloc and _mm_free I see no big difficulty (and of course the ever-difficult rounding functions) at least for basic slow support

p0nce avatar Jul 16 '21 14:07 p0nce

Impractical without a libc, since WASM builtin grow memory but do not malloc/free/realloc

p0nce avatar Aug 04 '21 12:08 p0nce