SIMD broken with emsdk 1.39.16 and node 14.4.0

74 views
Skip to first unread message

Soeren Balko

unread,
Jun 5, 2020, 3:19:22 AM6/5/20
to emscripten-discuss
I am getting some weird SIMD-related errors when running an FFmpeg build generated with emsdk 1.39.16 and using the ` -msimd128` compiler flag. In the latest node version (14.4.0), I get this. Not even adding `-fno-vectorize` fixes this issue. 

```
CompileError: WebAssembly.compile(): Compiling function #68 failed: i16x8.replace_lane[1] expected type i32, found s128.load128 of type s128 @+33864
```

Assuming that this is caused by an "old" V8 version in node 14.4.0, I have turned to the latest Chrome development build, enabled the WebAssembly SIMD option under chrome://flags. This time, I am getting a different error that I haven't seen before:

```
WebAssembly.instantiate(): memory import 51 has no maximum limit, expected at most 4294967295
```

I am compiling with the `-s ALLOW_MEMORY_GROWTH` flag, which used to work fine in 1.39.11. Any suggestions what may cause these two WebAssembly initialization issues? Is there some sort of compatibility table that states what emsdk is compatible with what node.js and browser versions?

Soeren

Soeren Balko

unread,
Jun 5, 2020, 3:49:49 AM6/5/20
to emscripten-discuss
Update: the "memory import has no maximum limit" issue seems unrelated to the SIMD includes. It appears even when omitting the -msimd128 flag. Is this related to the recent 4GB heap enablement?

Alon Zakai

unread,
Jun 5, 2020, 12:42:04 PM6/5/20
to emscripte...@googlegroups.com
> WebAssembly.instantiate(): memory import 51 has no maximum limit, expected at most 4294967295

Aside from memory growth, what compiler flags are you using for INITIAL_MEMORY and MAXIMUM_MEMORY? And are you creating the memory yourself?

But I'm not sure what causes that error: "no limit" seems compatible with 4GB. So it could be a browser or toolchain bug. Can you share your build?

> Is there some sort of compatibility table that states what emsdk is compatible with what node.js and browser versions?

For SIMD things are still experimental so there is no guaranteed compatibility AFAIK. In general stable features in an emsdk release should work on stable browsers. Something like 4GB support won't work in many browsers today, though, as it isn't stable, and for that reason it isn't on by default in emscripten (for chrome you need 83 or newer, https://v8.dev/blog/4gb-wasm-memory).


--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/67aeaa6a-0a8b-489e-9f4c-027b6a81b520o%40googlegroups.com.

Soeren Balko

unread,
Jun 5, 2020, 8:33:16 PM6/5/20
to emscripten-discuss
Thanks for getting back to me, Alon!

Besides the s ALLOW_MEMORY_GROWTH, we set -s TOTAL_MEMORY=134217728. I just realised that this is now called "INITIAL_MEMORY". Will re-compile with this and report my findings. 

Soeren

To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Soeren Balko

unread,
Jun 5, 2020, 9:17:58 PM6/5/20
to emscripten-discuss
OK, so turns out that the issue was that we construct the WebAssembly.Memory outside the Emscripten-generated code and without the ("maximum") property set in the constructor. We do so in order to be able to re-use the same WebAssembly.Memory instance across multiple subsequent WebAssembly instances.

The "maximum" property used to be optional - is it no longer?

Soeren

Alon Zakai

unread,
Jun 8, 2020, 4:00:13 PM6/8/20
to emscripte...@googlegroups.com
In that case, I think you may need to set MAXIMUM_MEMORY to 4GB, or to -1, so that it is compatible with your manually-created memory.

What I think might have changed here is that emscripten now sets the default MAXIMUM_MEMORY to 2GB. That is because not all VMs support 4GB yet, and also since to support more than 2GB we need to increase code size a little, so we don't want that by default.



--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/a9b94bf6-97b7-49cd-9d63-92cc9f730f1co%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages