Replies: 24 comments
-
We were thinking about doing WebAsm but we were considering targeting proposed web assembly extensions. The doc you linked says:
This approach with intrinsic conversion is a good idea and should hopefully tie you over. On AVX we will by default select a 32 bit register, which means all sort of unpleasantness for you. Example:
|
Beta Was this translation helpful? Give feedback.
-
Do not hesitate to reach out, we are happy for people to try out the library. On top of creating issues, you can: cpplang slack: jfalcou, dyaroshev |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick reply. I'll see if I can get setup and benchmarked this weekend. |
Beta Was this translation helpful? Give feedback.
-
👍 I personally have zero doubts that the first attempt will fail, please reach out. |
Beta Was this translation helpful? Give feedback.
-
Can't we consider wasm simd as a separate target architecture ? |
Beta Was this translation helpful? Give feedback.
-
Sure we can and should. Porting will take a long time though. But @ruler501 - wants to use eve now and the cross compilation should be a solid option. |
Beta Was this translation helpful? Give feedback.
-
I did what you suggested (added
... and much more similar. It appears that EVE is attempting to use 256-bit AVX. Is there a way to prevent that? |
Beta Was this translation helpful? Give feedback.
-
Normally, EVE detects and includes the SSE extensions by itself. Now, we use SPY to detect extensions so maybe I need to fix SPY for emscripten ? |
Beta Was this translation helpful? Give feedback.
-
Possibly. I've created a little test like this:
It always fails on emscripten:
|
Beta Was this translation helpful? Give feedback.
-
If no SIMD is detected, all operations are emulated indeed. Alternatively, maybe we should first see if SPY (https://github.com/jfalcou/spy) works with emscripten by running the SPY test with it. |
Beta Was this translation helpful? Give feedback.
-
If I build without |
Beta Was this translation helpful? Give feedback.
-
Btw, emscripten 2.0.31, which I'm using, is based on LLVM 14, but it still uses libc++ from LLVM 12, which doesn't provide support for concepts STL library. I've worked around this by backporting required stuff from LLVM 13 (which is released and fully supports concepts STL lib). If you need it for your testing, grab it here: Just unzip it and put it somewhere in your include path. Same trick is also needed when building with Android NDK r23 (also based on LLVM 12) and with Xcode 13 (iOS and macOS; also based on LLVM 12). |
Beta Was this translation helpful? Give feedback.
-
Yeah the libc++ support is still flaky. |
Beta Was this translation helpful? Give feedback.
-
Yes. From the Emscripten documentation:
The Also, you can find the Emscripten's SSE emulation header here - it may also provide a good baseline for proper WASM SIMD support in EVE. Emscripten also provides other emulation headers, for easier porting of ARM NEON code as well. You can see how it works here, but SSE and SSE2 emulation works best (most of the intrinsics are 1:1 with WASM SIMD). |
Beta Was this translation helpful? Give feedback.
-
Lack of intrinsics even defined is annoying. I dealt with this when doing a clang based refactoring at one point. But it's nasty for real use-case. |
Beta Was this translation helpful? Give feedback.
-
You can try putting it here: eve/include/eve/arch/x86/predef.hpp Line 61 in 26d50d5 Should be similar to this for arm: eve/include/eve/arch/arm/predef.hpp Line 19 in 26d50d5 THis is obviously a hack so I can't tell you if it will work or not. |
Beta Was this translation helpful? Give feedback.
-
Maybe we can actually modify spec.hpp for x86 by wrapping the >128 test in a macro that detects emscipten properly ? |
Beta Was this translation helpful? Give feedback.
-
My opinion: We should try to hack x86 to unblock @DoDoENT The initial commit for that is big but not that big. It will go through emulation most of the time, which will be bad (that's why I suggest hacking x86 at the moment) but we can fix the gaps as we go along. |
Beta Was this translation helpful? Give feedback.
-
@DenisYaroshevskiy , this appears to be working for me at the moment. It compiles and runs and actually uses WASM SIMD (tested on Browser that doesn't support SIMD (Safari) and it fails to run the binary, as expected, and it works correctly on Chrome). I'll make some more tests on my side (I'm still learning the API, the documentation is pretty scarce - I'm basically doing everything based on this example) and add more stubs if needed. Afterward, I can create a PR. |
Beta Was this translation helpful? Give feedback.
-
The fact that you have to stab functions as well as registers is non sustainable. I will try to have a look at actually hooking up the WASM implementation proper this weekend. What I think can work in a mean time is, instead of writing the wrappers yourself, you can try hooking up Simd Everywhere, which has WASM <=> x86 emulation complete. https://github.com/simd-everywhere/simde Defining |
Beta Was this translation helpful? Give feedback.
-
With respect to documentation being scarce, yeah - feel free to report an issue or ask on C++ lang Slack "@jfalcou" or "@dyaroshev" - we can sketch you an example. |
Beta Was this translation helpful? Give feedback.
-
Given that @DoDoENT discovered eve doesn't work for them - will push this back a bit |
Beta Was this translation helpful? Give feedback.
-
Given my schedule in the upcoming month at least I don't see this happening soon. |
Beta Was this translation helpful? Give feedback.
-
We need to get a proper testing harness first anyway |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
I'm writing a library that is used both in-browser and as a standalone application. I'd love to be able to use SIMD to accelerate the computations.
Describe the solution you'd like
A reasonably easy way to use simd on both x86 architectures and webassembly (through emscripten) that doesn't require too extensive platform specific code.
Describe alternatives you've considered
I don't need simd that many places so I've considered trying to hand write the functions for webassembly and switch between them at compile time.
Additional context
https://emscripten.org/docs/porting/simd.html is the documentation I've been referring to.
Beta Was this translation helpful? Give feedback.
All reactions